shaders 0.0.1 → 2.0.0-alpha.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 (90) hide show
  1. package/LICENSE +17 -0
  2. package/dist/react/components/Circle.d.ts +22 -0
  3. package/dist/react/components/Circle.d.ts.map +1 -0
  4. package/dist/react/components/GlassTiles.d.ts +22 -0
  5. package/dist/react/components/GlassTiles.d.ts.map +1 -0
  6. package/dist/react/components/Grayscale.d.ts +22 -0
  7. package/dist/react/components/Grayscale.d.ts.map +1 -0
  8. package/dist/react/components/HueShift.d.ts +22 -0
  9. package/dist/react/components/HueShift.d.ts.map +1 -0
  10. package/dist/react/components/Invert.d.ts +22 -0
  11. package/dist/react/components/Invert.d.ts.map +1 -0
  12. package/dist/react/components/LinearGradient.d.ts +22 -0
  13. package/dist/react/components/LinearGradient.d.ts.map +1 -0
  14. package/dist/react/components/Posterize.d.ts +22 -0
  15. package/dist/react/components/Posterize.d.ts.map +1 -0
  16. package/dist/react/components/Saturation.d.ts +22 -0
  17. package/dist/react/components/Saturation.d.ts.map +1 -0
  18. package/dist/react/components/SolidColor.d.ts +22 -0
  19. package/dist/react/components/SolidColor.d.ts.map +1 -0
  20. package/dist/react/components/Twirl.d.ts +22 -0
  21. package/dist/react/components/Twirl.d.ts.map +1 -0
  22. package/dist/react/components/Vibrance.d.ts +22 -0
  23. package/dist/react/components/Vibrance.d.ts.map +1 -0
  24. package/dist/react/engine/Ombre.d.ts +22 -0
  25. package/dist/react/engine/Ombre.d.ts.map +1 -0
  26. package/dist/react/engine/component.template.d.ts +22 -0
  27. package/dist/react/engine/component.template.d.ts.map +1 -0
  28. package/dist/react/index.cjs +168 -0
  29. package/dist/react/index.cjs.map +1 -0
  30. package/dist/react/index.d.ts +13 -0
  31. package/dist/react/index.d.ts.map +1 -0
  32. package/dist/react/index.js +35833 -0
  33. package/dist/react/index.js.map +1 -0
  34. package/dist/svelte/components/Circle.svelte +202 -0
  35. package/dist/svelte/components/Circle.svelte.d.ts +39 -0
  36. package/dist/svelte/components/GlassTiles.svelte +202 -0
  37. package/dist/svelte/components/GlassTiles.svelte.d.ts +39 -0
  38. package/dist/svelte/components/Grayscale.svelte +202 -0
  39. package/dist/svelte/components/Grayscale.svelte.d.ts +39 -0
  40. package/dist/svelte/components/HueShift.svelte +202 -0
  41. package/dist/svelte/components/HueShift.svelte.d.ts +39 -0
  42. package/dist/svelte/components/Invert.svelte +202 -0
  43. package/dist/svelte/components/Invert.svelte.d.ts +39 -0
  44. package/dist/svelte/components/LinearGradient.svelte +202 -0
  45. package/dist/svelte/components/LinearGradient.svelte.d.ts +39 -0
  46. package/dist/svelte/components/Posterize.svelte +202 -0
  47. package/dist/svelte/components/Posterize.svelte.d.ts +39 -0
  48. package/dist/svelte/components/Saturation.svelte +202 -0
  49. package/dist/svelte/components/Saturation.svelte.d.ts +39 -0
  50. package/dist/svelte/components/SolidColor.svelte +202 -0
  51. package/dist/svelte/components/SolidColor.svelte.d.ts +39 -0
  52. package/dist/svelte/components/Twirl.svelte +202 -0
  53. package/dist/svelte/components/Twirl.svelte.d.ts +39 -0
  54. package/dist/svelte/components/Vibrance.svelte +202 -0
  55. package/dist/svelte/components/Vibrance.svelte.d.ts +39 -0
  56. package/dist/svelte/engine/Ombre.svelte +101 -0
  57. package/dist/svelte/engine/Ombre.svelte.d.ts +31 -0
  58. package/dist/svelte/engine/component.template.svelte +202 -0
  59. package/dist/svelte/engine/component.template.svelte.d.ts +39 -0
  60. package/dist/svelte/index.d.ts +12 -0
  61. package/dist/svelte/index.js +12 -0
  62. package/dist/vue/components/Circle.vue.d.ts +51 -0
  63. package/dist/vue/components/Circle.vue.d.ts.map +1 -0
  64. package/dist/vue/components/GlassTiles.vue.d.ts +51 -0
  65. package/dist/vue/components/GlassTiles.vue.d.ts.map +1 -0
  66. package/dist/vue/components/Grayscale.vue.d.ts +51 -0
  67. package/dist/vue/components/Grayscale.vue.d.ts.map +1 -0
  68. package/dist/vue/components/HueShift.vue.d.ts +51 -0
  69. package/dist/vue/components/HueShift.vue.d.ts.map +1 -0
  70. package/dist/vue/components/Invert.vue.d.ts +51 -0
  71. package/dist/vue/components/Invert.vue.d.ts.map +1 -0
  72. package/dist/vue/components/LinearGradient.vue.d.ts +51 -0
  73. package/dist/vue/components/LinearGradient.vue.d.ts.map +1 -0
  74. package/dist/vue/components/Posterize.vue.d.ts +51 -0
  75. package/dist/vue/components/Posterize.vue.d.ts.map +1 -0
  76. package/dist/vue/components/Saturation.vue.d.ts +51 -0
  77. package/dist/vue/components/Saturation.vue.d.ts.map +1 -0
  78. package/dist/vue/components/SolidColor.vue.d.ts +51 -0
  79. package/dist/vue/components/SolidColor.vue.d.ts.map +1 -0
  80. package/dist/vue/components/Twirl.vue.d.ts +51 -0
  81. package/dist/vue/components/Twirl.vue.d.ts.map +1 -0
  82. package/dist/vue/components/Vibrance.vue.d.ts +51 -0
  83. package/dist/vue/components/Vibrance.vue.d.ts.map +1 -0
  84. package/dist/vue/engine/Ombre.vue.d.ts +38 -0
  85. package/dist/vue/engine/Ombre.vue.d.ts.map +1 -0
  86. package/dist/vue/index.d.ts +13 -0
  87. package/dist/vue/index.d.ts.map +1 -0
  88. package/dist/vue/index.js +456 -0
  89. package/package.json +34 -7
  90. package/README.md +0 -0
@@ -0,0 +1,456 @@
1
+ import{computed as e,createElementBlock as t,createElementVNode as n,defineComponent as r,effectScope as i,inject as a,mergeDefaults as o,mergeProps as s,onBeforeUnmount as c,onMounted as l,openBlock as u,provide as d,ref as f,renderSlot as p,toValue as m,watch as h}from"vue";var g=Object.defineProperty,_=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})};const v=`177`,y=0,b=1,x=2,S=0,ee=1,te=3,ne=0,re=1,ie=2,ae=0,oe=1,se=2,ce=3,le=4,ue=5,de=100,fe=101,pe=102,me=103,he=104,ge=200,_e=201,ve=202,ye=203,be=204,xe=205,Se=206,Ce=207,we=208,Te=209,Ee=210,De=0,Oe=1,ke=2,Ae=3,je=4,Me=5,Ne=6,Pe=7,Fe=0,Ie=1,Le=2,Re=0,ze=1,Be=2,Ve=3,He=4,Ue=6,We=7,Ge=300,Ke=301,qe=302,Je=303,Ye=304,Xe=306,Ze=1e3,Qe=1001,$e=1002,et=1003,tt=1004,nt=1005,rt=1006,it=1007,at=1008,ot=1008,st=1009,ct=1010,lt=1011,ut=1012,dt=1013,ft=1014,pt=1015,mt=1016,ht=1017,gt=1018,_t=1020,vt=35902,eee=1021,yt=1022,bt=1023,xt=1026,St=1027,Ct=1028,wt=1029,Tt=1030,Et=1031,Dt=1032,Ot=1033,kt=33776,At=33777,jt=33778,Mt=33779,Nt=35840,Pt=35841,Ft=35842,It=35843,Lt=36196,Rt=37492,zt=37496,Bt=37808,Vt=37809,Ht=37810,Ut=37811,Wt=37812,Gt=37813,Kt=37814,qt=37815,Jt=37816,Yt=37817,Xt=37818,Zt=37819,Qt=37820,$t=37821,en=36492,tn=36283,nn=36284,rn=36285,an=36286,on=2300,sn=2301,cn=2302,ln=2400,un=2401,dn=2402,fn=0,pn=1,mn=``,hn=`srgb`,gn=`srgb-linear`,_n=`linear`,vn=`srgb`,yn=0,bn=7680,xn=7681,Sn=7682,Cn=7683,wn=34055,tee=34056,Tn=5386,En=512,Dn=513,On=514,kn=515,An=516,jn=517,Mn=518,Nn=519,Pn=512,Fn=513,In=514,Ln=515,Rn=516,zn=517,Bn=518,Vn=519,Hn=35044,Un=35048,Wn=2e3,Gn=2001;var Kn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const qn=`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`.split(`.`);let Jn=1234567;const Yn=Math.PI/180,Xn=180/Math.PI;function Zn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=qn[e&255]+qn[e>>8&255]+qn[e>>16&255]+qn[e>>24&255]+`-`+qn[t&255]+qn[t>>8&255]+`-`+qn[t>>16&15|64]+qn[t>>24&255]+`-`+qn[n&63|128]+qn[n>>8&255]+`-`+qn[n>>16&255]+qn[n>>24&255]+qn[r&255]+qn[r>>8&255]+qn[r>>16&255]+qn[r>>24&255];return i.toLowerCase()}function Qn(e,t,n){return Math.max(t,Math.min(n,e))}function $n(e,t){return(e%t+t)%t}function er(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function tr(e,t,n){return e===t?0:(n-e)/(t-e)}function nr(e,t,n){return(1-n)*e+n*t}function rr(e,t,n,r){return nr(e,t,1-Math.exp(-n*r))}function ir(e,t=1){return t-Math.abs($n(e,t*2)-t)}function ar(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function nee(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function ree(e,t){return e+Math.floor(Math.random()*(t-e+1))}function iee(e,t){return e+Math.random()*(t-e)}function aee(e){return e*(.5-Math.random())}function oee(e){e!==void 0&&(Jn=e);let t=Jn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function see(e){return e*Yn}function cee(e){return e*Xn}function lee(e){return(e&e-1)==0&&e!==0}function uee(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function dee(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function fee(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function or(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function sr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const cr={DEG2RAD:Yn,RAD2DEG:Xn,generateUUID:Zn,clamp:Qn,euclideanModulo:$n,mapLinear:er,inverseLerp:tr,lerp:nr,damp:rr,pingpong:ir,smoothstep:ar,smootherstep:nee,randInt:ree,randFloat:iee,randFloatSpread:aee,seededRandom:oee,degToRad:see,radToDeg:cee,isPowerOfTwo:lee,ceilPowerOfTwo:uee,floorPowerOfTwo:dee,setQuaternionFromProperEuler:fee,normalize:sr,denormalize:or};var lr=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}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 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 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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Qn(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Qn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ur=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,n,r){return this._x=e,this._y=t,this._z=n,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){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Qn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*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=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},C=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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 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 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(fr.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fr.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-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){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this.z=Qn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this.z=Qn(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Qn(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return dr.copy(this).projectOnVector(e),this.sub(dr)}reflect(e){return this.sub(dr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Qn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const dr=new C,fr=new ur;var pr=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,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){let 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,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(mr.makeScale(e,t)),this}rotate(e){return this.premultiply(mr.makeRotation(-e)),this}translate(e,t){return this.premultiply(mr.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){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const mr=new pr;function hr(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function gr(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function _r(){let e=gr(`canvas`);return e.style.display=`block`,e}const vr={};function yr(e){e in vr||(vr[e]=!0,console.warn(e))}const br=new pr().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),xr=new pr().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Sr(){let e={enabled:!0,workingColorSpace:gn,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===vn&&(e.r=wr(e.r),e.g=wr(e.g),e.b=wr(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===vn&&(e.r=Tr(e.r),e.g=Tr(e.g),e.b=Tr(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===mn?_n:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return yr(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return yr(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[gn]:{primaries:t,whitePoint:r,transfer:_n,toXYZ:br,fromXYZ:xr,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:t,whitePoint:r,transfer:vn,toXYZ:br,fromXYZ:xr,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}}),e}const Cr=Sr();function wr(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Tr(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let Er;var Dr=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Er===void 0&&(Er=gr(`canvas`)),Er.width=e.width,Er.height=e.height;let t=Er.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Er}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=gr(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=wr(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(wr(t[e]/255)*255):t[e]=wr(t[e]);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 Or=0;var kr=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:Or++}),this.uuid=Zn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Ar(r[t].image)):e.push(Ar(r[t]))}else e=Ar(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Ar(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Dr.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let jr=0;const Mr=new C;var Nr=class e extends Kn{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=Qe,i=Qe,a=rt,o=at,s=bt,c=st,l=e.DEFAULT_ANISOTROPY,u=mn){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:jr++}),this.uuid=Zn(),this.name=``,this.source=new kr(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new lr(0,0),this.repeat=new lr(1,1),this.center=new lr(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Mr).x}get height(){return this.source.getSize(Mr).y}get depth(){return this.source.getSize(Mr).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==Ge)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ze:e.x-=Math.floor(e.x);break;case Qe:e.x=e.x<0?0:1;break;case $e:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ze:e.y-=Math.floor(e.y);break;case Qe:e.y=e.y<0?0:1;break;case $e:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(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++}};Nr.DEFAULT_IMAGE=null,Nr.DEFAULT_MAPPING=Ge,Nr.DEFAULT_ANISOTROPY=1;var Pr=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}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,n,r){return this.x=e,this.y=t,this.z=n,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 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 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?1:e.w,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){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let 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,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let 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=Qn(this.x,e.x,t.x),this.y=Qn(this.y,e.y,t.y),this.z=Qn(this.z,e.z,t.z),this.w=Qn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Qn(this.x,e,t),this.y=Qn(this.y,e,t),this.z=Qn(this.z,e,t),this.w=Qn(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Qn(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}},Fr=class extends Kn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Pr(0,0,e,t),this.scissorTest=!1,this.viewport=new Pr(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new Nr(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:rt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new kr(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},Ir=class extends Fr{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Lr=class extends Nr{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=et,this.minFilter=et,this.wrapR=Qe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Rr=class{constructor(e=new C(1/0,1/0,1/0),t=new C(-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,n=e.length;t<n;t+=3)this.expandByPoint(Br.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Br.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Br.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Br):Br.fromBufferAttribute(r,t),Br.applyMatrix4(e.matrixWorld),this.expandByPoint(Br);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),Vr.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Vr.copy(e.boundingBox)),Vr.applyMatrix4(e.matrixWorld),this.union(Vr)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],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,Br),Br.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Jr),Yr.subVectors(this.max,Jr),Hr.subVectors(e.a,Jr),Ur.subVectors(e.b,Jr),Wr.subVectors(e.c,Jr),Gr.subVectors(Ur,Hr),Kr.subVectors(Wr,Ur),qr.subVectors(Hr,Wr);let t=[0,-Gr.z,Gr.y,0,-Kr.z,Kr.y,0,-qr.z,qr.y,Gr.z,0,-Gr.x,Kr.z,0,-Kr.x,qr.z,0,-qr.x,-Gr.y,Gr.x,0,-Kr.y,Kr.x,0,-qr.y,qr.x,0];return!Qr(t,Hr,Ur,Wr,Yr)||(t=[1,0,0,0,1,0,0,0,1],!Qr(t,Hr,Ur,Wr,Yr))?!1:(Xr.crossVectors(Gr,Kr),t=[Xr.x,Xr.y,Xr.z],Qr(t,Hr,Ur,Wr,Yr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Br).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Br).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:(zr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zr),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const zr=[new C,new C,new C,new C,new C,new C,new C,new C],Br=new C,Vr=new Rr,Hr=new C,Ur=new C,Wr=new C,Gr=new C,Kr=new C,qr=new C,Jr=new C,Yr=new C,Xr=new C,Zr=new C;function Qr(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Zr.fromArray(e,a);let o=i.x*Math.abs(Zr.x)+i.y*Math.abs(Zr.y)+i.z*Math.abs(Zr.z),s=t.dot(Zr),c=n.dot(Zr),l=r.dot(Zr);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const $r=new Rr,ei=new C,ti=new C;var ni=class{constructor(e=new C,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){let n=this.center;t===void 0?$r.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));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){let 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){let n=this.center.distanceToSquared(e);return t.copy(e),n>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*=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;ei.subVectors(e,this.center);let t=ei.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(ei,n/e),this.radius+=n}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):(ti.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ei.copy(e.center).add(ti)),this.expandByPoint(ei.copy(e.center).sub(ti))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const ri=new C,ii=new C,ai=new C,oi=new C,si=new C,ci=new C,li=new C;var ui=class{constructor(e=new C,t=new C(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,ri)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ri.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ri.copy(this.origin).addScaledVector(this.direction,t),ri.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ii.copy(e).add(t).multiplyScalar(.5),ai.copy(t).sub(e).normalize(),oi.copy(this.origin).sub(ii);let i=e.distanceTo(t)*.5,a=-this.direction.dot(ai),o=oi.dot(this.direction),s=-oi.dot(ai),c=oi.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(ii).addScaledVector(ai,d),f}intersectSphere(e,t){ri.subVectors(e.center,this.origin);let n=ri.dot(this.direction),r=ri.dot(ri)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ri)!==null}intersectTriangle(e,t,n,r,i){si.subVectors(t,e),ci.subVectors(n,e),li.crossVectors(si,ci);let a=this.direction.dot(li),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;oi.subVectors(this.origin,e);let s=o*this.direction.dot(ci.crossVectors(oi,ci));if(s<0)return null;let c=o*this.direction.dot(si.cross(oi));if(c<0||s+c>a)return null;let l=-o*oi.dot(li);return l<0?null:this.at(l/a,i)}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)}},di=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/fi.setFromMatrixColumn(e,0).length(),i=1/fi.setFromMatrixColumn(e,1).length(),a=1/fi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}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(mi,e,hi)}lookAt(e,t,n){let r=this.elements;return vi.subVectors(e,t),vi.lengthSq()===0&&(vi.z=1),vi.normalize(),gi.crossVectors(n,vi),gi.lengthSq()===0&&(Math.abs(n.z)===1?vi.x+=1e-4:vi.z+=1e-4,vi.normalize(),gi.crossVectors(n,vi)),gi.normalize(),_i.crossVectors(vi,gi),r[0]=gi.x,r[4]=_i.x,r[8]=vi.x,r[1]=gi.y,r[5]=_i.y,r[9]=vi.y,r[2]=gi.z,r[6]=_i.z,r[10]=vi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,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,n){let 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]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=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,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=fi.set(r[0],r[1],r[2]).length(),a=fi.set(r[4],r[5],r[6]).length(),o=fi.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],pi.copy(this);let c=1/i,l=1/a,u=1/o;return pi.elements[0]*=c,pi.elements[1]*=c,pi.elements[2]*=c,pi.elements[4]*=l,pi.elements[5]*=l,pi.elements[6]*=l,pi.elements[8]*=u,pi.elements[9]*=u,pi.elements[10]*=u,t.setFromRotationMatrix(pi),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Wn){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===Wn)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===Gn)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Wn){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===Wn)p=(a+i)*u,m=-2*u;else if(o===Gn)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const fi=new C,pi=new di,mi=new C(0,0,0),hi=new C(1,1,1),gi=new C,_i=new C,vi=new C,yi=new di,bi=new ur;var xi=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}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,n,r=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(Qn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-Qn(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(Qn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-Qn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(Qn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-Qn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return yi.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yi,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bi.setFromEuler(this),this.setFromQuaternion(bi,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}};xi.DEFAULT_ORDER=`XYZ`;var Si=class{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 Ci=0;const wi=new C,Ti=new ur,Ei=new di,Di=new C,Oi=new C,ki=new C,Ai=new ur,ji=new C(1,0,0),Mi=new C(0,1,0),Ni=new C(0,0,1),Pi={type:`added`},Fi={type:`removed`},Ii={type:`childadded`,child:null},Li={type:`childremoved`,child:null};var Ri=class e extends Kn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:Ci++}),this.uuid=Zn(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new C,n=new xi,r=new ur,i=new C(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new di},normalMatrix:{value:new pr}}),this.matrix=new di,this.matrixWorld=new di,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Si,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.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 Ti.setFromAxisAngle(e,t),this.quaternion.multiply(Ti),this}rotateOnWorldAxis(e,t){return Ti.setFromAxisAngle(e,t),this.quaternion.premultiply(Ti),this}rotateX(e){return this.rotateOnAxis(ji,e)}rotateY(e){return this.rotateOnAxis(Mi,e)}rotateZ(e){return this.rotateOnAxis(Ni,e)}translateOnAxis(e,t){return wi.copy(e).applyQuaternion(this.quaternion),this.position.add(wi.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ji,e)}translateY(e){return this.translateOnAxis(Mi,e)}translateZ(e){return this.translateOnAxis(Ni,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ei.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Di.copy(e):Di.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Oi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ei.lookAt(Oi,Di,this.up):Ei.lookAt(Di,Oi,this.up),this.quaternion.setFromRotationMatrix(Ei),r&&(Ei.extractRotation(r.matrixWorld),Ti.setFromRotationMatrix(Ei),this.quaternion.premultiply(Ti.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);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(Pi),Ii.child=e,this.dispatchEvent(Ii),Ii.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fi),Li.child=e,this.dispatchEvent(Li),Li.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ei.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ei.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ei),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pi),Ii.child=e,this.dispatchEvent(Ii),Ii.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 n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,e,ki),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,Ai,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let 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);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let 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.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.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=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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 t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};Ri.DEFAULT_UP=new C(0,1,0),Ri.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ri.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zi=new C,Bi=new C,Vi=new C,Hi=new C,Ui=new C,Wi=new C,Gi=new C,Ki=new C,qi=new C,Ji=new C,Yi=new Pr,Xi=new Pr,Zi=new Pr;var Qi=class e{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),zi.subVectors(e,t),r.cross(zi);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){zi.subVectors(r,t),Bi.subVectors(n,t),Vi.subVectors(e,t);let a=zi.dot(zi),o=zi.dot(Bi),s=zi.dot(Vi),c=Bi.dot(Bi),l=Bi.dot(Vi),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Hi)===null?!1:Hi.x>=0&&Hi.y>=0&&Hi.x+Hi.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Hi)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Hi.x),s.addScaledVector(a,Hi.y),s.addScaledVector(o,Hi.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Yi.setScalar(0),Xi.setScalar(0),Zi.setScalar(0),Yi.fromBufferAttribute(e,t),Xi.fromBufferAttribute(e,n),Zi.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Yi,i.x),a.addScaledVector(Xi,i.y),a.addScaledVector(Zi,i.z),a}static isFrontFacing(e,t,n,r){return zi.subVectors(n,t),Bi.subVectors(e,t),zi.cross(Bi).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 zi.subVectors(this.c,this.b),Bi.subVectors(this.a,this.b),zi.cross(Bi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Ui.subVectors(r,n),Wi.subVectors(i,n),Ki.subVectors(e,n);let s=Ui.dot(Ki),c=Wi.dot(Ki);if(s<=0&&c<=0)return t.copy(n);qi.subVectors(e,r);let l=Ui.dot(qi),u=Wi.dot(qi);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Ui,a);Ji.subVectors(e,i);let f=Ui.dot(Ji),p=Wi.dot(Ji);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Wi,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Gi.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Gi,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Ui,a).addScaledVector(Wi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const $i={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},ea={h:0,s:0,l:0},ta={h:0,s:0,l:0};function na(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var ra=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=hn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cr.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Cr.workingColorSpace){return this.r=e,this.g=t,this.b=n,Cr.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Cr.workingColorSpace){if(e=$n(e,1),t=Qn(t,0,1),n=Qn(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=na(i,r,e+1/3),this.g=na(i,r,e),this.b=na(i,r,e-1/3)}return Cr.colorSpaceToWorking(this,r),this}setStyle(e,t=hn){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,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=hn){let n=$i[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),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=wr(e.r),this.g=wr(e.g),this.b=wr(e.b),this}copyLinearToSRGB(e){return this.r=Tr(e.r),this.g=Tr(e.g),this.b=Tr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hn){return Cr.workingToColorSpace(ia.copy(this),e),Math.round(Qn(ia.r*255,0,255))*65536+Math.round(Qn(ia.g*255,0,255))*256+Math.round(Qn(ia.b*255,0,255))}getHexString(e=hn){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Cr.workingColorSpace){Cr.workingToColorSpace(ia.copy(this),t);let n=ia.r,r=ia.g,i=ia.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=Cr.workingColorSpace){return Cr.workingToColorSpace(ia.copy(this),t),e.r=ia.r,e.g=ia.g,e.b=ia.b,e}getStyle(e=hn){Cr.workingToColorSpace(ia.copy(this),e);let t=ia.r,n=ia.g,r=ia.b;return e===hn?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(ea),this.setHSL(ea.h+e,ea.s+t,ea.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ea),e.getHSL(ta);let n=nr(ea.h,ta.h,t),r=nr(ea.s,ta.s,t),i=nr(ea.l,ta.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[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 ia=new ra;ra.NAMES=$i;let pee=0;var aa=class extends Kn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:pee++}),this.uuid=Zn(),this.name=``,this.type=`Material`,this.blending=oe,this.side=ne,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=be,this.blendDst=xe,this.blendEquation=de,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ra(0,0,0),this.blendAlpha=0,this.depthFunc=Ae,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Nn,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=bn,this.stencilZFail=bn,this.stencilZPass=bn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let 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(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==oe&&(n.blending=this.blending),this.side!==ne&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==be&&(n.blendSrc=this.blendSrc),this.blendDst!==xe&&(n.blendDst=this.blendDst),this.blendEquation!==de&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ae&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Nn&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==bn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==bn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==bn&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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++}},oa=class extends aa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new ra(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 xi,this.combine=Fe,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 sa=mee();function mee(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function ca(e){Math.abs(e)>65504&&console.warn(`THREE.DataUtils.toHalfFloat(): Value out of range.`),e=Qn(e,-65504,65504),sa.floatView[0]=e;let t=sa.uint32View[0],n=t>>23&511;return sa.baseTable[n]+((t&8388607)>>sa.shiftTable[n])}function la(e){let t=e>>10;return sa.uint32View[0]=sa.mantissaTable[sa.offsetTable[t]+(e&1023)]+sa.exponentTable[t],sa.floatView[0]}const ua=new C,da=new lr;let hee=0;var fa=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:hee++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Hn,this.updateRanges=[],this.gpuType=pt,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)da.fromBufferAttribute(this,t),da.applyMatrix3(e),this.setXY(t,da.x,da.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ua.fromBufferAttribute(this,t),ua.applyMatrix3(e),this.setXYZ(t,ua.x,ua.y,ua.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ua.fromBufferAttribute(this,t),ua.applyMatrix4(e),this.setXYZ(t,ua.x,ua.y,ua.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ua.fromBufferAttribute(this,t),ua.applyNormalMatrix(e),this.setXYZ(t,ua.x,ua.y,ua.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ua.fromBufferAttribute(this,t),ua.transformDirection(e),this.setXYZ(t,ua.x,ua.y,ua.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=or(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=or(t,this.array)),t}setX(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=or(t,this.array)),t}setY(e,t){return this.normalized&&(t=sr(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=or(t,this.array)),t}setZ(e,t){return this.normalized&&(t=sr(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=or(t,this.array)),t}setW(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==Hn&&(e.usage=this.usage),e}},pa=class extends fa{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ma=class extends fa{constructor(e,t,n){super(new Uint32Array(e),t,n)}},ha=class extends fa{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=la(this.array[e*this.itemSize]);return this.normalized&&(t=or(t,this.array)),t}setX(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize]=ca(t),this}getY(e){let t=la(this.array[e*this.itemSize+1]);return this.normalized&&(t=or(t,this.array)),t}setY(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize+1]=ca(t),this}getZ(e){let t=la(this.array[e*this.itemSize+2]);return this.normalized&&(t=or(t,this.array)),t}setZ(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize+2]=ca(t),this}getW(e){let t=la(this.array[e*this.itemSize+3]);return this.normalized&&(t=or(t,this.array)),t}setW(e,t){return this.normalized&&(t=sr(t,this.array)),this.array[e*this.itemSize+3]=ca(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array)),this.array[e+0]=ca(t),this.array[e+1]=ca(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array)),this.array[e+0]=ca(t),this.array[e+1]=ca(n),this.array[e+2]=ca(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array)),this.array[e+0]=ca(t),this.array[e+1]=ca(n),this.array[e+2]=ca(r),this.array[e+3]=ca(i),this}},ga=class extends fa{constructor(e,t,n){super(new Float32Array(e),t,n)}};let _a=0;const va=new di,ya=new Ri,ba=new C,xa=new Rr,Sa=new Rr,Ca=new C;var wa=class e extends Kn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:_a++}),this.uuid=Zn(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=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(hr(e)?ma:pa)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new pr().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let 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 va.makeRotationFromQuaternion(e),this.applyMatrix4(va),this}rotateX(e){return va.makeRotationX(e),this.applyMatrix4(va),this}rotateY(e){return va.makeRotationY(e),this.applyMatrix4(va),this}rotateZ(e){return va.makeRotationZ(e),this.applyMatrix4(va),this}translate(e,t,n){return va.makeTranslation(e,t,n),this.applyMatrix4(va),this}scale(e,t,n){return va.makeScale(e,t,n),this.applyMatrix4(va),this}lookAt(e){return ya.lookAt(e),ya.updateMatrix(),this.applyMatrix4(ya.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ba).negate(),this.translate(ba.x,ba.y,ba.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new ga(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Rr);let 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 C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];xa.setFromBufferAttribute(n),this.morphTargetsRelative?(Ca.addVectors(this.boundingBox.min,xa.min),this.boundingBox.expandByPoint(Ca),Ca.addVectors(this.boundingBox.max,xa.max),this.boundingBox.expandByPoint(Ca)):(this.boundingBox.expandByPoint(xa.min),this.boundingBox.expandByPoint(xa.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 ni);let 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 C,1/0);return}if(e){let n=this.boundingSphere.center;if(xa.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Sa.setFromBufferAttribute(n),this.morphTargetsRelative?(Ca.addVectors(xa.min,Sa.min),xa.expandByPoint(Ca),Ca.addVectors(xa.max,Sa.max),xa.expandByPoint(Ca)):(xa.expandByPoint(Sa.min),xa.expandByPoint(Sa.max))}xa.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Ca.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Ca));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Ca.fromBufferAttribute(a,t),o&&(ba.fromBufferAttribute(e,t),Ca.add(ba)),r=Math.max(r,n.distanceToSquared(Ca))}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(){let 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}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new fa(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new C,s[e]=new C;let c=new C,l=new C,u=new C,d=new lr,f=new lr,p=new lr,m=new C,h=new C;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new C,y=new C,b=new C,x=new C;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new fa(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new C,i=new C,a=new C,o=new C,s=new C,c=new C,l=new C,u=new C;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ca.fromBufferAttribute(e,t),Ca.normalize(),e.setXYZ(t,Ca.x,Ca.y,Ca.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new fa(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const Ta=new di,Ea=new ui,Da=new ni,Oa=new C,ka=new C,Aa=new C,ja=new C,Ma=new C,Na=new C,Pa=new C,Fa=new C;var Ia=class extends Ri{constructor(e=new wa,t=new oa){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Na.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Ma.fromBufferAttribute(s,e),a?Na.addScaledVector(Ma,r):Na.addScaledVector(Ma.sub(t),r))}t.add(Na)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Da.copy(n.boundingSphere),Da.applyMatrix4(i),Ea.copy(e.ray).recast(e.near),!(Da.containsPoint(Ea.origin)===!1&&(Ea.intersectSphere(Da,Oa)===null||Ea.origin.distanceToSquared(Oa)>(e.far-e.near)**2))&&(Ta.copy(i).invert(),Ea.copy(e.ray).applyMatrix4(Ta),!(n.boundingBox!==null&&Ea.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ea)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ra(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ra(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ra(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ra(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function La(e,t,n,r,i,a,o,s){let c;if(c=t.side===re?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===ne,s),c===null)return null;Fa.copy(s),Fa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Fa);return l<n.near||l>n.far?null:{distance:l,point:Fa.clone(),object:e}}function Ra(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,ka),e.getVertexPosition(c,Aa),e.getVertexPosition(l,ja);let u=La(e,t,n,r,ka,Aa,ja,Pa);if(u){let e=new C;Qi.getBarycoord(Pa,ka,Aa,ja,e),i&&(u.uv=Qi.getInterpolatedAttribute(i,s,c,l,e,new lr)),a&&(u.uv1=Qi.getInterpolatedAttribute(a,s,c,l,e,new lr)),o&&(u.normal=Qi.getInterpolatedAttribute(o,s,c,l,e,new C),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new C,materialIndex:0};Qi.getNormal(ka,Aa,ja,t.normal),u.face=t,u.barycoord=e}return u}var za=class e extends wa{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new ga(c,3)),this.setAttribute(`normal`,new ga(l,3)),this.setAttribute(`uv`,new ga(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new C;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function Ba(e){let t={};for(let n in e)for(let r in t[n]={},e[n]){let i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}return t}function Va(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}var Ha=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,Ua=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`,Wa=class extends aa{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ha,this.fragmentShader=Ua,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=Ba(e.uniforms),this.uniformsGroups=Va(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){let t=super.toJSON(e);for(let n in t.glslVersion=this.glslVersion,t.uniforms={},this.uniforms){let r=this.uniforms[n],i=r.value;i&&i.isTexture?t.uniforms[n]={type:`t`,value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:`c`,value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:`v2`,value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:`v3`,value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:`v4`,value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:`m3`,value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:`m4`,value:i.toArray()}:t.uniforms[n]={value:i}}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;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Ga=class extends Ri{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new di,this.projectionMatrix=new di,this.projectionMatrixInverse=new di,this.coordinateSystem=Wn}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 Ka=new C,qa=new lr,Ja=new lr;var Ya=class extends Ga{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,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){let t=.5*this.getFilmHeight()/e;this.fov=Xn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Yn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Xn*2*Math.atan(Math.tan(Yn*.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,n){Ka.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ka.x,Ka.y).multiplyScalar(-e/Ka.z),Ka.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ka.x,Ka.y).multiplyScalar(-e/Ka.z)}getViewSize(e,t){return this.getViewBounds(e,qa,Ja),t.subVectors(Ja,qa)}setViewOffset(e,t,n,r,i,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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Yn*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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 Xa=-90,Za=1;var Qa=class extends Ri{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Ya(Xa,Za,e,t);r.layers=this.layers,this.add(r);let i=new Ya(Xa,Za,e,t);i.layers=this.layers,this.add(i);let a=new Ya(Xa,Za,e,t);a.layers=this.layers,this.add(a);let o=new Ya(Xa,Za,e,t);o.layers=this.layers,this.add(o);let s=new Ya(Xa,Za,e,t);s.layers=this.layers,this.add(s);let c=new Ya(Xa,Za,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===Wn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.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),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===Gn)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.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),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,s),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},$a=class extends Nr{constructor(e=[],t=Ke,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},eo=class extends Ir{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new $a(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},r=new za(5,5,5),i=new Wa({name:`CubemapFromEquirect`,uniforms:Ba(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:re,blending:ae});i.uniforms.tEquirect.value=t;let a=new Ia(r,i),o=t.minFilter;t.minFilter===at&&(t.minFilter=rt);let s=new Qa(1,10,this);return s.update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},to=class extends Ri{constructor(){super(),this.isGroup=!0,this.type=`Group`}};const no={type:`move`};var ro=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new to,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 to,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new to,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),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){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}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,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position),s=.02,l=.005;c.inputState.pinching&&o>s+l?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=s-l&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),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(no)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new to;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},io=class extends Ri{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 xi,this.environmentIntensity=1,this.environmentRotation=new xi,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){let 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}},ao=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Hn,this.updateRanges=[],this.version=0,this.uuid=Zn()}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,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+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=Zn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=Zn()),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 oo=new C;var so=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)oo.fromBufferAttribute(this,t),oo.applyMatrix4(e),this.setXYZ(t,oo.x,oo.y,oo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)oo.fromBufferAttribute(this,t),oo.applyNormalMatrix(e),this.setXYZ(t,oo.x,oo.y,oo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)oo.fromBufferAttribute(this,t),oo.transformDirection(e),this.setXYZ(t,oo.x,oo.y,oo.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=or(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=sr(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=sr(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=sr(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=sr(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=or(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=or(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=or(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=or(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=sr(t,this.array),n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new fa(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.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.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,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}}},co=class extends aa{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new ra(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}},lo=class extends Nr{constructor(e=null,t=1,n=1,r,i,a,o,s,c=et,l=et,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},uo=class extends fa{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const fo=new C,po=new C,mo=new pr;var ho=class{constructor(e=new C(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=fo.subVectors(n,t).cross(po.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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){let n=e.delta(fo),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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){let n=t||mo.getNormalMatrix(e),r=this.coplanarPoint(fo).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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 go=new ni,_o=new C;var vo=class{constructor(e=new ho,t=new ho,n=new ho,r=new ho,i=new ho,a=new ho){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Wn){let n=this.planes,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=r[8],p=r[9],m=r[10],h=r[11],g=r[12],_=r[13],v=r[14],y=r[15];if(n[0].setComponents(s-i,d-c,h-f,y-g).normalize(),n[1].setComponents(s+i,d+c,h+f,y+g).normalize(),n[2].setComponents(s+a,d+l,h+p,y+_).normalize(),n[3].setComponents(s-a,d-l,h-p,y-_).normalize(),n[4].setComponents(s-o,d-u,h-m,y-v).normalize(),t===Wn)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===Gn)n[5].setComponents(o,u,m,v).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),go.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),go.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(go)}intersectsSprite(e){return go.center.set(0,0,0),go.radius=.7071067811865476,go.applyMatrix4(e.matrixWorld),this.intersectsSphere(go)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){let i=t[e].distanceToPoint(n);if(i<r)return!1}return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(_o.x=r.normal.x>0?e.max.x:e.min.x,_o.y=r.normal.y>0?e.max.y:e.min.y,_o.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(_o)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};const yo=new di,bo=new vo;var xo=class e{constructor(){this.coordinateSystem=Wn}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,this.coordinateSystem),bo.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,this.coordinateSystem),bo.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,this.coordinateSystem),bo.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,this.coordinateSystem),bo.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){let r=t.cameras[n];if(yo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),bo.setFromProjectionMatrix(yo,this.coordinateSystem),bo.containsPoint(e))return!0}return!1}clone(){return new e}},So=class extends aa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new ra(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}},Co=class extends aa{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new ra(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}},wo=class extends Nr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=et,this.minFilter=et,this.generateMipmaps=!1,this.needsUpdate=!0}},To=class extends Nr{constructor(e,t,n=ft,r,i,a,o=et,s=et,c,l=xt,u=1){if(l!==xt&&l!==St)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new kr(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Eo=class e extends wa{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new ga(u,3)),this.setAttribute(`normal`,new ga(d,3)),this.setAttribute(`uv`,new ga(f,2));function _(){let a=new C,_=new C,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new lr,m=new C,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r,n=t*s+o,i=Math.cos(n),c=Math.sin(n);m.x=v*c,m.y=h*y,m.z=v*i,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=i*.5+.5,a.y=c*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Do=class e extends wa{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new ga(p,3)),this.setAttribute(`normal`,new ga(m,3)),this.setAttribute(`uv`,new ga(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},Oo=class e extends wa{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new C,d=new C,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=0;f===0&&a===0?v=.5/t:f===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){let s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(r+s*i)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(s+v,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new ga(p,3)),this.setAttribute(`normal`,new ga(m,3)),this.setAttribute(`uv`,new ga(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},ko=class extends aa{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new ra(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}},Ao=class extends aa{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new ra(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 ra(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(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 xi,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}},jo=class extends Ao{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 lr(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,`reflectivity`,{get:function(){return Qn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ra(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 ra(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ra(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}},Mo=class extends aa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new ra(16777215),this.specular=new ra(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ra(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=Fe,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}},No=class extends aa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new ra(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ra(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(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}},Po=class extends aa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(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}},Fo=class extends aa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new ra(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ra(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=Fe,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}},Io=class extends aa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new ra(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new lr(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}},Lo=class extends So{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 Ro(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function zo(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Bo=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},Vo=class extends Bo{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ln,endingEnd:ln}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case un:i=e,o=2*t-n;break;case dn:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case un:a=e,s=2*n-t;break;case dn:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},Ho=class extends Bo{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},Uo=class extends Bo{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Wo=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=Ro(t,this.TimeBufferType),this.values=Ro(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ro(e.times,Array),values:Ro(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Uo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ho(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Vo(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case on:t=this.InterpolantFactoryMethodDiscrete;break;case sn:t=this.InterpolantFactoryMethodLinear;break;case cn:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`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 Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return on;case this.InterpolantFactoryMethodLinear:return sn;case this.InterpolantFactoryMethodSmooth:return cn}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&zo(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===cn,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Wo.prototype.ValueTypeName=``,Wo.prototype.TimeBufferType=Float32Array,Wo.prototype.ValueBufferType=Float32Array,Wo.prototype.DefaultInterpolation=sn;var Go=class extends Wo{constructor(e,t,n){super(e,t,n)}};Go.prototype.ValueTypeName=`bool`,Go.prototype.ValueBufferType=Array,Go.prototype.DefaultInterpolation=on,Go.prototype.InterpolantFactoryMethodLinear=void 0,Go.prototype.InterpolantFactoryMethodSmooth=void 0;var Ko=class extends Wo{constructor(e,t,n,r){super(e,t,n,r)}};Ko.prototype.ValueTypeName=`color`;var qo=class extends Wo{constructor(e,t,n,r){super(e,t,n,r)}};qo.prototype.ValueTypeName=`number`;var Jo=class extends Bo{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)ur.slerpFlat(i,0,a,c-o,a,c,s);return i}},Yo=class extends Wo{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Jo(this.times,this.values,this.getValueSize(),e)}};Yo.prototype.ValueTypeName=`quaternion`,Yo.prototype.InterpolantFactoryMethodSmooth=void 0;var Xo=class extends Wo{constructor(e,t,n){super(e,t,n)}};Xo.prototype.ValueTypeName=`string`,Xo.prototype.ValueBufferType=Array,Xo.prototype.DefaultInterpolation=on,Xo.prototype.InterpolantFactoryMethodLinear=void 0,Xo.prototype.InterpolantFactoryMethodSmooth=void 0;var Zo=class extends Wo{constructor(e,t,n,r){super(e,t,n,r)}};Zo.prototype.ValueTypeName=`vector`;var Qo=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const $o=new Qo;var es=class{constructor(e){this.manager=e===void 0?$o:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}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}};es.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var ts=class extends Ri{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new ra(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){let 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}},ns=class extends ts{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ra(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}};const rs=new di,os=new C,ss=new C;var cs=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new lr(512,512),this.mapType=st,this.map=null,this.mapPass=null,this.matrix=new di,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new vo,this._frameExtents=new lr(1,1),this._viewportCount=1,this._viewports=[new Pr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;os.setFromMatrixPosition(e.matrixWorld),t.position.copy(os),ss.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ss),t.updateMatrixWorld(),rs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(rs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(rs)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let 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}},ls=class extends cs{constructor(){super(new Ya(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Xn*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,i=e.distance||t.far;(n!==t.fov||r!==t.aspect||i!==t.far)&&(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},us=class extends ts{constructor(e,t,n=0,r=Math.PI/3,i=0,a=2){super(e,t),this.isSpotLight=!0,this.type=`SpotLight`,this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.target=new Ri,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new ls}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 ds=new di,fs=new C,ps=new C;var ms=class extends cs{constructor(){super(new Ya(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new lr(4,2),this._viewportCount=6,this._viewports=[new Pr(2,1,1,1),new Pr(0,1,1,1),new Pr(3,1,1,1),new Pr(1,1,1,1),new Pr(3,0,1,1),new Pr(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),fs.setFromMatrixPosition(e.matrixWorld),n.position.copy(fs),ps.copy(n.position),ps.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ps),n.updateMatrixWorld(),r.makeTranslation(-fs.x,-fs.y,-fs.z),ds.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ds)}},hs=class extends ts{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type=`PointLight`,this.distance=n,this.decay=r,this.shadow=new ms}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}},gs=class extends Ga{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,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,n,r,i,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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},_s=class extends cs{constructor(){super(new gs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},vs=class extends ts{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.target=new Ri,this.shadow=new _s}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},ys=class extends ts{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},bs=class extends ts{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type=`RectAreaLight`,this.width=n,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){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},xs=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new C)}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){let n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*i)),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],1.092548*(n*i)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,i=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*i),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],2*.429043*n*i),t.addScaledVector(a[8],.429043*(n*n-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 n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],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){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}},Ss=class extends ts{constructor(e=new xs,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){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Cs=class extends Ya{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};const ws=`\\[\\]\\.:\\/`,Ts=RegExp(`[`+ws+`]`,`g`),Es=`[^`+ws+`]`,Ds=`[^`+ws.replace(`\\.`,``)+`]`,Os=/((?:WC+[\/:])*)/.source.replace(`WC`,Es),ks=/(WCOD+)?/.source.replace(`WCOD`,Ds),As=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,Es),js=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,Es),Ms=RegExp(`^`+Os+ks+As+js+`$`),Ns=[`material`,`materials`,`bones`,`map`];var Ps=class{constructor(e,t,n){let r=n||Fs.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Fs=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(Ts,``)}static parseTrackName(e){let t=Ms.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);Ns.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[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){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[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 t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Fs.Composite=Ps,Fs.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Fs.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Fs.prototype.GetterByBindingType=[Fs.prototype._getValue_direct,Fs.prototype._getValue_array,Fs.prototype._getValue_arrayElement,Fs.prototype._getValue_toArray],Fs.prototype.SetterByBindingTypeAndVersioning=[[Fs.prototype._setValue_direct,Fs.prototype._setValue_direct_setNeedsUpdate,Fs.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Fs.prototype._setValue_array,Fs.prototype._setValue_array_setNeedsUpdate,Fs.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Fs.prototype._setValue_arrayElement,Fs.prototype._setValue_arrayElement_setNeedsUpdate,Fs.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Fs.prototype._setValue_fromArray,Fs.prototype._setValue_fromArray_setNeedsUpdate,Fs.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const gee=new Float32Array(1);var Is=class extends ao{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Ls=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:v}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=v);const Rs=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var zs=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=Rs,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function Bs(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const Vs=e=>Bs(e),Hs=e=>Bs(e),Us=(...e)=>Bs(e);function Ws(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of Gs(e))n.push(Bs(r.slice(0,-4)),i.getCacheKey(t));return Bs(n)}function*Gs(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const Ks=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),qs=new WeakMap;function Js(e){return Ks.get(e)}function Ys(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function Xs(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function Zs(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function Qs(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function $s(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function ec(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new ra(...t):n===`vec2`?new lr(...t):n===`vec3`?new C(...t):n===`vec4`?new Pr(...t):n===`mat2`?new Ls(...t):n===`mat3`?new pr(...t):n===`mat4`?new di(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?rc(t[0]):null}function tc(e){let t=qs.get(e);return t===void 0&&(t={},qs.set(e,t)),t}function nc(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function rc(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const ic={VERTEX:`vertex`,FRAGMENT:`fragment`},ac={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},oc={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},sc={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},cc=[`fragment`,`vertex`],lc=[`setup`,`analyze`,`generate`],uc=[...cc,`compute`],dc=[`x`,`y`,`z`,`w`],fc={analyze:`setup`,generate:`analyze`};let pc=0;var mc=class extends Kn{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=ac.NONE,this.updateBeforeType=ac.NONE,this.updateAfterType=ac.NONE,this.uuid=cr.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:pc++})}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,ac.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ac.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ac.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(let{childNode:e}of Gs(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Us(Ws(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=fc[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Gs(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},hc=class extends mc{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){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},gc=class extends mc{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},_c=class extends mc{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},vc=class extends _c{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const yc=dc.join(``);var bc=class extends mc{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(let t of this.components)e=Math.max(dc.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){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===yc.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},xc=class extends _c{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=dc[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Sc=class extends _c{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=dc[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},Cc=class extends mc{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?$s(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=$s(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=nc(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?ec(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.`)}};const wc=/float|u?int/;var Tc=class extends Cc{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){let n=this.getNodeType(e);return wc.test(n)&&wc.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Ec=class extends mc{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let Dc=null;const Oc=new Map;function w(e,t){if(Oc.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);Oc.set(e,t)}const kc=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),Ac=e=>kc(e).split(``).sort().join(``),jc={setup(e,t){let n=t.shift();return e(rl(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(Dc.assign(n,...e),n);if(Oc.has(t)){let r=Oc.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&Oc.has(t.slice(0,t.length-6))){let r=Oc.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=kc(t),T(new bc(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Ac(t.slice(3).toLowerCase()),n=>T(new xc(e,t,T(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Ac(t.slice(4).toLowerCase()),()=>T(new Sc(T(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),T(new bc(e,t));else if(/^\d+$/.test(t)===!0)return T(new hc(n,new Tc(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>T(new Ec(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},Mc=new WeakMap,Nc=new WeakMap,Pc=function(e,t=null){let n=$s(e);if(n===`node`){let t=Mc.get(e);return t===void 0&&(t=new Proxy(e,jc),Mc.set(e,t),Mc.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return T(Zc(e,t));else if(n===`shader`)return O(e);return e},Fc=function(e,t=null){for(let n in e)e[n]=T(e[n],t);return e},Ic=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=T(e[r],t);return e},Lc=function(e,t=null,n=null,r=null){let i=e=>T(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...il(l(t)))):n===null?a=(...n)=>i(new e(t,...il(l(n)))):(n=T(n),a=(...r)=>i(new e(t,...il(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},Rc=function(e,...t){return T(new e(...il(t)))};var zc=class extends mc{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=Nc.get(e.constructor);r===void 0&&(r=new WeakMap,Nc.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=T(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=T(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=T(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},Bc=class extends mc{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return rl(e),T(new zc(this,e))}setup(){return this.call()}};const Vc=[!1,!0],Hc=[0,1,2,3],Uc=[-1,-2],Wc=[.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],Gc=new Map;for(let e of Vc)Gc.set(e,new Tc(e));const Kc=new Map;for(let e of Hc)Kc.set(e,new Tc(e,`uint`));const qc=new Map([...Kc].map(e=>new Tc(e.value,`int`)));for(let e of Uc)qc.set(e,new Tc(e,`int`));const Jc=new Map([...qc].map(e=>new Tc(e.value)));for(let e of Wc)Jc.set(e,new Tc(e));for(let e of Wc)Jc.set(-e,new Tc(-e));const Yc={bool:Gc,uint:Kc,ints:qc,float:Jc},Xc=new Map([...Gc,...Jc]),Zc=(e,t)=>Xc.has(e)?Xc.get(e):e.isNode===!0?e:new Tc(e,t),Qc=e=>{try{return e.getNodeType()}catch{return}},$c=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[ec(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return T(t.get(n[0]));if(n.length===1){let t=Zc(n[0],e);return Qc(t)===e?T(t):T(new gc(t,e))}let r=n.map(e=>Zc(e));return T(new vc(r,e))}},el=e=>typeof e==`object`&&e?e.value:e,tl=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function nl(e,t){return new Proxy(new Bc(e,t),jc)}const T=(e,t=null)=>Pc(e,t),rl=(e,t=null)=>new Fc(e,t),il=(e,t=null)=>new Ic(e,t),E=(...e)=>new Lc(...e),D=(...e)=>new Rc(...e);let _ee=0;const O=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new nl(e,n),i=(...e)=>{let t;rl(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ _ee++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},al=e=>{Dc=e},ol=()=>Dc,sl=(...e)=>Dc.If(...e),vee=(...e)=>Dc.Switch(...e);function cl(e){return Dc&&Dc.add(e),e}w(`toStack`,cl);const ll=new $c(`color`),k=new $c(`float`,Yc.float),A=new $c(`int`,Yc.ints),j=new $c(`uint`,Yc.uint),ul=new $c(`bool`,Yc.bool),M=new $c(`vec2`),dl=new $c(`ivec2`),fl=new $c(`uvec2`),pl=new $c(`bvec2`),N=new $c(`vec3`),ml=new $c(`ivec3`),hl=new $c(`uvec3`),gl=new $c(`bvec3`),_l=new $c(`vec4`),vl=new $c(`ivec4`),yl=new $c(`uvec4`),bl=new $c(`bvec4`),xl=new $c(`mat2`),Sl=new $c(`mat3`),Cl=new $c(`mat4`),yee=(e=``)=>T(new Tc(e,`string`)),bee=e=>T(new Tc(e,`ArrayBuffer`));w(`toColor`,ll),w(`toFloat`,k),w(`toInt`,A),w(`toUint`,j),w(`toBool`,ul),w(`toVec2`,M),w(`toIVec2`,dl),w(`toUVec2`,fl),w(`toBVec2`,pl),w(`toVec3`,N),w(`toIVec3`,ml),w(`toUVec3`,hl),w(`toBVec3`,gl),w(`toVec4`,_l),w(`toIVec4`,vl),w(`toUVec4`,yl),w(`toBVec4`,bl),w(`toMat2`,xl),w(`toMat3`,Sl),w(`toMat4`,Cl);const wl=E(hc).setParameterLength(2),Tl=(e,t)=>T(new gc(T(e),t)),xee=(e,t)=>T(new bc(T(e),t));w(`element`,wl),w(`convert`,Tl);const See=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),cl(e));w(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),cl(e)));const Cee=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),O(...e));var El=class extends mc{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const Dl=(e,t)=>T(new El(e,t)),Ol=(e,t)=>T(new El(e,t,!0)),kl=D(El,`vec4`,`DiffuseColor`),Al=D(El,`vec3`,`EmissiveColor`),jl=D(El,`float`,`Roughness`),Ml=D(El,`float`,`Metalness`),Nl=D(El,`float`,`Clearcoat`),Pl=D(El,`float`,`ClearcoatRoughness`),Fl=D(El,`vec3`,`Sheen`),Il=D(El,`float`,`SheenRoughness`),Ll=D(El,`float`,`Iridescence`),Rl=D(El,`float`,`IridescenceIOR`),zl=D(El,`float`,`IridescenceThickness`),Bl=D(El,`float`,`AlphaT`),Vl=D(El,`float`,`Anisotropy`),Hl=D(El,`vec3`,`AnisotropyT`),Ul=D(El,`vec3`,`AnisotropyB`),Wl=D(El,`color`,`SpecularColor`),Gl=D(El,`float`,`SpecularF90`),Kl=D(El,`float`,`Shininess`),ql=D(El,`vec4`,`Output`),Jl=D(El,`float`,`dashSize`),Yl=D(El,`float`,`gapSize`),Xl=D(El,`float`,`pointWidth`),Zl=D(El,`float`,`IOR`),Ql=D(El,`float`,`Transmission`),$l=D(El,`float`,`Thickness`),eu=D(El,`float`,`AttenuationDistance`),tu=D(El,`color`,`AttenuationColor`),nu=D(El,`float`,`Dispersion`);var ru=class extends mc{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const iu=e=>new ru(e),au=(e,t=0)=>new ru(e,!0,t),ou=au(`frame`),su=au(`render`),cu=iu(`object`);var lu=class extends Cc{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=cu}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){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const uu=(e,t)=>{let n=tl(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return T(new lu(r,n))};var du=class extends _c{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const fu=(...e)=>{let t;if(e.length===1){let n=e[0];t=new du(null,n.length,n)}else{let n=e[0],r=e[1];t=new du(n,r)}return T(t)};w(`toArray`,(e,t)=>fu(Array(t).fill(e)));var pu=class extends _c{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=dc.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const mu=E(pu).setParameterLength(2);w(`assign`,mu);var hu=class extends _c{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){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(k(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(k(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const gu=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?il(t):rl(t[0]),T(new hu(T(e),t)));w(`call`,gu);const _u={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var vu=class e extends _c{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(_u[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===Wn;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const yu=E(vu,`+`).setParameterLength(2,1/0).setName(`add`),bu=E(vu,`-`).setParameterLength(2,1/0).setName(`sub`),xu=E(vu,`*`).setParameterLength(2,1/0).setName(`mul`),Su=E(vu,`/`).setParameterLength(2,1/0).setName(`div`),Cu=E(vu,`%`).setParameterLength(2).setName(`mod`),wu=E(vu,`==`).setParameterLength(2).setName(`equal`),Tu=E(vu,`!=`).setParameterLength(2).setName(`notEqual`),Eu=E(vu,`<`).setParameterLength(2).setName(`lessThan`),Du=E(vu,`>`).setParameterLength(2).setName(`greaterThan`),Ou=E(vu,`<=`).setParameterLength(2).setName(`lessThanEqual`),ku=E(vu,`>=`).setParameterLength(2).setName(`greaterThanEqual`),Au=E(vu,`&&`).setParameterLength(2,1/0).setName(`and`),ju=E(vu,`||`).setParameterLength(2,1/0).setName(`or`),Mu=E(vu,`!`).setParameterLength(1).setName(`not`),Nu=E(vu,`^^`).setParameterLength(2).setName(`xor`),Pu=E(vu,`&`).setParameterLength(2).setName(`bitAnd`),Fu=E(vu,`~`).setParameterLength(2).setName(`bitNot`),Iu=E(vu,`|`).setParameterLength(2).setName(`bitOr`),Lu=E(vu,`^`).setParameterLength(2).setName(`bitXor`),Ru=E(vu,`<<`).setParameterLength(2).setName(`shiftLeft`),zu=E(vu,`>>`).setParameterLength(2).setName(`shiftRight`),Bu=O(([e])=>(e.addAssign(1),e)),Vu=O(([e])=>(e.subAssign(1),e)),Hu=O(([e])=>{let t=A(e).toConst();return e.addAssign(1),t}),Uu=O(([e])=>{let t=A(e).toConst();return e.subAssign(1),t});w(`add`,yu),w(`sub`,bu),w(`mul`,xu),w(`div`,Su),w(`mod`,Cu),w(`equal`,wu),w(`notEqual`,Tu),w(`lessThan`,Eu),w(`greaterThan`,Du),w(`lessThanEqual`,Ou),w(`greaterThanEqual`,ku),w(`and`,Au),w(`or`,ju),w(`not`,Mu),w(`xor`,Nu),w(`bitAnd`,Pu),w(`bitNot`,Fu),w(`bitOr`,Iu),w(`bitXor`,Lu),w(`shiftLeft`,Ru),w(`shiftRight`,zu),w(`incrementBefore`,Bu),w(`decrementBefore`,Vu),w(`increment`,Hu),w(`decrement`,Uu);const Wu=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),Cu(e,t)),Gu=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),Cu(A(e),A(t)));w(`remainder`,Wu),w(`modInt`,Gu);var P=class e extends _c{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=bu(1,n);else if(i===e.RECIPROCAL)a=Su(1,n);else if(i===e.DIFFERENCE)a=gd(bu(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=_l(N(i),0):e=_l(N(e),0);let o=xu(e,i).xyz;a=cd(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===Wn&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===Wn&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===Gn&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};P.ALL=`all`,P.ANY=`any`,P.RADIANS=`radians`,P.DEGREES=`degrees`,P.EXP=`exp`,P.EXP2=`exp2`,P.LOG=`log`,P.LOG2=`log2`,P.SQRT=`sqrt`,P.INVERSE_SQRT=`inversesqrt`,P.FLOOR=`floor`,P.CEIL=`ceil`,P.NORMALIZE=`normalize`,P.FRACT=`fract`,P.SIN=`sin`,P.COS=`cos`,P.TAN=`tan`,P.ASIN=`asin`,P.ACOS=`acos`,P.ATAN=`atan`,P.ABS=`abs`,P.SIGN=`sign`,P.LENGTH=`length`,P.NEGATE=`negate`,P.ONE_MINUS=`oneMinus`,P.DFDX=`dFdx`,P.DFDY=`dFdy`,P.ROUND=`round`,P.RECIPROCAL=`reciprocal`,P.TRUNC=`trunc`,P.FWIDTH=`fwidth`,P.TRANSPOSE=`transpose`,P.BITCAST=`bitcast`,P.EQUALS=`equals`,P.MIN=`min`,P.MAX=`max`,P.STEP=`step`,P.REFLECT=`reflect`,P.DISTANCE=`distance`,P.DIFFERENCE=`difference`,P.DOT=`dot`,P.CROSS=`cross`,P.POW=`pow`,P.TRANSFORM_DIRECTION=`transformDirection`,P.MIX=`mix`,P.CLAMP=`clamp`,P.REFRACT=`refract`,P.SMOOTHSTEP=`smoothstep`,P.FACEFORWARD=`faceforward`;const Ku=k(1e-6),qu=k(1e6),Ju=k(Math.PI),Yu=k(Math.PI*2),Xu=E(P,P.ALL).setParameterLength(1),Zu=E(P,P.ANY).setParameterLength(1),Qu=E(P,P.RADIANS).setParameterLength(1),$u=E(P,P.DEGREES).setParameterLength(1),ed=E(P,P.EXP).setParameterLength(1),td=E(P,P.EXP2).setParameterLength(1),nd=E(P,P.LOG).setParameterLength(1),rd=E(P,P.LOG2).setParameterLength(1),id=E(P,P.SQRT).setParameterLength(1),ad=E(P,P.INVERSE_SQRT).setParameterLength(1),od=E(P,P.FLOOR).setParameterLength(1),sd=E(P,P.CEIL).setParameterLength(1),cd=E(P,P.NORMALIZE).setParameterLength(1),ld=E(P,P.FRACT).setParameterLength(1),ud=E(P,P.SIN).setParameterLength(1),dd=E(P,P.COS).setParameterLength(1),fd=E(P,P.TAN).setParameterLength(1),pd=E(P,P.ASIN).setParameterLength(1),md=E(P,P.ACOS).setParameterLength(1),hd=E(P,P.ATAN).setParameterLength(1,2),gd=E(P,P.ABS).setParameterLength(1),_d=E(P,P.SIGN).setParameterLength(1),vd=E(P,P.LENGTH).setParameterLength(1),yd=E(P,P.NEGATE).setParameterLength(1),bd=E(P,P.ONE_MINUS).setParameterLength(1),xd=E(P,P.DFDX).setParameterLength(1),Sd=E(P,P.DFDY).setParameterLength(1),Cd=E(P,P.ROUND).setParameterLength(1),wd=E(P,P.RECIPROCAL).setParameterLength(1),Td=E(P,P.TRUNC).setParameterLength(1),Ed=E(P,P.FWIDTH).setParameterLength(1),Dd=E(P,P.TRANSPOSE).setParameterLength(1),Od=E(P,P.BITCAST).setParameterLength(2),kd=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),wu(e,t)),Ad=E(P,P.MIN).setParameterLength(2,1/0),jd=E(P,P.MAX).setParameterLength(2,1/0),Md=E(P,P.STEP).setParameterLength(2),Nd=E(P,P.REFLECT).setParameterLength(2),Pd=E(P,P.DISTANCE).setParameterLength(2),Fd=E(P,P.DIFFERENCE).setParameterLength(2),Id=E(P,P.DOT).setParameterLength(2),Ld=E(P,P.CROSS).setParameterLength(2),Rd=E(P,P.POW).setParameterLength(2),zd=E(P,P.POW,2).setParameterLength(1),Bd=E(P,P.POW,3).setParameterLength(1),Vd=E(P,P.POW,4).setParameterLength(1),Hd=E(P,P.TRANSFORM_DIRECTION).setParameterLength(2),Ud=e=>xu(_d(e),Rd(gd(e),1/3)),Wd=e=>Id(e,e),Gd=E(P,P.MIX).setParameterLength(3),Kd=(e,t=0,n=1)=>T(new P(P.CLAMP,T(e),T(t),T(n))),qd=e=>Kd(e),Jd=E(P,P.REFRACT).setParameterLength(3),Yd=E(P,P.SMOOTHSTEP).setParameterLength(3),Xd=E(P,P.FACEFORWARD).setParameterLength(3),Zd=O(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=Id(e.xy,M(t,n)),a=Cu(i,Ju);return ld(ud(a).mul(r))}),Qd=(e,t,n)=>Gd(t,n,e),$d=(e,t,n)=>Yd(t,n,e),ef=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),hd(e,t)),tf=Xd,nf=ad;w(`all`,Xu),w(`any`,Zu),w(`equals`,kd),w(`radians`,Qu),w(`degrees`,$u),w(`exp`,ed),w(`exp2`,td),w(`log`,nd),w(`log2`,rd),w(`sqrt`,id),w(`inverseSqrt`,ad),w(`floor`,od),w(`ceil`,sd),w(`normalize`,cd),w(`fract`,ld),w(`sin`,ud),w(`cos`,dd),w(`tan`,fd),w(`asin`,pd),w(`acos`,md),w(`atan`,hd),w(`abs`,gd),w(`sign`,_d),w(`length`,vd),w(`lengthSq`,Wd),w(`negate`,yd),w(`oneMinus`,bd),w(`dFdx`,xd),w(`dFdy`,Sd),w(`round`,Cd),w(`reciprocal`,wd),w(`trunc`,Td),w(`fwidth`,Ed),w(`atan2`,ef),w(`min`,Ad),w(`max`,jd),w(`step`,Md),w(`reflect`,Nd),w(`distance`,Pd),w(`dot`,Id),w(`cross`,Ld),w(`pow`,Rd),w(`pow2`,zd),w(`pow3`,Bd),w(`pow4`,Vd),w(`transformDirection`,Hd),w(`mix`,Qd),w(`clamp`,Kd),w(`refract`,Jd),w(`smoothstep`,$d),w(`faceForward`,Xd),w(`difference`,Fd),w(`saturate`,qd),w(`cbrt`,Ud),w(`transpose`,Dd),w(`rand`,Zd);var rf=class extends mc{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?Dl(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
41
+
42
+ `+e.tab+`}`),o!==null){e.addFlowCode(` else {
43
+
44
+ `).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
45
+
46
+ `+e.tab+`}
47
+
48
+ `)}else e.addFlowCode(`
49
+
50
+ `);return e.format(l,n,t)}};const af=E(rf).setParameterLength(2,3);w(`select`,af);const sf=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),af(...e));w(`cond`,sf);var cf=class extends mc{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){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const lf=E(cf).setParameterLength(1,2),uf=(e,t)=>lf(e,{label:t});w(`context`,lf),w(`label`,uf);var df=class extends mc{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const ff=E(df),pf=(e,t=null)=>ff(e,t).toStack(),mf=(e,t=null)=>ff(e,t,!0).toStack();w(`toVar`,pf),w(`toConst`,mf);const hf=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),ff(e));w(`temp`,hf);var gf=class extends mc{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(ic.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(ic.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,ic.VERTEX);e.flowNodeFromShaderStage(ic.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const _f=E(gf).setParameterLength(1,2),vf=e=>_f(e);w(`toVarying`,_f),w(`toVertexStage`,vf),w(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),_f(...e))),w(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),_f(...e)));const yf=O(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=Gd(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),bf=O(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=Gd(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),xf=`WorkingColorSpace`,Sf=`OutputColorSpace`;var Cf=class extends _c{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===xf?Cr.workingColorSpace:t===Sf?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return Cr.enabled===!1||n===r||!n||!r?i:(Cr.getTransfer(n)===vn&&(i=_l(yf(i.rgb),i.a)),Cr.getPrimaries(n)!==Cr.getPrimaries(r)&&(i=_l(Sl(Cr._getMatrix(new pr,n,r)).mul(i.rgb),i.a)),Cr.getTransfer(r)===vn&&(i=_l(bf(i.rgb),i.a)),i)}};const wf=(e,t)=>T(new Cf(T(e),xf,t)),Tf=(e,t)=>T(new Cf(T(e),t,xf)),Ef=(e,t,n)=>T(new Cf(T(e),t,n));w(`workingToColorSpace`,wf),w(`colorSpaceToWorking`,Tf);let Df=class extends hc{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var Of=class extends mc{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=ac.OBJECT}setGroup(e){return this.group=e,this}element(e){return T(new Df(this,T(e)))}setNodeType(e){let t=uu(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){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const kf=(e,t,n)=>T(new Of(e,t,n));var Af=class extends Of{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(su)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const jf=(e,t,n=null)=>T(new Af(e,t,n));var Mf=class extends _c{static get type(){return`ToneMappingNode`}constructor(e,t=Pf,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return Us(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Re)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=_l(i(t.rgb,this.exposureNode),t.a),r}};const Nf=(e,t,n)=>T(new Mf(e,T(t),T(n))),Pf=jf(`toneMappingExposure`,`float`);w(`toneMapping`,(e,t,n)=>Nf(t,n,e));var Ff=class extends Cc{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Hn,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;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new ao(n,i),s=new so(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=_f(this);i=n.build(e,t)}return i}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 If=(e,t=null,n=0,r=0)=>T(new Ff(e,t,n,r)),Lf=(e,t=null,n=0,r=0)=>If(e,t,n,r).setUsage(Un),Rf=(e,t=null,n=0,r=0)=>If(e,t,n,r).setInstanced(!0),zf=(e,t=null,n=0,r=0)=>Lf(e,t,n,r).setInstanced(!0);w(`toAttribute`,e=>If(e.value));var Bf=class extends mc{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=ac.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const Vf=(e,t,n)=>T(new Bf(T(e),t,n));w(`compute`,Vf);var Hf=class extends mc{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const Uf=(e,t)=>T(new Hf(T(e),t)),Wf=(e,t)=>e.context({namespace:t});w(`cache`,Uf);var Gf=class extends mc{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){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const Kf=E(Gf).setParameterLength(2);w(`bypass`,Kf);var qf=class extends mc{static get type(){return`RemapNode`}constructor(e,t,n,r=k(0),i=k(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const Jf=E(qf,null,null,{doClamp:!1}).setParameterLength(3,5),Yf=E(qf).setParameterLength(3,5);w(`remap`,Jf),w(`remapClamp`,Yf);var Xf=class extends mc{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const Zf=E(Xf).setParameterLength(1,2),Qf=e=>(e?af(e,Zf(`discard`)):Zf(`discard`)).toStack(),$f=()=>Zf(`return`).toStack();w(`discard`,Qf);var ep=class extends _c{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||Re,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||mn;return n!==Re&&(t=t.toneMapping(n)),r!==mn&&r!==Cr.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const tp=(e,t=null,n=null)=>T(new ep(T(e),t,n));w(`renderOutput`,tp);var np=class extends _c{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
51
+ `,a+=e.flow.code.replace(/^\t/gm,``)+`
52
+ `,a+=`/* ... */ `+n+` /* ... */
53
+ `,a+=`// #`+i+`#
54
+ `,t===null?console.log(a):t(e,a),n}};const rp=(e,t=null)=>T(new np(T(e),t));w(`debug`,rp);function ip(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var ap=class extends mc{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){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=_f(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}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 op=(e,t=null)=>T(new ap(e,t)),sp=(e=0)=>op(`uv`+(e>0?e:``),`vec2`);var cp=class extends mc{static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const lp=E(cp).setParameterLength(1,2);var up=class extends lu{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=ac.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const dp=E(up).setParameterLength(1),fp=new Nr;var pp=class extends lu{static get type(){return`TextureNode`}constructor(e=fp,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ac.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===ft?`uvec4`:this.value.type===dt?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return sp(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=uu(this.value.matrix)),this._matrixUniform.mul(N(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?ac.OBJECT:ac.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(A(lp(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,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,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=Tf(Zf(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=T(e),t.referenceNode=this.getSelf(),T(t)}blur(e){let t=this.clone();t.biasNode=T(e).mul(dp(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===et||n.magFilter===et)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),T(t)}level(e){let t=this.clone();return t.levelNode=T(e),t.referenceNode=this.getSelf(),T(t)}size(e){return lp(this,e)}bias(e){let t=this.clone();return t.biasNode=T(e),t.referenceNode=this.getSelf(),T(t)}compare(e){let t=this.clone();return t.compareNode=T(e),t.referenceNode=this.getSelf(),T(t)}grad(e,t){let n=this.clone();return n.gradNode=[T(e),T(t)],n.referenceNode=this.getSelf(),T(n)}depth(e){let t=this.clone();return t.depthNode=T(e),t.referenceNode=this.getSelf(),T(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(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const mp=E(pp).setParameterLength(1,4).setName(`texture`),hp=(e=fp,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=T(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=T(t)),n!==null&&(i.levelNode=T(n)),r!==null&&(i.biasNode=T(r))):i=mp(e,t,n,r),i},gp=(e=fp)=>hp(e),_p=(...e)=>hp(...e).setSampler(!1),vp=e=>(e.isNode===!0?e:hp(e)).convert(`sampler`),yp=e=>(e.isNode===!0?e:hp(e)).convert(`samplerComparison`);var bp=class extends lu{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const xp=(e,t,n)=>T(new bp(e,t,n));var Sp=class extends hc{static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},Cp=class extends bp{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?$s(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ac.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return T(new Sp(this,T(e)))}};const wp=(e,t)=>T(new Cp(e,t)),Tp=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),T(new Cp(e,t)));var Ep=class extends mc{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const Dp=E(Ep).setParameterLength(1),Op=uu(0,`uint`).label(`u_cameraIndex`).setGroup(au(`cameraIndex`)).toVarying(`v_cameraIndex`),kp=uu(`float`).label(`cameraNear`).setGroup(su).onRenderUpdate(({camera:e})=>e.near),Ap=uu(`float`).label(`cameraFar`).setGroup(su).onRenderUpdate(({camera:e})=>e.far),jp=O(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=wp(n).setGroup(su).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?Dp(`gl_ViewID_OVR`):Op).toVar(`cameraProjectionMatrix`)}else t=uu(`mat4`).label(`cameraProjectionMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Mp=O(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=wp(n).setGroup(su).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?Dp(`gl_ViewID_OVR`):Op).toVar(`cameraProjectionMatrixInverse`)}else t=uu(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(su).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Np=O(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=wp(n).setGroup(su).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?Dp(`gl_ViewID_OVR`):Op).toVar(`cameraViewMatrix`)}else t=uu(`mat4`).label(`cameraViewMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Pp=uu(`mat4`).label(`cameraWorldMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.matrixWorld),Fp=uu(`mat3`).label(`cameraNormalMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.normalMatrix),Ip=uu(new C).label(`cameraPosition`).setGroup(su).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),Lp=new ni;var Rp=class e extends mc{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ac.OBJECT,this.uniformNode=new lu(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new C,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new C,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new C,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new C,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Lp.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=Lp.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Rp.WORLD_MATRIX=`worldMatrix`,Rp.POSITION=`position`,Rp.SCALE=`scale`,Rp.VIEW_POSITION=`viewPosition`,Rp.DIRECTION=`direction`,Rp.RADIUS=`radius`;const zp=E(Rp,Rp.DIRECTION).setParameterLength(1),Bp=E(Rp,Rp.WORLD_MATRIX).setParameterLength(1),Vp=E(Rp,Rp.POSITION).setParameterLength(1),Hp=E(Rp,Rp.SCALE).setParameterLength(1),Up=E(Rp,Rp.VIEW_POSITION).setParameterLength(1),Wp=E(Rp,Rp.RADIUS).setParameterLength(1);var Gp=class extends Rp{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Kp=D(Gp,Gp.DIRECTION),qp=D(Gp,Gp.WORLD_MATRIX),Jp=D(Gp,Gp.POSITION),Yp=D(Gp,Gp.SCALE),Xp=D(Gp,Gp.VIEW_POSITION),Zp=D(Gp,Gp.RADIUS),Qp=uu(new pr).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),$p=uu(new di).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),em=O(e=>e.renderer.overrideNodes.modelViewMatrix||tm).once()().toVar(`modelViewMatrix`),tm=Np.mul(qp),nm=O(e=>(e.context.isHighPrecisionModelViewMatrix=!0,uu(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),rm=O(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return uu(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),im=op(`position`,`vec3`),am=im.toVarying(`positionLocal`),om=im.toVarying(`positionPrevious`),sm=O(e=>qp.mul(am).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),cm=O(e=>{let t=am.transformDirection(qp).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),lm=O(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),um=lm.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var dm=class extends mc{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===Wn&&n.side===re?`false`:e.getFrontFacing()}};const fm=D(dm),pm=k(fm).mul(2).sub(1),mm=op(`normal`,`vec3`),hm=O(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),N(0,1,0)):mm,`vec3`).once()().toVar(`normalLocal`),gm=lm.dFdx().cross(lm.dFdy()).normalize().toVar(`normalFlat`),_m=O(e=>{let t;return t=e.material.flatShading===!0?gm:_f(Cm(hm),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),vm=O(e=>{let t=_m.transformDirection(Np);return e.material.flatShading!==!0&&(t=_f(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),ym=O(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(pm)),t},`vec3`).once()().toVar(`transformedNormalView`),bm=ym.transformDirection(Np).toVar(`transformedNormalWorld`),xm=O(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(pm)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),Sm=O(([e,t=qp])=>{let n=Sl(t),r=e.div(N(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),Cm=O(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=Qp.mul(e);return Np.transformDirection(r)}),wm=new xi,Tm=new di,Em=uu(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Dm=uu(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Om=uu(new di).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(wm.copy(n),Tm.makeRotationFromEuler(wm)):Tm.identity(),Tm}),km=um.negate().reflect(ym),Am=um.negate().refract(ym,Em),jm=km.transformDirection(Np).toVar(`reflectVector`),Mm=Am.transformDirection(Np).toVar(`reflectVector`),Nm=new $a;var Pm=class extends pp{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===Ke?jm:e.mapping===qe?Mm:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),N(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===Gn||!n.isRenderTargetTexture)&&(t=N(t.x.negate(),t.yz)),Om.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const Fm=E(Pm).setParameterLength(1,4).setName(`cubeTexture`),Im=(e=Nm,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=T(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=T(t)),n!==null&&(i.levelNode=T(n)),r!==null&&(i.biasNode=T(r))):i=Fm(e,t,n,r),i},Lm=(e=Nm)=>Fm(e);var Rm=class extends hc{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},zm=class extends mc{static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=ac.OBJECT}element(e){return T(new Rm(this,T(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?wp(null,e):e===`texture`?hp(null):e===`cubeTexture`?Im(null):uu(null,e):xp(null,e,this.count),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){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const Bm=(e,t,n)=>T(new zm(e,t,n)),Vm=(e,t,n,r)=>T(new zm(e,t,r,n));var Hm=class extends zm{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const Um=(e,t,n=null)=>T(new Hm(e,t,n)),Wm=O(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),op(`tangent`,`vec4`)))(),Gm=Wm.xyz.toVar(`tangentLocal`),Km=em.mul(_l(Gm,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),qm=Km.transformDirection(Np).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),Jm=Km.toVar(`transformedTangentView`),Ym=Jm.transformDirection(Np).normalize().toVar(`transformedTangentWorld`),Xm=O(([e,t],n)=>{let r=e.mul(Wm.w).xyz;return n.material.flatShading!==!0&&(r=_f(r,t)),r}).once(),Zm=Xm(mm.cross(Wm),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),Qm=Xm(hm.cross(Gm),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),$m=Xm(_m.cross(Km),`v_bitangentView`).normalize().toVar(`bitangentView`),eh=Xm(vm.cross(qm),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),th=Xm(ym.cross(Jm),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),nh=th.transformDirection(Np).normalize().toVar(`transformedBitangentWorld`),rh=Sl(Km,$m,_m),ih=um.mul(rh),ah=(e,t)=>e.sub(ih.mul(t)),oh=(()=>{let e=Ul.cross(um);return e=e.cross(Ul).normalize(),e=Gd(e,ym,Vl.mul(jl.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),sh=O(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=pm.mul(m.inverseSqrt());return yu(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var ch=class extends _c{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=fn}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=N(r.xy.mul(n),r.z));let i=null;if(t===pn)i=Cm(r);else if(t===fn){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?rh.mul(r).normalize():sh({eye_pos:lm,surf_norm:_m,mapN:r,uv:sp()})}return i}};const lh=E(ch).setParameterLength(1,2),uh=O(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||sp()),forceUVContext:!0}),r=k(n(e=>e));return M(k(n(e=>e.add(e.dFdx()))).sub(r),k(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),dh=O(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(pm),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var fh=class extends _c{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=uh({textureNode:this.textureNode,bumpScale:e});return dh({surf_pos:lm,surf_norm:_m,dHdxy:t})}};const ph=E(fh).setParameterLength(1,2),mh=new Map;var F=class e extends mc{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=mh.get(e);return n===void 0&&(n=Um(e,t),mh.set(e,n)),n}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(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?N():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:k(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=lh(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?ph(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):_m;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?lh(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):_m;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=xl(Qh.x,Qh.y,Qh.y.negate(),Qh.x);i=t.mul(e.rg.mul(2).sub(M(1)).normalize().mul(e.b))}else i=Qh;else if(r===e.IRIDESCENCE_THICKNESS){let e=Bm(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=Bm(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):k(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};F.ALPHA_TEST=`alphaTest`,F.COLOR=`color`,F.OPACITY=`opacity`,F.SHININESS=`shininess`,F.SPECULAR=`specular`,F.SPECULAR_STRENGTH=`specularStrength`,F.SPECULAR_INTENSITY=`specularIntensity`,F.SPECULAR_COLOR=`specularColor`,F.REFLECTIVITY=`reflectivity`,F.ROUGHNESS=`roughness`,F.METALNESS=`metalness`,F.NORMAL=`normal`,F.CLEARCOAT=`clearcoat`,F.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,F.CLEARCOAT_NORMAL=`clearcoatNormal`,F.EMISSIVE=`emissive`,F.ROTATION=`rotation`,F.SHEEN=`sheen`,F.SHEEN_ROUGHNESS=`sheenRoughness`,F.ANISOTROPY=`anisotropy`,F.IRIDESCENCE=`iridescence`,F.IRIDESCENCE_IOR=`iridescenceIOR`,F.IRIDESCENCE_THICKNESS=`iridescenceThickness`,F.IOR=`ior`,F.TRANSMISSION=`transmission`,F.THICKNESS=`thickness`,F.ATTENUATION_DISTANCE=`attenuationDistance`,F.ATTENUATION_COLOR=`attenuationColor`,F.LINE_SCALE=`scale`,F.LINE_DASH_SIZE=`dashSize`,F.LINE_GAP_SIZE=`gapSize`,F.LINE_WIDTH=`linewidth`,F.LINE_DASH_OFFSET=`dashOffset`,F.POINT_SIZE=`size`,F.DISPERSION=`dispersion`,F.LIGHT_MAP=`light`,F.AO=`ao`;const hh=D(F,F.ALPHA_TEST),gh=D(F,F.COLOR),_h=D(F,F.SHININESS),vh=D(F,F.EMISSIVE),yh=D(F,F.OPACITY),bh=D(F,F.SPECULAR),xh=D(F,F.SPECULAR_INTENSITY),Sh=D(F,F.SPECULAR_COLOR),Ch=D(F,F.SPECULAR_STRENGTH),wh=D(F,F.REFLECTIVITY),Th=D(F,F.ROUGHNESS),Eh=D(F,F.METALNESS),Dh=D(F,F.NORMAL),Oh=D(F,F.CLEARCOAT),kh=D(F,F.CLEARCOAT_ROUGHNESS),Ah=D(F,F.CLEARCOAT_NORMAL),jh=D(F,F.ROTATION),Mh=D(F,F.SHEEN),Nh=D(F,F.SHEEN_ROUGHNESS),Ph=D(F,F.ANISOTROPY),Fh=D(F,F.IRIDESCENCE),Ih=D(F,F.IRIDESCENCE_IOR),Lh=D(F,F.IRIDESCENCE_THICKNESS),Rh=D(F,F.TRANSMISSION),zh=D(F,F.THICKNESS),Bh=D(F,F.IOR),Vh=D(F,F.ATTENUATION_DISTANCE),Hh=D(F,F.ATTENUATION_COLOR),Uh=D(F,F.LINE_SCALE),Wh=D(F,F.LINE_DASH_SIZE),Gh=D(F,F.LINE_GAP_SIZE),Kh=D(F,F.LINE_WIDTH),qh=D(F,F.LINE_DASH_OFFSET),Jh=D(F,F.POINT_SIZE),Yh=D(F,F.DISPERSION),Xh=D(F,F.LIGHT_MAP),Zh=D(F,F.AO),Qh=uu(new lr).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),$h=O(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var eg=class e extends mc{static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=_f(this);a=e.build(t,n)}return a}};eg.VERTEX=`vertex`,eg.INSTANCE=`instance`,eg.SUBGROUP=`subgroup`,eg.INVOCATION_LOCAL=`invocationLocal`,eg.INVOCATION_SUBGROUP=`invocationSubgroup`,eg.DRAW=`draw`;const tg=D(eg,eg.VERTEX),ng=D(eg,eg.INSTANCE),rg=D(eg,eg.SUBGROUP),ig=D(eg,eg.INVOCATION_SUBGROUP),ag=D(eg,eg.INVOCATION_LOCAL),og=D(eg,eg.DRAW);var sg=class extends mc{static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ac.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=xp(n.array,`mat4`,Math.max(t,1)).element(ng);else{let e=new Is(n.array,16,1);this.buffer=e;let t=n.usage===Un?zf:Rf,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=Cl(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new uo(r.array,3),t=r.usage===Un?zf:Rf;this.bufferColor=e,a=N(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(am).xyz;if(am.assign(o),e.hasGeometryAttribute(`normal`)){let e=Sm(hm,i);hm.assign(e)}this.instanceColorNode!==null&&Ol(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Un&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Un&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const cg=E(sg).setParameterLength(2,3);var lg=class extends sg{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const ug=E(lg).setParameterLength(1);var dg=class extends mc{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=ng:this.batchingIdNode=og);let t=O(([e])=>{let t=A(lp(_p(this.batchMesh._indirectTexture),0).x),n=A(e).mod(t),r=A(e).div(t);return _p(this.batchMesh._indirectTexture,dl(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(A(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=A(lp(_p(r),0).x),a=k(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=Cl(_p(r,dl(o,s)),_p(r,dl(o.add(1),s)),_p(r,dl(o.add(2),s)),_p(r,dl(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=O(([e])=>{let t=A(lp(_p(l),0).x),n=e,r=n.mod(t),i=n.div(t);return _p(l,dl(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);Ol(`vec3`,`vBatchColor`).assign(t)}let u=Sl(c);am.assign(c.mul(am));let d=hm.div(N(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;hm.assign(f),e.hasGeometryAttribute(`tangent`)&&Gm.mulAssign(u)}};const fg=E(dg).setParameterLength(1);var pg=class extends hc{static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const mg=E(pg).setParameterLength(2);var hg=class extends bp{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=Js(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=sc.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return mg(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(sc.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=If(this.value),this._varying=_f(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const gg=(e,t=null,n=0)=>T(new hg(e,t,n)),_g=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),gg(e,t,n).setPBO(!0)),vg=new WeakMap;var yg=class extends mc{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=ac.OBJECT,this.skinIndexNode=op(`skinIndex`,`uvec4`),this.skinWeightNode=op(`skinWeight`,`vec4`),this.bindMatrixNode=Bm(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=Bm(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=Vm(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=am,this.toPositionNode=am,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=yu(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=hm){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=yu(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Vm(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,om)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||tc(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&om.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();hm.assign(t),e.hasGeometryAttribute(`tangent`)&&Gm.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;vg.get(t)!==e.frameId&&(vg.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const bg=e=>T(new yg(e)),xg=(e,t=null)=>{let n=new yg(e);return n.positionNode=gg(new uo(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(ng).toVar(),n.skinIndexNode=gg(new uo(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(ng).toVar(),n.skinWeightNode=gg(new uo(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(ng).toVar(),n.bindMatrixNode=uu(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=uu(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=xp(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,T(n)};var Sg=class extends mc{static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=Zf(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=O(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
55
+ `:``)+e.tab+f+` {
56
+
57
+ `).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
58
+ `+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
59
+
60
+ `).removeFlowTab();return e.addFlowTab(),a}};const Cg=(...e)=>T(new Sg(il(e,`int`))).toStack(),wg=()=>Zf(`continue`).toStack(),Tg=()=>Zf(`break`).toStack(),Eg=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),Cg(...e)),Dg=new WeakMap,Og=new Pr,kg=O(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=A(tg).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=_p(e,dl(c,s)).depth(i).xyz;return l.mul(t)});function Ag(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=Dg.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new Lr(p,u,d,a);m.type=pt,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(Og.fromBufferAttribute(a,e),p[f+i+0]=Og.x,p[f+i+1]=Og.y,p[f+i+2]=Og.z,p[f+i+3]=0),n===!0&&(Og.fromBufferAttribute(o,e),p[f+i+4]=Og.x,p[f+i+5]=Og.y,p[f+i+6]=Og.z,p[f+i+7]=0),r===!0&&(Og.fromBufferAttribute(l,e),p[f+i+8]=Og.x,p[f+i+9]=Og.y,p[f+i+10]=Og.z,p[f+i+11]=l.itemSize===4?Og.w:1)}}o={count:a,texture:m,stride:l,size:new lr(u,d)},Dg.set(e,o);function g(){m.dispose(),Dg.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var jg=class extends mc{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=uu(1),this.updateType=ac.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=Ag(t);n===!0&&am.mulAssign(this.morphBaseInfluence),r===!0&&hm.mulAssign(this.morphBaseInfluence);let l=A(c.width);Cg(a,({i:e})=>{let t=k(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(_p(this.mesh.morphTexture,dl(A(e).add(1),A(ng))).r):t.assign(Bm(`morphTargetInfluences`,`float`).element(e).toVar()),sl(t.notEqual(0),()=>{n===!0&&am.addAssign(kg({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:A(0)})),r===!0&&hm.addAssign(kg({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:A(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const Mg=E(jg).setParameterLength(1);var Ng=class extends mc{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Pg=class extends Ng{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Fg=class extends cf{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=N().toVar(`directDiffuse`),r=N().toVar(`directSpecular`),i=N().toVar(`indirectDiffuse`),a=N().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:N().toVar(`radiance`),irradiance:N().toVar(`irradiance`),iblIrradiance:N().toVar(`iblIrradiance`),ambientOcclusion:k(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const Ig=E(Fg);var Lg=class extends Ng{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let Rg,zg;var Bg=class e extends mc{static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=ac.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=ac.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(zg),zg.multiplyScalar(t.getPixelRatio())):zg.copy(n.viewport):n===null?t.getDrawingBufferSize(Rg):(Rg.width=n.width,Rg.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?uu(Rg||=new lr):t===e.VIEWPORT?uu(zg||=new Pr):M(Ug.div(Hg)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(Hg).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};Bg.COORDINATE=`coordinate`,Bg.VIEWPORT=`viewport`,Bg.SIZE=`size`,Bg.UV=`uv`;const Vg=D(Bg,Bg.UV),Hg=D(Bg,Bg.SIZE),Ug=D(Bg,Bg.COORDINATE),Wg=D(Bg,Bg.VIEWPORT),Gg=Wg.zw,Kg=Ug.sub(Wg.xy),qg=Kg.div(Gg),Jg=O(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),Hg),`vec2`).once()(),Yg=O(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),Vg),`vec2`).once()(),Xg=O(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),Vg.flipY()),`vec2`).once()(),Zg=new lr;var Qg=class extends pp{static get type(){return`ViewportTextureNode`}constructor(e=Vg,t=null,n=null){n===null&&(n=new wo,n.minFilter=at),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=ac.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(Zg);let n=this.value;(n.image.width!==Zg.width||n.image.height!==Zg.height)&&(n.image.width=Zg.width,n.image.height=Zg.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const $g=E(Qg).setParameterLength(0,3),e_=E(Qg,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let t_=null;var n_=class extends Qg{static get type(){return`ViewportDepthTextureNode`}constructor(e=Vg,t=null){t_===null&&(t_=new To),super(e,t,t_)}};const r_=E(n_).setParameterLength(0,2);var i_=class e extends mc{static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=d_().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?s_(lm.z,kp,Ap):a_(lm.z,kp,Ap);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=c_(r,kp,Ap);i=a_(e,kp,Ap)}else i=r;else i=a_(lm.z,kp,Ap);return i}};i_.DEPTH_BASE=`depthBase`,i_.DEPTH=`depth`,i_.LINEAR_DEPTH=`linearDepth`;const a_=(e,t,n)=>e.add(t).div(t.sub(n)),o_=(e,t,n)=>t.sub(n).mul(e).sub(t),s_=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),c_=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),l_=(e,t,n)=>{t=t.max(1e-6).toVar();let r=rd(e.negate().div(t)),i=rd(n.div(t));return r.div(i)},u_=(e,t,n)=>{let r=e.mul(nd(n.div(t)));return k(Math.E).pow(r).mul(t).negate()},d_=E(i_,i_.DEPTH_BASE),f_=D(i_,i_.DEPTH),p_=E(i_,i_.LINEAR_DEPTH).setParameterLength(0,1),m_=p_(r_());f_.assign=e=>d_(e);var h_=class e extends mc{static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return O(()=>{let n=k().toVar(`distanceToPlane`),r=k().toVar(`distanceToGradient`),i=k(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=wp(t);Cg(a,({i:t})=>{let a=e.element(t);n.assign(lm.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Yd(r.negate(),r,n))})}let o=e.length;if(o>0){let t=wp(e),a=k(1).toVar(`intersectionClipOpacity`);Cg(o,({i:e})=>{let i=t.element(e);n.assign(lm.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Yd(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}kl.a.mulAssign(i),kl.a.equal(0).discard()})()}setupDefault(e,t){return O(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=wp(t);Cg(n,({i:t})=>{let n=e.element(t);lm.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=wp(e),n=ul(!0).toVar(`clipped`);Cg(r,({i:e})=>{let r=t.element(e);n.assign(lm.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),O(()=>{let r=wp(e),i=Dp(t.getClipDistance());Cg(n,({i:e})=>{let t=r.element(e),n=lm.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};h_.ALPHA_TO_COVERAGE=`alphaToCoverage`,h_.DEFAULT=`default`,h_.HARDWARE=`hardware`;const g_=()=>T(new h_),__=()=>T(new h_(h_.ALPHA_TO_COVERAGE)),v_=()=>T(new h_(h_.HARDWARE)),y_=.05,b_=O(([e])=>ld(xu(1e4,ud(xu(17,e.x).add(xu(.1,e.y)))).mul(yu(.1,gd(ud(xu(13,e.y).add(e.x))))))),x_=O(([e])=>b_(M(b_(e.xy),e.z))),S_=O(([e])=>{let t=jd(vd(xd(e.xyz)),vd(Sd(e.xyz))),n=k(1).div(k(y_).mul(t)).toVar(`pixScale`),r=M(td(od(rd(n))),td(sd(rd(n)))),i=M(x_(od(r.x.mul(e.xyz))),x_(od(r.y.mul(e.xyz)))),a=ld(rd(n)),o=yu(xu(a.oneMinus(),i.x),xu(a,i.y)),s=Ad(a,a.oneMinus()),c=N(o.mul(o).div(xu(2,s).mul(bu(1,s))),o.sub(xu(.5,s)).div(bu(1,s)),bu(1,bu(1,o).mul(bu(1,o)).div(xu(2,s).mul(bu(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return Kd(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var C_=class extends ap{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new Pr(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const w_=(e=0)=>T(new C_(e));var T_=class extends aa{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+Ws(this)}build(e){this.setup(e)}setupObserver(e){return new zs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=_l(r,kl.a).max(0);a=this.setupOutput(e,i),ql.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&ql.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=_l(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=__():e.stack.add(g_())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(v_()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?l_(lm.z,kp,Ap):a_(lm.z,kp,Ap))}r!==null&&f_.assign(r).toStack()}setupPositionView(){return em.mul(am).xyz}setupModelViewProjection(){return jp.mul(lm)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),$h}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&Mg(t).toStack(),t.isSkinnedMesh===!0&&bg(t).toStack(),this.displacementMap){let e=Um(`displacementMap`,`texture`),t=Um(`displacementScale`,`float`),n=Um(`displacementBias`,`float`);am.addAssign(hm.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&fg(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&ug(t).toStack(),this.positionNode!==null&&am.assign(Wf(this.positionNode,`POSITION`)),am}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&ul(this.maskNode).not().discard();let n=this.colorNode?_l(this.colorNode):gh;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(w_())),e.instanceColor){let e=Ol(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=Ol(`vec3`,`vBatchColor`);n=e.mul(n)}kl.assign(n);let r=this.opacityNode?k(this.opacityNode):yh;kl.a.assign(kl.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?hh:k(this.alphaTestNode),kl.a.lessThanEqual(i).discard()),this.alphaHash===!0&&kl.a.lessThan(S_(am)).discard();let a=this.transparent===!1&&this.blending===oe&&this.alphaToCoverage===!1;a?kl.a.assign(1):i===null&&kl.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?N(0):kl.rgb}setupNormal(){return this.normalNode?N(this.normalNode):Dh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Um(`envMap`,`cubeTexture`):Um(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Lg(Xh)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?Zh:this.aoNode;t.push(new Pg(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=Ig(o,t,n,r)}else n!==null&&(s=N(r===null?n:Gd(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Al.assign(N(i||vh)),s=s.add(Al)),s}setupFog(e,t){let n=e.fogNode;return n&&(ql.assign(t),t=_l(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=aa.prototype.toJSON.call(this,e),r=Gs(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}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.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};const E_=new So;var D_=class extends T_{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(E_),this.setValues(e)}};const O_=new Lo;var k_=class extends T_{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(O_),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?k(this.offsetNode):qh,t=this.dashScaleNode?k(this.dashScaleNode):Uh,n=this.dashSizeNode?k(this.dashSizeNode):Wh,r=this.gapSizeNode?k(this.gapSizeNode):Gh;Jl.assign(n),Yl.assign(r);let i=_f(op(`lineDistance`).mul(t)),a=e?i.add(e):i;a.mod(Jl.add(Yl)).greaterThan(Jl).discard()}};let A_=null;var j_=class extends Qg{static get type(){return`ViewportSharedTextureNode`}constructor(e=Vg,t=null){A_===null&&(A_=new wo),super(e,t,A_)}updateReference(){return this}};const M_=E(j_).setParameterLength(0,2),N_=e=>T(e).mul(.5).add(.5),P_=e=>T(e).mul(2).sub(1),F_=new Po;var I_=class extends T_{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(F_),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?k(this.opacityNode):yh;kl.assign(Tf(_l(N_(ym),e),hn))}},L_=class extends _c{static get type(){return`EquirectUVNode`}constructor(e=cm){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return M(t,n)}};const R_=E(L_).setParameterLength(0,1);var z_=class extends eo{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){let n=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;let i=new za(5,5,5),a=R_(cm),o=new T_;o.colorNode=hp(t,a,0),o.side=re,o.blending=ae;let s=new Ia(i,o),c=new io;c.add(s),t.minFilter===at&&(t.minFilter=rt);let l=new Qa(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,c),e.setMRT(u),t.minFilter=n,t.currentGenerateMipmaps=r,s.geometry.dispose(),s.material.dispose(),this}};const B_=new WeakMap;var V_=class extends _c{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Im(null);let t=new $a;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ac.RENDER}updateBefore(e){let{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:n[r.property];if(e&&e.isTexture){let n=e.mapping;if(n===Je||n===Ye){if(B_.has(e)){let t=B_.get(e);W_(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(H_(n)){let r=new z_(n.height);r.fromEquirectangularTexture(t,e),W_(r.texture,e.mapping),this._cubeTexture=r.texture,B_.set(e,r.texture),e.addEventListener(`dispose`,U_)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function H_(e){return e==null?!1:e.height>0}function U_(e){let t=e.target;t.removeEventListener(`dispose`,U_);let n=B_.get(t);n!==void 0&&(B_.delete(t),n.dispose())}function W_(e,t){t===Je?e.mapping=Ke:t===Ye&&(e.mapping=qe)}const G_=E(V_).setParameterLength(1);var K_=class extends Ng{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=G_(this.envNode)}},q_=class extends Ng{static get type(){return`BasicLightMapNode`}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=k(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}},J_=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},Y_=class extends J_{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(_l(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(_l(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(kl.rgb)}finish(e){let{material:t,context:n}=e,r=n.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case Fe:r.rgb.assign(Gd(r.rgb,r.rgb.mul(i.rgb),Ch.mul(wh)));break;case Ie:r.rgb.assign(Gd(r.rgb,i.rgb,Ch.mul(wh)));break;case Le:r.rgb.addAssign(i.rgb.mul(Ch.mul(wh)));break;default:console.warn(`THREE.BasicLightingModel: Unsupported .combine value:`,t.combine);break}}};const X_=new oa;var Z_=class extends T_{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(X_),this.setValues(e)}setupNormal(){return _m}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new K_(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new q_(Xh)),t}setupOutgoingLight(){return kl.rgb}setupLightingModel(){return new Y_}};const Q_=O(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),$_=O(e=>e.diffuseColor.mul(1/Math.PI)),ev=()=>k(.25),tv=O(({dotNH:e})=>Kl.mul(k(.5)).add(1).mul(k(1/Math.PI)).mul(e.pow(Kl))),nv=O(({lightDirection:e})=>{let t=e.add(um).normalize(),n=ym.dot(t).clamp(),r=um.dot(t).clamp(),i=Q_({f0:Wl,f90:1,dotVH:r}),a=ev(),o=tv({dotNH:n});return i.mul(a).mul(o)});var rv=class extends Y_{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ym.dot(e).clamp(),i=r.mul(t);n.directDiffuse.addAssign(i.mul($_({diffuseColor:kl.rgb}))),this.specular===!0&&n.directSpecular.addAssign(i.mul(nv({lightDirection:e})).mul(Ch))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul($_({diffuseColor:kl}))),r.indirectDiffuse.mulAssign(t)}};const iv=new Fo;var av=class extends T_{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(iv),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new K_(t):null}setupLightingModel(){return new rv(!1)}};const ov=new Mo;var sv=class extends T_{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(ov),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new K_(t):null}setupLightingModel(){return new rv}setupVariants(){let e=(this.shininessNode?k(this.shininessNode):_h).max(1e-4);Kl.assign(e);let t=this.specularNode||bh;Wl.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}};const cv=O(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return k(0);let t=_m.dFdx().abs().max(_m.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),lv=O(e=>{let{roughness:t}=e,n=cv(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),uv=O(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return Su(.5,i.add(a).max(Ku))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),dv=O(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(N(e.mul(n),t.mul(r),o).length()),l=o.mul(N(e.mul(i),t.mul(a),s).length()),u=Su(.5,c.add(l));return u.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`}]}),fv=O(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),pv=k(1/Math.PI),mv=O(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=N(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return pv.mul(a.mul(c.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`}]}),hv=O(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||ym,l=i.pow2(),u=t.add(um).normalize(),d=c.dot(t).clamp(),f=c.dot(um).clamp(),p=c.dot(u).clamp(),m=um.dot(u).clamp(),h=Q_({f0:n,f90:r,dotVH:m}),g,_;if(el(o)&&(h=Ll.mix(h,a)),el(s)){let e=Hl.dot(t),n=Hl.dot(um),r=Hl.dot(u),i=Ul.dot(t),a=Ul.dot(um),o=Ul.dot(u);g=dv({alphaT:Bl,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=mv({alphaT:Bl,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=uv({alpha:l,dotNL:d,dotNV:f}),_=fv({alpha:l,dotNH:p});return h.mul(g).mul(_)}),gv=O(({roughness:e,dotNV:t})=>{let n=_l(-1,-.0275,-.572,.022),r=_l(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=M(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),_v=O(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=gv({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),vv=O(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(N(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),yv=O(({roughness:e,dotNH:t})=>{let n=e.pow2(),r=k(1).div(n),i=t.pow2(),a=i.oneMinus().max(.0078125);return k(2).add(r).mul(a.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:`D_Charlie`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`dotNH`,type:`float`}]}),bv=O(({dotNV:e,dotNL:t})=>k(1).div(k(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:`V_Neubelt`,type:`float`,inputs:[{name:`dotNV`,type:`float`},{name:`dotNL`,type:`float`}]}),xv=O(({lightDirection:e})=>{let t=e.add(um).normalize(),n=ym.dot(e).clamp(),r=ym.dot(um).clamp(),i=ym.dot(t).clamp(),a=yv({roughness:Il,dotNH:i}),o=bv({dotNV:r,dotNL:n});return Fl.mul(a).mul(o)}),Sv=O(({N:e,V:t,roughness:n})=>{let r=64,i=(r-1)/r,a=.5/r,o=e.dot(t).saturate(),s=M(n,o.oneMinus().sqrt());return s.assign(s.mul(i).add(a)),s}).setLayout({name:`LTC_Uv`,type:`vec2`,inputs:[{name:`N`,type:`vec3`},{name:`V`,type:`vec3`},{name:`roughness`,type:`float`}]}),Cv=O(({f:e})=>{let t=e.length();return jd(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),wv=O(({v1:e,v2:t})=>{let n=e.dot(t),r=n.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=i.div(a),s=n.greaterThan(0).select(o,jd(n.mul(n).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(s)}).setLayout({name:`LTC_EdgeVectorFormFactor`,type:`vec3`,inputs:[{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`}]}),Tv=O(({N:e,V:t,P:n,mInv:r,p0:i,p1:a,p2:o,p3:s})=>{let c=a.sub(i).toVar(),l=s.sub(i).toVar(),u=c.cross(l),d=N().toVar();return sl(u.dot(n.sub(i)).greaterThanEqual(0),()=>{let c=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(c).negate(),u=r.mul(Sl(c,l,e).transpose()).toVar(),f=u.mul(i.sub(n)).normalize().toVar(),p=u.mul(a.sub(n)).normalize().toVar(),m=u.mul(o.sub(n)).normalize().toVar(),h=u.mul(s.sub(n)).normalize().toVar(),g=N(0).toVar();g.addAssign(wv({v1:f,v2:p})),g.addAssign(wv({v1:p,v2:m})),g.addAssign(wv({v1:m,v2:h})),g.addAssign(wv({v1:h,v2:f})),d.assign(N(Cv({f:g})))}),d}).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`}]}),Ev=1/6,Dv=e=>xu(Ev,xu(e,xu(e,e.negate().add(3)).sub(3)).add(1)),Ov=e=>xu(Ev,xu(e,xu(e,xu(3,e).sub(6))).add(4)),kv=e=>xu(Ev,xu(e,xu(e,xu(-3,e).add(3)).add(3)).add(1)),Av=e=>xu(Ev,Rd(e,3)),jv=e=>Dv(e).add(Ov(e)),Mv=e=>kv(e).add(Av(e)),Nv=e=>yu(-1,Ov(e).div(Dv(e).add(Ov(e)))),Pv=e=>yu(1,Av(e).div(kv(e).add(Av(e)))),Fv=(e,t,n)=>{let r=e.uvNode,i=xu(r,t.zw).add(.5),a=od(i),o=ld(i),s=jv(o.x),c=Mv(o.x),l=Nv(o.x),u=Pv(o.x),d=Nv(o.y),f=Pv(o.y),p=M(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=M(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=M(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=M(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=jv(o.y).mul(yu(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=Mv(o.y).mul(yu(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Iv=O(([e,t=k(3)])=>{let n=M(e.size(A(t))),r=M(e.size(A(t.add(1)))),i=Su(1,n),a=Su(1,r),o=Fv(e,_l(i,n),od(t)),s=Fv(e,_l(a,r),sd(t));return ld(t).mix(o,s)}),Lv=O(([e,t,n,r,i])=>{let a=N(Jd(t.negate(),cd(e),Su(1,r))),o=N(vd(i[0].xyz),vd(i[1].xyz),vd(i[2].xyz));return cd(a).mul(n.mul(o))}).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`}]}),Rv=O(([e,t])=>e.mul(Kd(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),zv=e_(),Bv=e_(),Vv=O(([e,t,n],{material:r})=>{let i=r.side===re?zv:Bv,a=i.sample(e),o=rd(Hg.x).mul(Rv(t,n));return Iv(a,o)}),Hv=O(([e,t,n])=>(sl(n.notEqual(0),()=>{let r=nd(t).negate().div(n),i=ed(r.negate().mul(e));return i}),N(1))).setLayout({name:`volumeAttenuation`,type:`vec3`,inputs:[{name:`transmissionDistance`,type:`float`},{name:`attenuationColor`,type:`vec3`},{name:`attenuationDistance`,type:`float`}]}),Uv=O(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=_l().toVar(),g=N().toVar();let i=u.sub(1).mul(m.mul(.025)),a=N(u.sub(i),u,u.add(i));Cg({start:0,end:3},({i})=>{let u=a.element(i),m=Lv(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(_l(_,1))),y=M(v.xy.div(v.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(M(y.x,y.y.oneMinus()));let b=Vv(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(Hv(vd(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Lv(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(_l(a,1))),_=M(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(M(_.x,_.y.oneMinus())),h=Vv(_,n,u),g=r.mul(Hv(vd(i),f,p))}let _=g.rgb.mul(h.rgb),v=e.dot(t).clamp(),y=N(_v({dotNV:v,specularColor:i,specularF90:a,roughness:n})),b=g.r.add(g.g,g.b).div(3);return _l(y.oneMinus().mul(_),h.a.oneMinus().mul(b).oneMinus())}),Wv=Sl(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Gv=e=>{let t=e.sqrt();return N(1).add(t).div(N(1).sub(t))},Kv=(e,t)=>e.sub(t).div(e.add(t)).pow2(),qv=(e,t)=>{let n=e.mul(2*Math.PI*1e-9),r=N(54856e-17,44201e-17,52481e-17),i=N(1681e3,1795300,2208400),a=N(43278e5,93046e5,66121e5),o=k(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(n.mul(2239900).add(t.x).cos()).mul(n.pow2().mul(-45282e5).exp()),s=r.mul(a.mul(2*Math.PI).sqrt()).mul(i.mul(n).add(t).cos()).mul(n.pow2().negate().mul(a).exp());s=N(s.x.add(o),s.y,s.z).div(1.0685e-7);let c=Wv.mul(s);return c},Jv=O(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=Gd(e,t,Yd(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()),s=o.oneMinus();sl(s.lessThan(0),()=>N(1));let c=s.sqrt(),l=Kv(a,e),u=Q_({f0:l,f90:1,dotVH:n}),d=u.oneMinus(),f=a.lessThan(e).select(Math.PI,0),p=k(Math.PI).sub(f),m=Gv(i.clamp(0,.9999)),h=Kv(m,a.toVec3()),g=Q_({f0:h,f90:1,dotVH:c}),_=N(m.x.lessThan(a).select(Math.PI,0),m.y.lessThan(a).select(Math.PI,0),m.z.lessThan(a).select(Math.PI,0)),v=a.mul(r,c,2),y=N(p).add(_),b=u.mul(g).clamp(1e-5,.9999),x=b.sqrt(),S=d.pow2().mul(g).div(N(1).sub(b)),ee=u.add(S),te=ee.toVar(),ne=S.sub(d).toVar();return Cg({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{ne.mulAssign(x);let t=qv(k(e).mul(v),k(e).mul(y)).mul(2);te.addAssign(ne.mul(t))}),te.max(N(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`}]}),Yv=O(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.pow2(),a=af(n.lessThan(.25),k(-339.2).mul(i).add(k(161.4).mul(n)).sub(25.9),k(-8.48).mul(i).add(k(14.3).mul(n)).sub(9.95)),o=af(n.lessThan(.25),k(44).mul(i).sub(k(23.7).mul(n)).add(3.26),k(1.97).mul(i).sub(k(3.27).mul(n)).add(.72)),s=af(n.lessThan(.25),0,k(.1).mul(n).sub(.025)).add(a.mul(r).add(o).exp());return s.mul(1/Math.PI).saturate()}),Xv=N(.04),Zv=k(1);var Qv=class extends J_{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=i,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=N().toVar(`clearcoatRadiance`),this.clearcoatSpecularDirect=N().toVar(`clearcoatSpecularDirect`),this.clearcoatSpecularIndirect=N().toVar(`clearcoatSpecularIndirect`)),this.sheen===!0&&(this.sheenSpecularDirect=N().toVar(`sheenSpecularDirect`),this.sheenSpecularIndirect=N().toVar(`sheenSpecularIndirect`)),this.iridescence===!0){let e=ym.dot(um).clamp();this.iridescenceFresnel=Jv({outsideIOR:k(1),eta2:Rl,cosTheta1:e,thinFilmThickness:zl,baseF0:Wl}),this.iridescenceF0=vv({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(this.transmission===!0){let t=sm,n=Ip.sub(sm).normalize(),r=bm,i=e.context;i.backdrop=Uv(r,n,jl,kl,Wl,Gl,t,qp,Np,jp,Zl,$l,tu,eu,this.dispersion?nu:null),i.backdropAlpha=Ql,kl.a.mulAssign(Gd(1,i.backdrop.a,Ql))}super.start(e)}computeMultiscattering(e,t,n){let r=ym.dot(um).clamp(),i=gv({roughness:jl,dotNV:r}),a=this.iridescenceF0?Ll.mix(Wl,this.iridescenceF0):Wl,o=a.mul(i.x).add(n.mul(i.y)),s=i.x.add(i.y),c=s.oneMinus(),l=Wl.add(Wl.oneMinus().mul(.047619)),u=o.mul(l).div(c.mul(l).oneMinus());e.addAssign(o),t.addAssign(u.mul(c))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=ym.dot(e).clamp(),i=r.mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(i.mul(xv({lightDirection:e}))),this.clearcoat===!0){let n=xm.dot(e).clamp(),r=n.mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(hv({lightDirection:e,f0:Xv,f90:Zv,roughness:Pl,normalView:xm})))}n.directDiffuse.addAssign(i.mul($_({diffuseColor:kl.rgb}))),n.directSpecular.addAssign(i.mul(hv({lightDirection:e,f0:Wl,f90:1,roughness:jl,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:i,ltc_1:a,ltc_2:o}){let s=t.add(n).sub(r),c=t.sub(n).sub(r),l=t.sub(n).add(r),u=t.add(n).add(r),d=ym,f=um,p=lm.toVar(),m=Sv({N:d,V:f,roughness:jl}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=Sl(N(h.x,0,h.y),N(0,1,0),N(h.z,0,h.w)).toVar(),v=Wl.mul(g.x).add(Wl.oneMinus().mul(g.y)).toVar();i.directSpecular.addAssign(e.mul(v).mul(Tv({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(kl).mul(Tv({N:d,V:f,P:p,mInv:Sl(1,0,0,0,1,0,0,0,1),p0:s,p1:c,p2:l,p3:u})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(t.mul($_({diffuseColor:kl})))}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Fl,Yv({normal:ym,viewDir:um,roughness:Il}))),this.clearcoat===!0){let e=xm.dot(um).clamp(),t=_v({dotNV:e,specularColor:Xv,specularF90:Zv,roughness:Pl});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}let i=N().toVar(`singleScattering`),a=N().toVar(`multiScattering`),o=n.mul(1/Math.PI);this.computeMultiscattering(i,a,Gl);let s=i.add(a),c=kl.mul(s.r.max(s.g).max(s.b).oneMinus());r.indirectSpecular.addAssign(t.mul(i)),r.indirectSpecular.addAssign(a.mul(o)),r.indirectDiffuse.addAssign(c.mul(o))}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:n}=e.context,r=ym.dot(um).clamp(),i=r.add(t),a=jl.mul(-16).oneMinus().negate().exp2(),o=t.sub(i.pow(a).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(o)}finish({context:e}){let{outgoingLight:t}=e;if(this.clearcoat===!0){let e=xm.dot(um).clamp(),n=Q_({dotVH:e,f0:Xv,f90:Zv}),r=t.mul(Nl.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Nl));t.assign(r)}if(this.sheen===!0){let e=Fl.r.max(Fl.g).max(Fl.b).mul(.157).oneMinus(),n=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}};const $v=k(1),ey=k(-2),ty=k(.8),ny=k(-1),ry=k(.4),iy=k(2),ay=k(.305),oy=k(3),sy=k(.21),cy=k(4),ly=k(4),uy=k(16),dy=O(([e])=>{let t=N(gd(e)).toVar(),n=k(-1).toVar();return sl(t.x.greaterThan(t.z),()=>{sl(t.x.greaterThan(t.y),()=>{n.assign(af(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(af(e.y.greaterThan(0),1,4))})}).Else(()=>{sl(t.z.greaterThan(t.y),()=>{n.assign(af(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(af(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),fy=O(([e,t])=>{let n=M().toVar();return sl(t.equal(0),()=>{n.assign(M(e.z,e.y).div(gd(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(M(e.x.negate(),e.z.negate()).div(gd(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(M(e.x.negate(),e.y).div(gd(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(M(e.z.negate(),e.y).div(gd(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(M(e.x.negate(),e.z).div(gd(e.y)))}).Else(()=>{n.assign(M(e.x,e.y).div(gd(e.z)))}),xu(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),py=O(([e])=>{let t=k(0).toVar();return sl(e.greaterThanEqual(ty),()=>{t.assign($v.sub(e).mul(ny.sub(ey)).div($v.sub(ty)).add(ey))}).ElseIf(e.greaterThanEqual(ry),()=>{t.assign(ty.sub(e).mul(iy.sub(ny)).div(ty.sub(ry)).add(ny))}).ElseIf(e.greaterThanEqual(ay),()=>{t.assign(ry.sub(e).mul(oy.sub(iy)).div(ry.sub(ay)).add(iy))}).ElseIf(e.greaterThanEqual(sy),()=>{t.assign(ay.sub(e).mul(cy.sub(oy)).div(ay.sub(sy)).add(oy))}).Else(()=>{t.assign(k(-2).mul(rd(xu(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),my=O(([e,t])=>{let n=e.toVar();n.assign(xu(2,n).sub(1));let r=N(n,1).toVar();return sl(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),hy=O(([e,t,n,r,i,a])=>{let o=k(n),s=N(t),c=Kd(py(o),ey,a),l=ld(c),u=od(c),d=N(gy(e,s,u,r,i,a)).toVar();return sl(l.notEqual(0),()=>{let t=N(gy(e,s,u.add(1),r,i,a)).toVar();d.assign(Gd(d,t,l))}),d}),gy=O(([e,t,n,r,i,a])=>{let o=k(n).toVar(),s=N(t),c=k(dy(s)).toVar(),l=k(jd(ly.sub(o),0)).toVar();o.assign(jd(o,ly));let u=k(td(o)).toVar(),d=M(fy(s,c).mul(u.sub(2)).add(1)).toVar();return sl(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(xu(3,uy))),d.y.addAssign(xu(4,td(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(M(),M())}),_y=O(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=dd(r),l=n.mul(c).add(i.cross(n).mul(ud(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return gy(e,l,t,a,o,s)}),vy=O(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=N(af(t,n,Ld(n,r))).toVar();sl(f.equal(N(0)),()=>{f.assign(N(r.z,0,r.x.negate()))}),f.assign(cd(f));let p=N().toVar();return p.addAssign(i.element(0).mul(_y({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),Cg({start:A(1),end:e},({i:e})=>{sl(e.greaterThanEqual(a),()=>{Tg()});let t=k(o.mul(k(e))).toVar();p.addAssign(i.element(e).mul(_y({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(_y({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),_l(p,1)}),yy=4,by=[.125,.215,.35,.446,.526,.582],xy=20,Sy=new gs(-1,1,1,-1,0,1),Cy=new Ya(90,1),wy=new ra;let Ty=null,Ey=0,Dy=0;const Oy=(1+Math.sqrt(5))/2,ky=1/Oy,Ay=[new C(-Oy,ky,0),new C(Oy,ky,0),new C(-ky,0,Oy),new C(ky,0,Oy),new C(0,Oy,-ky),new C(0,Oy,ky),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)],wee=new C,jy=new WeakMap,Tee=[3,1,5,0,4,2],My=my(sp(),op(`faceIndex`)).normalize(),Ny=N(My.x,My.y,My.z);var Eee=class{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}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=wee,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}Ty=this._renderer.getRenderTarget(),Ey=this._renderer.getActiveCubeFace(),Dy=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ly(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ry(),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())}_setSizeFromTexture(e){e.mapping===Ke||e.mapping===qe?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=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(Ty,Ey,Dy),e.scissorTest=!1,Fy(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Ty=this._renderer.getRenderTarget(),Ey=this._renderer.getActiveCubeFace(),Dy=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=Py(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Py(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=Dee(t)),this._blurMaterial=Oee(t,e.width,e.height)}}async _compileMaterial(e){let t=new Ia(this._lodPlanes[0],e);await this._renderer.compile(t,Sy)}_sceneToCubeUV(e,t,n,r,i){let a=Cy;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(wy),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new oa({name:`PMREM.Background`,side:re,depthWrite:!1,depthTest:!1});u=new Ia(new za,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(wy),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;Fy(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===Ke||e.mapping===qe;r?this._cubemapMaterial===null&&(this._cubemapMaterial=Ly(e)):this._equirectMaterial===null&&(this._equirectMaterial=Ry(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;Fy(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Sy)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=Ay[(r-t-1)%Ay.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=jy.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*xy-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):xy;h>xy&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${xy}`);let g=[],_=0;for(let e=0;e<xy;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-yy?r-v+yy:0),x=4*(this._cubeSize-y);Fy(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,Sy)}};function Dee(e){let t=[],n=[],r=[],i=[],a=e,o=e-yy+1+by.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-yy?c=by[s-e+yy-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=Tee[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new wa;x.setAttribute(`position`,new fa(v,h)),x.setAttribute(`uv`,new fa(y,g)),x.setAttribute(`faceIndex`,new fa(b,_)),t.push(x),i.push(new Ia(x,null)),a>yy&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function Py(e,t){let n={magFilter:rt,minFilter:rt,generateMipmaps:!1,type:mt,format:bt,colorSpace:gn},r=new Fr(e,t,n);return r.texture.mapping=Xe,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function Fy(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Iy(e){let t=new T_;return t.depthTest=!1,t.depthWrite=!1,t.blending=ae,t.name=`PMREM_${e}`,t}function Oee(e,t,n){let r=wp(Array(xy).fill(0)),i=uu(new C(0,1,0)),a=uu(0),o=k(xy),s=uu(0),c=uu(1),l=hp(null),u=uu(0),d=k(1/t),f=k(1/n),p=k(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:Ny,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=Iy(`blur`);return h.fragmentNode=vy({...m,latitudinal:s.equal(1)}),jy.set(h,m),h}function Ly(e){let t=Iy(`cubemap`);return t.fragmentNode=Im(e,Ny),t}function Ry(e){let t=Iy(`equirect`);return t.fragmentNode=hp(e,R_(Ny),0),t}const zy=new WeakMap;function kee(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function Aee(e,t,n){let r=jee(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(Nee(t))i=n.fromCubemap(e,i);else return null;else if(Pee(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function jee(e){let t=zy.get(e);return t===void 0&&(t=new WeakMap,zy.set(e,t)),t}var Mee=class extends _c{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new Nr;r.isRenderTargetTexture=!0,this._texture=hp(r),this._width=uu(0),this._height=uu(0),this._maxMip=uu(0),this.updateBeforeType=ac.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=kee(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:Aee(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new Eee(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=Om.mul(N(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),hy(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function Nee(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function Pee(e){return e==null?!1:e.height>0}const By=E(Mee).setParameterLength(1,3),Vy=new WeakMap;var Fee=class extends Ng{static get type(){return`EnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){let e=n.isTextureNode?n.value:t[n.property],r=Vy.get(e);r===void 0&&(r=By(e),Vy.set(e,r)),n=r}let r=t.useAnisotropy===!0||t.anisotropy>0,i=r?oh:ym,a=n.context(Hy(jl,i)).mul(Dm),o=n.context(Iee(bm)).mul(Math.PI).mul(Dm),s=Uf(a),c=Uf(o);e.context.radiance.addAssign(s),e.context.iblIrradiance.addAssign(c);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=n.context(Hy(Pl,xm)).mul(Dm),t=Uf(e);l.addAssign(t)}}};const Hy=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=um.negate().reflect(t),n=e.mul(e).mix(n,t).normalize(),n=n.transformDirection(Np)),n),getTextureLevel:()=>e}},Iee=e=>({getUV:()=>e,getTextureLevel:()=>k(1)}),Lee=new Ao;var Uy=class extends T_{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(Lee),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new Fee(t):null}setupLightingModel(){return new Qv}setupSpecular(){let e=Gd(N(.04),kl.rgb,Ml);Wl.assign(e),Gl.assign(1)}setupVariants(){let e=this.metalnessNode?k(this.metalnessNode):Eh;Ml.assign(e);let t=this.roughnessNode?k(this.roughnessNode):Th;t=lv({roughness:t}),jl.assign(t),this.setupSpecular(),kl.assign(_l(kl.rgb.mul(e.oneMinus()),kl.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}};const Ree=new jo;var zee=class extends Uy{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(Ree),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(){let e=this.iorNode?k(this.iorNode):Bh;Zl.assign(e),Wl.assign(Gd(Ad(zd(Zl.sub(1).div(Zl.add(1))).mul(Sh),N(1)).mul(xh),kl.rgb,Ml)),Gl.assign(Gd(xh,1,Ml))}setupLightingModel(){return new Qv(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?k(this.clearcoatNode):Oh,t=this.clearcoatRoughnessNode?k(this.clearcoatRoughnessNode):kh;Nl.assign(e),Pl.assign(lv({roughness:t}))}if(this.useSheen){let e=this.sheenNode?N(this.sheenNode):Mh,t=this.sheenRoughnessNode?k(this.sheenRoughnessNode):Nh;Fl.assign(e),Il.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?k(this.iridescenceNode):Fh,t=this.iridescenceIORNode?k(this.iridescenceIORNode):Ih,n=this.iridescenceThicknessNode?k(this.iridescenceThicknessNode):Lh;Ll.assign(e),Rl.assign(t),zl.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?M(this.anisotropyNode):Ph).toVar();Vl.assign(e.length()),sl(Vl.equal(0),()=>{e.assign(M(1,0))}).Else(()=>{e.divAssign(M(Vl)),Vl.assign(Vl.saturate())}),Bl.assign(Vl.pow2().mix(jl.pow2(),1)),Hl.assign(rh[0].mul(e.x).add(rh[1].mul(e.y))),Ul.assign(rh[1].mul(e.x).sub(rh[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?k(this.transmissionNode):Rh,t=this.thicknessNode?k(this.thicknessNode):zh,n=this.attenuationDistanceNode?k(this.attenuationDistanceNode):Vh,r=this.attenuationColorNode?N(this.attenuationColorNode):Hh;if(Ql.assign(e),$l.assign(t),eu.assign(n),tu.assign(r),this.useDispersion){let e=this.dispersionNode?k(this.dispersionNode):Yh;nu.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?N(this.clearcoatNormalNode):Ah}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)}};const Bee=O(({normal:e,lightDirection:t,builder:n})=>{let r=e.dot(t),i=M(r.mul(.5).add(.5),0);if(n.material.gradientMap){let e=Um(`gradientMap`,`texture`).context({getUV:()=>i});return N(e.r)}else{let e=i.fwidth().mul(.5);return Gd(N(.7),N(1),Yd(k(.7).sub(e.x),k(.7).add(e.x),i.x))}});var Vee=class extends J_{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=Bee({normal:mm,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul($_({diffuseColor:kl.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul($_({diffuseColor:kl}))),r.indirectDiffuse.mulAssign(t)}};const Hee=new No;var Uee=class extends T_{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Hee),this.setValues(e)}setupLightingModel(){return new Vee}},Wee=class extends _c{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=N(um.z,0,um.x.negate()).normalize(),t=um.cross(e);return M(e.dot(ym),t.dot(ym)).mul(.495).add(.5)}};const Wy=D(Wee),Gee=new Io;var Kee=class extends T_{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Gee),this.setValues(e)}setupVariants(e){let t=Wy,n;n=e.material.matcap?Um(`matcap`,`texture`).context({getUV:()=>t}):N(Gd(.2,.8,t.y)),kl.rgb.mulAssign(n.rgb)}},qee=class extends _c{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=xl(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=Cl(_l(1,0,0,0),_l(0,dd(e.x),ud(e.x).negate(),0),_l(0,ud(e.x),dd(e.x),0),_l(0,0,0,1)),i=Cl(_l(dd(e.y),0,ud(e.y),0),_l(0,1,0,0),_l(ud(e.y).negate(),0,dd(e.y),0),_l(0,0,0,1)),a=Cl(_l(dd(e.z),ud(e.z).negate(),0,0),_l(ud(e.z),dd(e.z),0,0),_l(0,0,1,0),_l(0,0,0,1));return r.mul(i).mul(a).mul(_l(n,1)).xyz}}};const Gy=E(qee).setParameterLength(2),Jee=new co;var Ky=class extends T_{static get type(){return`SpriteNodeMaterial`}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Jee),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:i,rotationNode:a,scaleNode:o}=this,s=em.mul(N(i||0)),c=M(qp[0].xyz.length(),qp[1].xyz.length());if(o!==null&&(c=c.mul(M(o))),r===!1)if(n.isPerspectiveCamera)c=c.mul(s.z.negate());else{let e=k(2).div(jp.element(1).element(1));c=c.mul(e.mul(2))}let l=im.xy;if(t.center&&t.center.isVector2===!0){let e=kf(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=k(a||jh),d=Gy(l,u);return _l(s.xy.add(d),s.zw)}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)}};const Yee=new Co;var Xee=class extends Ky{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return em.mul(N(e||am)).xyz}setupVertex(e){let t=super.setupVertex(e);if(e.material.isNodeMaterial!==!0)return t;let{rotationNode:n,scaleNode:r,sizeNode:i}=this,a=im.xy.toVar(),o=Wg.z.div(Wg.w);if(n&&n.isNode){let e=k(n);a.assign(Gy(a,e))}let s=i===null?Jh:M(i);return this.sizeAttenuation===!0&&(s=s.mul(s.div(lm.z.negate()))),r&&r.isNode&&(s=s.mul(M(r))),a.mulAssign(s.mul(2)),a.assign(a.div(Wg.z)),a.y.assign(a.y.mul(o)),a.assign(a.mul(t.w)),t.addAssign(_l(a,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},Zee=class extends J_{constructor(){super(),this.shadowNode=k(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){kl.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(kl.rgb)}};const Qee=new ko;var $ee=class extends T_{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Qee),this.setValues(e)}setupLightingModel(){return new Zee}};const ete=Dl(`vec3`),tte=Dl(`vec3`),nte=Dl(`vec3`);var rte=class{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self<`u`?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}},qy=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}};let ite=0;function ate(e){let t=Object.keys(e),n=Object.getPrototypeOf(e);for(;n;){let e=Object.getOwnPropertyDescriptors(n);for(let n in e)if(e[n]!==void 0){let r=e[n];r&&typeof r.get==`function`&&t.push(n)}n=Object.getPrototypeOf(n)}return t}var ote=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=ite++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=i,this.scene=a,this.camera=o,this.lightsNode=s,this.context=c,this.geometry=r.geometry,this.version=i.version,this.drawRange=null,this.attributes=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=l,this.clippingContextCacheKey=l===null?``:l.cacheKey,this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.material.addEventListener(`dispose`,this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||=this._nodes.getForRender(this)}getMonitor(){return this._monitor||=this.getNodeBuilderState().observer}getBindings(){return this._bindings||=this.getNodeBuilderState().createBindings()}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(let i of e){let e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(e===void 0)continue;n.push(e);let a=e.isInterleavedBufferAttribute?e.data:e;r.add(a)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:n,group:r,drawRange:i}=this,a=this.drawParams||={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0},o=this.getIndex(),s=o!==null,c=1;if(n.isInstancedBufferGeometry===!0?c=n.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let l=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(l=2);let u=i.start*l,d=(i.start+i.count)*l;r!==null&&(u=Math.max(u,r.start*l),d=Math.min(d,(r.start+r.count)*l));let f=n.attributes.position,p=1/0;s?p=o.count:f!=null&&(p=f.count),u=Math.max(u,0),d=Math.min(d,p);let m=d-u;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=u,a)}getGeometryCacheKey(){let{geometry:e}=this,t=``;for(let n of Object.keys(e.attributes).sort()){let r=e.attributes[n];t+=n+`,`,r.data&&(t+=r.data.stride+`,`),r.offset&&(t+=r.offset+`,`),r.itemSize&&(t+=r.itemSize+`,`),r.normalized&&(t+=`n,`)}for(let n of Object.keys(e.morphAttributes).sort()){let r=e.morphAttributes[n];t+=`morph-`+n+`,`;for(let e=0,n=r.length;e<n;e++){let n=r[e];t+=n.id+`,`}}return e.index&&(t+=`index,`),t}getMaterialCacheKey(){let{object:e,material:t}=this,n=t.customProgramCacheKey();for(let e of ate(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let r=t[e],i;if(r!==null){let e=typeof r;e===`number`?i=r===0?`0`:`1`:e===`object`?(i=`{`,r.isTexture&&(i+=r.mapping),i+=`}`):i=String(r)}else i=String(r);n+=i+`,`}return n+=this.clippingContextCacheKey+`,`,e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+`,`),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+`,`,e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+`,`)),e.count>1&&(n+=e.uuid+`,`),n+=e.receiveShadow+`,`,Vs(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Us(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Us(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}};const Jy=[];var ste=class{constructor(e,t,n,r,i,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=i,this.info=a,this.chainMaps={}}get(e,t,n,r,i,a,o,s){let c=this.getChainMap(s);Jy[0]=e,Jy[1]=t,Jy[2]=a,Jy[3]=i;let l=c.get(Jy);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(Jy,l)):(l.updateClipping(o),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey===l.getCacheKey()?l.version=t.version:(l.dispose(),l=this.get(e,t,n,r,i,a,o,s)))),Jy.length=0,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new qy)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new ote(e,t,n,r,i,a,o,s,c,l);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.delete(f),this.nodes.delete(f),d.delete(f.getChainArray())},f}},Yy=class{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}};const Xy={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Zy=16,cte=211,lte=212;var ute=class extends Yy{constructor(e){super(),this.backend=e}delete(e){let t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){let n=this.get(e);if(n.version===void 0)t===Xy.VERTEX?this.backend.createAttribute(e):t===Xy.INDEX?this.backend.createIndexAttribute(e):t===Xy.STORAGE?this.backend.createStorageAttribute(e):t===Xy.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version<t.version||t.usage===Un)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function Qy(e){return e.index===null?e.attributes.position.version:e.index.version}function $y(e){let t=[],n=e.index,r=e.attributes.position;if(n!==null){let e=n.array;for(let n=0,r=e.length;n<r;n+=3){let r=e[n+0],i=e[n+1],a=e[n+2];t.push(r,i,i,a,a,r)}}else{let e=r.array;for(let n=0,r=e.length/3-1;n<r;n+=3){let e=n+0,r=n+1,i=n+2;t.push(e,r,r,i,i,e)}}let i=new(hr(t)?ma:pa)(t,1);return i.version=Qy(e),i}var dte=class extends Yy{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){let t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let n=t.index,i=e.getAttributes();n!==null&&this.attributes.delete(n);for(let e of i)this.attributes.delete(e);let a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener(`dispose`,r)};t.addEventListener(`dispose`,r)}updateAttributes(e){let t=e.getAttributes();for(let e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Xy.STORAGE):this.updateAttribute(e,Xy.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,Xy.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Xy.INDIRECT)}updateAttribute(e,t){let n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){let{geometry:t,material:n}=e,r=t.index;if(n.wireframe===!0){let e=this.wireframes,n=e.get(t);n===void 0?(n=$y(t),e.set(t,n)):n.version!==Qy(t)&&(this.attributes.delete(n),n=$y(t),e.set(t,n)),r=n}return r}},fte=class{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error(`THREE.WebGPUInfo: Unknown object type.`)}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}},eb=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},pte=class extends eb{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},mte=class extends eb{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}};let hte=0;var tb=class{constructor(e,t,n,r=null,i=null){this.id=hte++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},gte=class extends Yy{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);let a=this.nodes.getForCompute(e),o=this.programs.compute.get(a.computeShader);o===void 0&&(i&&i.computeProgram.usedTimes===0&&this._releaseProgram(i.computeProgram),o=new tb(a.computeShader,`compute`,e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),n.createProgram(o));let s=this._getComputeCacheKey(e,o),c=this.caches.get(s);c===void 0&&(i&&i.usedTimes===0&&this._releasePipeline(i),c=this._getComputePipeline(e,o,s,t)),c.usedTimes++,o.usedTimes++,r.version=e.version,r.pipeline=c}return r.pipeline}getForRender(e,t=null){let{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){let i=r.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);let a=e.getNodeBuilderState(),o=e.material?e.material.name:``,s=this.programs.vertex.get(a.vertexShader);s===void 0&&(i&&i.vertexProgram.usedTimes===0&&this._releaseProgram(i.vertexProgram),s=new tb(a.vertexShader,`vertex`,o),this.programs.vertex.set(a.vertexShader,s),n.createProgram(s));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(i&&i.fragmentProgram.usedTimes===0&&this._releaseProgram(i.fragmentProgram),c=new tb(a.fragmentShader,`fragment`,o),this.programs.fragment.set(a.fragmentShader,c),n.createProgram(c));let l=this._getRenderCacheKey(e,s,c),u=this.caches.get(l);u===void 0?(i&&i.usedTimes===0&&this._releasePipeline(i),u=this._getRenderPipeline(e,s,c,l,t)):e.pipeline=u,u.usedTimes++,s.usedTimes++,c.usedTimes++,r.pipeline=u}return r.pipeline}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n||=this._getComputeCacheKey(e,t);let i=this.caches.get(n);return i===void 0&&(i=new mte(n,t),this.caches.set(n,i),this.backend.createComputePipeline(i,r)),i}_getRenderPipeline(e,t,n,r,i){r||=this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new pte(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,i)),a}_getComputeCacheKey(e,t){return e.id+`,`+t.id}_getRenderCacheKey(e,t,n){return t.id+`,`+n.id+`,`+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){let t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){let t=this.get(e);return t.pipeline===void 0||this.backend.needsRenderUpdate(e)}},_te=class extends Yy{constructor(e,t,n,r,i,a){super(),this.backend=e,this.textures=n,this.pipelines=i,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings();for(let e of t){let n=this.get(e);n.bindGroup===void 0&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let e of t){let n=this.get(e);n.bindGroup===void 0&&(this._init(e),this.backend.createBindings(e,t,0),n.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(let t of e)this._update(t,e)}_init(e){for(let t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){let e=t.attribute,n=e.isIndirectStorageBufferAttribute?Xy.INDIRECT:Xy.STORAGE;this.attributes.update(e,n)}}_update(e,t){let{backend:n}=this,r=!1,i=!0,a=0,o=0;for(let t of e.bindings){if(t.isNodeUniformsGroup){let e=this.nodes.updateGroup(t);if(e===!1)continue}if(t.isStorageBuffer){let e=t.attribute,n=e.isIndirectStorageBufferAttribute?Xy.INDIRECT:Xy.STORAGE;this.attributes.update(e,n)}if(t.isUniformBuffer){let e=t.update();e&&n.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){let e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(r=!0);let s=t.update(),c=t.texture;s&&this.textures.updateTexture(c);let l=n.get(c);if(l.externalTexture!==void 0||e.isDefaultTexture?i=!1:(a=a*10+c.id,o+=c.version),n.isWebGPUBackend===!0&&l.texture===void 0&&l.externalTexture===void 0&&(console.error(`Bindings._update: binding should be available:`,t,s,c,t.textureNode.value,r),this.textures.updateTexture(c),r=!0),c.isStorageTexture===!0){let e=this.get(c);t.store===!0?e.needsMipmap=!0:this.textures.needsMipmaps(c)&&e.needsMipmap===!0&&(this.backend.generateMipmaps(c),e.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,i?a:0,o)}};function vte(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:e.z-t.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function nb(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function rb(e){let t=e.transmission>0||e.transmissionNode;return t&&e.side===ie&&e.forceSinglePass===!1}var yte=class{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,i,a,o){let s=this.renderItems[this.renderItemsIndex];return s===void 0?(s={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:i,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=s):(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.groupOrder=r,s.renderOrder=e.renderOrder,s.z=i,s.group=a,s.clippingContext=o),this.renderItemsIndex++,s}push(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(rb(n)&&this.transparentDoublePass.push(s),this.transparent.push(s)):this.opaque.push(s)}unshift(e,t,n,r,i,a,o){let s=this.getNextRenderItem(e,t,n,r,i,a,o);n.transparent===!0||n.transmission>0?(rb(n)&&this.transparentDoublePass.unshift(s),this.transparent.unshift(s)):this.opaque.unshift(s)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||vte),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||nb),this.transparent.length>1&&this.transparent.sort(t||nb)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}}};const ib=[];var bte=class{constructor(e){this.lighting=e,this.lists=new qy}get(e,t){let n=this.lists;ib[0]=e,ib[1]=t;let r=n.get(ib);return r===void 0&&(r=new yte(this.lighting,e,t),n.set(ib,r)),ib.length=0,r}dispose(){this.lists=new qy}};let xte=0;var Ste=class{constructor(){this.id=xte++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Pr,this.scissor=!1,this.scissorValue=new Pr,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return ab(this)}};function ab(e){let{textures:t,activeCubeFace:n}=e,r=[n];for(let e of t)r.push(e.id);return Hs(r)}const ob=[],Cte=new io,wte=new Ga;var Tte=class{constructor(){this.chainMaps={}}get(e,t,n=null){ob[0]=e,ob[1]=t;let r;if(n===null)r=`default`;else{let e=n.texture.format,t=n.textures.length;r=`${t}:${e}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}let i=this._getChainMap(r),a=i.get(ob);return a===void 0&&(a=new Ste,i.set(ob,a)),ob.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(Cte,wte,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new qy)}dispose(){this.chainMaps={}}};const Ete=new C;var Dte=class extends Yy{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){let n=this.get(e),r=e.samples===0?1:e.samples,i=n.depthTextureMips||={},a=e.textures,o=this.getSize(a[0]),s=o.width>>t,c=o.height>>t,l=e.depthTexture||i[t],u=e.depthBuffer===!0||e.stencilBuffer===!0,d=!1;l===void 0&&u&&(l=new To,l.format=e.stencilBuffer?St:xt,l.type=e.stencilBuffer?_t:ft,l.image.width=s,l.image.height=c,l.image.depth=o.depth,l.isArrayTexture=e.multiview===!0&&o.depth>1,i[t]=l),(n.width!==o.width||o.height!==n.height)&&(d=!0,l&&(l.needsUpdate=!0,l.image.width=s,l.image.height=c,l.image.depth=l.isArrayTexture?l.image.depth:1)),n.width=o.width,n.height=o.height,n.textures=a,n.depthTexture=l||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(d=!0,l&&(l.needsUpdate=!0),n.sampleCount=r);let f={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,f)}l&&this.updateTexture(l,f)}if(n.initialized!==!0){n.initialized=!0;let t=()=>{e.removeEventListener(`dispose`,t);for(let e=0;e<a.length;e++)this._destroyTexture(a[e]);l&&this._destroyTexture(l),this.delete(e)};e.addEventListener(`dispose`,t)}}updateTexture(e,t={}){let n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;let r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(r&&n.initialized===!0&&(i.destroySampler(e),i.destroyTexture(e)),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=st}let{width:a,height:o,depth:s}=this.getSize(e);if(t.width=a,t.height=o,t.depth=s,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,r||e.isStorageTexture===!0)i.createSampler(e),i.createTexture(e,t),n.generation=e.version;else{let r=n.initialized!==!0;if(r&&i.createSampler(e),e.version>0){let r=e.image;if(r===void 0)console.warn(`THREE.Renderer: Texture marked for update but image is undefined.`);else if(r.complete===!1)console.warn(`THREE.Renderer: Texture marked for update but image is incomplete.`);else{if(e.images){let n=[];for(let t of e.images)n.push(t);t.images=n}else t.image=r;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(i.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&i.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version}if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;let t=()=>{e.removeEventListener(`dispose`,t),this._destroyTexture(e)};e.addEventListener(`dispose`,t)}n.version=e.version}getSize(e,t=Ete){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return r=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.isCompressedTexture===!0||e.generateMipmaps}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}},sb=class extends ra{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},cb=class extends El{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const Ote=(e,t)=>T(new cb(e,t));var kte=class extends mc{static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new nl(t);return this._currentCond=af(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new nl(t),r=af(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new nl(e),this}Switch(e){return this._expressionNode=T(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(T(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new nl(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=af(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=ol();al(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return al(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const lb=E(kte).setParameterLength(0,1);function Ate(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var jte=class extends mc{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=Ate(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=Zs(i)*t,o=Qs(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},Mte=class extends mc{static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const Nte=(e,t=null)=>{let n=new jte(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return T(new Mte(n,r))};return r.layout=n,r.isStruct=!0,r};var ub=class extends mc{static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const Pte=E(ub);function db(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Fte=class extends ub{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){let t={...this.outputNodes,...e.outputNodes};return fb(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=db(i,e);r[n]=_l(t[e])}return this.members=r,super.setup(e)}};const fb=E(Fte),Ite=O(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),pb=(e,t)=>Rd(xu(4,e.mul(bu(1,e))),t),Lte=(e,t)=>e.lessThan(.5)?pb(e.mul(2),t).div(2):bu(1,pb(xu(bu(1,e),2),t).div(2)),Rte=(e,t,n)=>Rd(Su(Rd(e,t),yu(Rd(e,t),Rd(bu(1,e),n))),1/t),zte=(e,t)=>ud(Ju.mul(t.mul(e).sub(1))).div(Ju.mul(t.mul(e).sub(1))),mb=O(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Bte=O(([e])=>N(mb(e.z.add(mb(e.y.mul(1)))),mb(e.z.add(mb(e.x.mul(1)))),mb(e.y.add(mb(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Vte=O(([e,t,n])=>{let r=N(e).toVar(),i=k(1.4).toVar(),a=k(0).toVar(),o=N(r).toVar();return Cg({start:k(0),end:k(3),type:`float`,condition:`<=`},()=>{let e=N(Bte(o.mul(2))).toVar();r.addAssign(e.add(n.mul(k(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=k(mb(r.z.add(mb(r.x.add(mb(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Hte=class extends mc{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){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const Ute=E(Hte),hb=e=>(...t)=>Ute(e,...t),gb=uu(0).setGroup(su).onRenderUpdate(e=>e.time),_b=uu(0).setGroup(su).onRenderUpdate(e=>e.deltaTime),Wte=uu(0,`uint`).setGroup(su).onRenderUpdate(e=>e.frameId),Gte=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),gb.mul(e)),Kte=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),gb.mul(e)),qte=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),_b.mul(e)),Jte=(e=gb)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Yte=(e=gb)=>e.fract().round(),Xte=(e=gb)=>e.add(.5).fract().mul(2).sub(1).abs(),Zte=(e=gb)=>e.fract(),Qte=O(([e,t,n=M(.5)])=>Gy(e.sub(n),t).add(n)),$te=O(([e,t,n=M(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),ene=O(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=qp:(r=qp.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Np.mul(r);return el(t)&&(i[0][0]=qp[0].length(),i[0][1]=0,i[0][2]=0),el(n)&&(i[1][0]=0,i[1][1]=qp[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,jp.mul(i).mul(am)}),tne=O(([e=null])=>{let t=p_(),n=p_(r_(e)).sub(t),r=n.lessThan(0).select(Vg,e);return r});var nne=class extends mc{static get type(){return`SpriteSheetUVNode`}constructor(e,t=sp(),n=k(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=M(o,s);return t.add(l).mul(c)}};const rne=E(nne).setParameterLength(3);var ine=class extends mc{static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=k(1),i=am,a=hm){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(N(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=hp(u,s).mul(o.x),m=hp(d,c).mul(o.y),h=hp(f,l).mul(o.z);return yu(p,m,h)}};const vb=E(ine).setParameterLength(1,6),ane=(...e)=>vb(...e),yb=new ho,bb=new C,xb=new C,Sb=new C,Cb=new di,wb=new C(0,0,-1),Tb=new Pr,Eb=new C,Db=new C,Ob=new Pr,kb=new lr,Ab=new Fr,one=Vg.flipX();Ab.depthTexture=new To(1,1);let jb=!1;var sne=class e extends pp{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||Ab.texture,one),this._reflectorBaseNode=e.reflector||new cne(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=T(new e({defaultTexture:Ab.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},cne=class extends mc{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new Ri,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?ac.RENDER:ac.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(kb),e.setSize(Math.round(kb.width*n),Math.round(kb.height*n))}setup(e){return this._updateResolution(Ab,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}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 Fr(0,0,{type:mt}),this.generateMipmaps===!0&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new To),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&jb)return!1;jb=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(kb),this._updateResolution(s,r),xb.setFromMatrixPosition(a.matrixWorld),Sb.setFromMatrixPosition(n.matrixWorld),Cb.extractRotation(a.matrixWorld),bb.set(0,0,1),bb.applyMatrix4(Cb),Eb.subVectors(xb,Sb);let c=Eb.dot(bb)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){jb=!1;return}l=!0}Eb.reflect(bb).negate(),Eb.add(xb),Cb.extractRotation(n.matrixWorld),wb.set(0,0,-1),wb.applyMatrix4(Cb),wb.add(Sb),Db.subVectors(xb,wb),Db.reflect(bb).negate(),Db.add(xb),o.coordinateSystem=n.coordinateSystem,o.position.copy(Eb),o.up.set(0,1,0),o.up.applyMatrix4(Cb),o.up.reflect(bb),o.lookAt(Db),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),yb.setFromNormalAndCoplanarPoint(bb,xb),yb.applyMatrix4(o.matrixWorldInverse),Tb.set(yb.normal.x,yb.normal.y,yb.normal.z,yb.constant);let u=o.projectionMatrix;Ob.x=(Math.sign(Tb.x)+u.elements[8])/u.elements[0],Ob.y=(Math.sign(Tb.y)+u.elements[9])/u.elements[5],Ob.z=-1,Ob.w=(1+u.elements[10])/u.elements[14],Tb.multiplyScalar(1/Tb.dot(Ob));let d=0;u.elements[2]=Tb.x,u.elements[6]=Tb.y,u.elements[10]=r.coordinateSystem===Gn?Tb.z-d:Tb.z+1-d,u.elements[14]=Tb.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,jb=!1,this.forceUpdate=!1}};const lne=e=>T(new sne(e)),Mb=new gs(-1,1,1,-1,0,1);var une=class extends wa{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new ga([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new ga(t,2))}};const dne=new une;var Nb=class extends Ia{constructor(e=null){super(dne,e),this.camera=Mb,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Mb)}render(e){e.render(this,Mb)}};const fne=new lr;var pne=class extends pp{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:mt}){let i=new Fr(t,n,r);super(i.texture,sp()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new Nb(new T_),this.updateBeforeType=ac.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;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,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();let t=e.getSize(fne);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new pp(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const Pb=(e,...t)=>T(new pne(T(e),...t)),mne=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():Pb(e,...t),Fb=O(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===Gn?(e=M(e.x,e.y.oneMinus()).mul(2).sub(1),i=_l(N(e,t),1)):i=_l(N(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=_l(n.mul(i));return a.xyz.div(a.w)}),hne=O(([e,t])=>{let n=t.mul(_l(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return M(r.x,r.y.oneMinus())}),gne=O(([e,t,n])=>{let r=lp(_p(t)),i=dl(e.mul(r)).toVar(),a=_p(t,i).toVar(),o=_p(t,i.sub(dl(2,0))).toVar(),s=_p(t,i.sub(dl(1,0))).toVar(),c=_p(t,i.add(dl(1,0))).toVar(),l=_p(t,i.add(dl(2,0))).toVar(),u=_p(t,i.add(dl(0,2))).toVar(),d=_p(t,i.add(dl(0,1))).toVar(),f=_p(t,i.sub(dl(0,1))).toVar(),p=_p(t,i.sub(dl(0,2))).toVar(),m=gd(bu(k(2).mul(s).sub(o),a)).toVar(),h=gd(bu(k(2).mul(c).sub(l),a)).toVar(),g=gd(bu(k(2).mul(d).sub(u),a)).toVar(),_=gd(bu(k(2).mul(f).sub(p),a)).toVar(),v=Fb(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(Fb(e.sub(M(k(1).div(r.x),0)),s,n)),v.negate().add(Fb(e.add(M(k(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(Fb(e.add(M(0,k(1).div(r.y))),d,n)),v.negate().add(Fb(e.sub(M(0,k(1).div(r.y))),f,n)));return cd(Ld(y,b))});var _ne=class extends uo{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},vne=class extends fa{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const yne=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=Ys(`float`)):(n=Xs(t),r=Ys(t));let i=new vne(e,n,r),a=gg(i,t,e);return a},bne=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=Ys(`float`)):(n=Xs(t),r=Ys(t));let i=new _ne(e,n,r),a=gg(i,t,e);return a};var xne=class extends mc{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const Sne=D(xne),Ib=new xi,Lb=new di;var Rb=class e extends mc{static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=Bm(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=Bm(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=uu(`mat4`).label(`backgroundRotation`).setGroup(su).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==Ge?(Ib.copy(r.backgroundRotation),Ib.x*=-1,Ib.y*=-1,Ib.z*=-1,Lb.makeRotationFromEuler(Ib)):Lb.identity(),Lb}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};Rb.BACKGROUND_BLURRINESS=`backgroundBlurriness`,Rb.BACKGROUND_INTENSITY=`backgroundIntensity`,Rb.BACKGROUND_ROTATION=`backgroundRotation`;const zb=D(Rb,Rb.BACKGROUND_BLURRINESS),Bb=D(Rb,Rb.BACKGROUND_INTENSITY),Vb=D(Rb,Rb.BACKGROUND_ROTATION);var Cne=class extends pp{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=sc.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(sc.READ_WRITE)}toReadOnly(){return this.setAccess(sc.READ_ONLY)}toWriteOnly(){return this.setAccess(sc.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const Hb=E(Cne).setParameterLength(1,3),Ub=(e,t,n)=>{let r=Hb(e,t,n);return n!==null&&r.toStack(),r},Wb=O(({texture:e,uv:t})=>{let n=1e-4,r=N().toVar();return sl(t.x.lessThan(n),()=>{r.assign(N(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(N(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(N(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(N(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(N(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(N(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(N(-.01,0,0))).r.sub(e.sample(t.add(N(n,0,0))).r),a=e.sample(t.add(N(0,-.01,0))).r.sub(e.sample(t.add(N(0,n,0))).r),o=e.sample(t.add(N(0,0,-.01))).r.sub(e.sample(t.add(N(0,0,n))).r);r.assign(N(i,a,o))}),r.normalize()});var Gb=class extends pp{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return N(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(A(lp(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return Wb({texture:this,uv:e})}};const Kb=E(Gb).setParameterLength(1,3);var qb=class extends zm{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const Jb=(e,t,n)=>T(new qb(e,t,n)),Yb=new WeakMap;var Xb=class extends _c{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=ac.OBJECT,this.updateAfterType=ac.OBJECT,this.previousModelWorldMatrix=uu(new di),this.previousProjectionMatrix=uu(new di).setGroup(su),this.previousCameraViewMatrix=uu(new di)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=Qb(n);this.previousModelWorldMatrix.value.copy(r);let i=Zb(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new di,i.previousCameraViewMatrix=new di,i.currentProjectionMatrix=new di,i.currentCameraViewMatrix=new di,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Qb(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?jp:uu(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(em).mul(am),r=this.previousProjectionMatrix.mul(t).mul(om),i=n.xy.div(n.w),a=r.xy.div(r.w),o=bu(i,a);return o}};function Zb(e){let t=Yb.get(e);return t===void 0&&(t={},Yb.set(e,t)),t}function Qb(e,t=0){let n=Zb(e),r=n[t];return r===void 0&&(n[t]=r=new di,n[t].copy(e.matrixWorld)),r}const $b=D(Xb),ex=O(([e,t])=>Ad(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),tx=O(([e,t])=>Ad(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),nx=O(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),rx=O(([e,t])=>Gd(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Md(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),ix=O(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return _l(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),ax=O(([e])=>_l(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),ox=O(([e])=>(sl(e.a.equal(0),()=>_l(0)),_l(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),sx=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),ex(e)),cx=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),tx(e)),lx=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),nx(e)),ux=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),rx(e)),dx=O(([e])=>hx(e.rgb)),fx=O(([e,t=k(1)])=>t.mix(hx(e.rgb),e.rgb)),px=O(([e,t=k(1)])=>{let n=yu(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return Gd(e.rgb,r,i)}),mx=O(([e,t=k(1)])=>{let n=N(.57735,.57735,.57735),r=t.cos();return N(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(Id(n,e.rgb).mul(r.oneMinus())))))}),hx=(e,t=N(Cr.getLuminanceCoefficients(new C)))=>Id(e,t),gx=O(([e,t=N(1),n=N(0),r=N(1),i=k(1),a=N(Cr.getLuminanceCoefficients(new C,gn))])=>{let o=e.rgb.dot(N(a)),s=jd(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return sl(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),sl(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),sl(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),_l(s.rgb,e.a)});var _x=class extends _c{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const vx=E(_x).setParameterLength(2),yx=new lr;var bx=class extends pp{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)}},xx=class extends bx{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}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)}},Sx=class e extends _c{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new To;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new Fr(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:mt,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=uu(0),this._cameraFar=uu(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=ac.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=T(new xx(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=T(new xx(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=c_(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=a_(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),yx.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(yx)),this._pixelRatio=i,this.setSize(yx.width,yx.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};Sx.COLOR=`color`,Sx.DEPTH=`depth`;const Cx=(e,t,n)=>T(new Sx(Sx.COLOR,e,t,n)),wx=(e,t)=>T(new bx(e,t)),Tx=(e,t,n)=>T(new Sx(Sx.DEPTH,e,t,n));var Ex=class extends Sx{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(Sx.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new T_;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=re;let t=hm.negate(),n=jp.mul(em),r=k(1),i=n.mul(_l(am,1)),a=n.mul(_l(am.add(t),1)),o=cd(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=_l(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 Dx=(e,t,n=new ra(0,0,0),r=.003,i=1)=>T(new Ex(e,t,T(n),T(r),T(i))),Ox=O(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),kx=O(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Ax=O(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),jx=O(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Mx=O(([e,t])=>{let n=Sl(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=Sl(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=jx(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Nx=Sl(N(1.6605,-.1246,-.0182),N(-.5876,1.1329,-.1006),N(-.0728,-.0083,1.1187)),Px=Sl(N(.6274,.0691,.0164),N(.3293,.9195,.088),N(.0433,.0113,.8956)),Fx=O(([e])=>{let t=N(e).toVar(),n=N(t.mul(t)).toVar(),r=N(n.mul(n)).toVar();return k(15.5).mul(r.mul(n)).sub(xu(40.14,r.mul(t))).add(xu(31.96,r).sub(xu(6.868,n.mul(t))).add(xu(.4298,n).add(xu(.1191,t).sub(.00232))))}),Ix=O(([e,t])=>{let n=N(e).toVar(),r=Sl(N(.856627153315983,.137318972929847,.11189821299995),N(.0951212405381588,.761241990602591,.0767994186031903),N(.0482516061458583,.101439036467562,.811302368396859)),i=Sl(N(1.1271005818144368,-.1413297634984383,-.14132976349843826),N(-.11060664309660323,1.157823702216272,-.11060664309660294),N(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=k(-12.47393),o=k(4.026069);return n.mulAssign(t),n.assign(Px.mul(n)),n.assign(r.mul(n)),n.assign(jd(n,1e-10)),n.assign(rd(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(Kd(n,0,1)),n.assign(Fx(n)),n.assign(i.mul(n)),n.assign(Rd(jd(N(0),n),N(2.2))),n.assign(Nx.mul(n)),n.assign(Kd(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Lx=O(([e,t])=>{let n=k(.76),r=k(.15);e=e.mul(t);let i=Ad(e.r,Ad(e.g,e.b)),a=af(i.lessThan(.08),i.sub(xu(6.25,i.mul(i))),.04);e.subAssign(a);let o=jd(e.r,jd(e.g,e.b));sl(o.lessThan(n),()=>e);let s=bu(1,n),c=bu(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=bu(1,Su(1,r.mul(o.sub(c)).add(1)));return Gd(e,N(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var Rx=class extends mc{static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.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 zx=E(Rx).setParameterLength(1,3),Bx=(e,t)=>zx(e,t,`js`),Vx=(e,t)=>zx(e,t,`wgsl`),Hx=(e,t)=>zx(e,t,`glsl`);var Ux=class extends Rx{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
61
+ `,t===`property`?o:e.format(`${o}()`,i,t)}};const Wx=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=T(new Ux(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},Gx=(e,t)=>Wx(e,t,`glsl`),Kx=(e,t)=>Wx(e,t,`wgsl`);var qx=class extends mc{static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Kn,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(){let 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:k()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=nc(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?rc(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}};const Jx=E(qx).setParameterLength(1);var Yx=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},wne=class{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){let t=this.parameters[e],n=t?t.getValue():null;return n}};const Xx=new Yx;var Zx=class extends mc{static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Yx,this._output=Jx(null),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(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=Jx(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=Jx(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[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(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r(...t)}async callAsync(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r.constructor.name===`AsyncFunction`?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new wne(this),r=Xx.get(`THREE`),i=Xx.get(`TSL`),a=this.getMethod(),o=[n,this._local,Xx,e,t,r,i];this._object=a(...o);let s=this._object.layout;if(s&&(s.cache===!1&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(let e of s.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){for(let t in super.deserialize(e),this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:k()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`],n=t.join(`, `),r=`var `+n+`; var output = {};
62
+ `,i=`
63
+ return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),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){let t=[Vs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Hs(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 Qx=E(Zx).setParameterLength(1,2);function $x(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||lm.z).negate()}const eS=O(([e,t],n)=>{let r=$x(n);return Yd(e,t,r)}),tS=O(([e],t)=>{let n=$x(t);return e.mul(e,n,n).negate().exp().oneMinus()}),nS=O(([e,t])=>_l(t.toFloat().mix(ql.rgb,e.toVec3()),ql.a));function rS(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),nS(e,eS(t,n))}function iS(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),nS(e,tS(t))}let aS=null,oS=null;var sS=class extends mc{static get type(){return`RangeNode`}constructor(e=k(),t=k()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength($s(this.minNode.value)),n=e.getTypeLength($s(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength($s(r)),o=e.getTypeLength($s(i));aS||=new Pr,oS||=new Pr,aS.setScalar(0),oS.setScalar(0),a===1?aS.setScalar(r):r.isColor?aS.set(r.r,r.g,r.b,1):aS.set(r.x,r.y,r.z||0,r.w||0),o===1?oS.setScalar(i):i.isColor?oS.set(i.r,i.g,i.b,1):oS.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=aS.getComponent(t),r=oS.getComponent(t);l[e]=cr.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=xp(l,`vec4`,t.count).element(ng).convert(u);else{let t=new uo(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=Rf(t).convert(u)}}else n=k(0);return n}};const cS=E(sS).setParameterLength(2);var lS=class extends mc{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){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} 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 uS=(e,t)=>T(new lS(e,t)),dS=uS(`numWorkgroups`,`uvec3`),fS=uS(`workgroupId`,`uvec3`),pS=uS(`globalId`,`uvec3`),mS=uS(`localId`,`uvec3`),hS=uS(`subgroupSize`,`uint`);var gS=class extends mc{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const _S=E(gS),vS=()=>_S(`workgroup`).toStack(),yS=()=>_S(`storage`).toStack(),bS=()=>_S(`texture`).toStack();var xS=class extends hc{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},SS=class extends mc{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return T(new xS(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const CS=(e,t)=>T(new SS(`Workgroup`,e,t));var wS=class extends mc{static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=Zf(l,i).toConst()),t.constNode.build(e)}};wS.ATOMIC_LOAD=`atomicLoad`,wS.ATOMIC_STORE=`atomicStore`,wS.ATOMIC_ADD=`atomicAdd`,wS.ATOMIC_SUB=`atomicSub`,wS.ATOMIC_MAX=`atomicMax`,wS.ATOMIC_MIN=`atomicMin`,wS.ATOMIC_AND=`atomicAnd`,wS.ATOMIC_OR=`atomicOr`,wS.ATOMIC_XOR=`atomicXor`;const TS=E(wS),ES=(e,t,n)=>TS(e,t,n).toStack(),DS=e=>ES(wS.ATOMIC_LOAD,e,null),OS=(e,t)=>ES(wS.ATOMIC_STORE,e,t),kS=(e,t)=>ES(wS.ATOMIC_ADD,e,t),AS=(e,t)=>ES(wS.ATOMIC_SUB,e,t),jS=(e,t)=>ES(wS.ATOMIC_MAX,e,t),MS=(e,t)=>ES(wS.ATOMIC_MIN,e,t),NS=(e,t)=>ES(wS.ATOMIC_AND,e,t),PS=(e,t)=>ES(wS.ATOMIC_OR,e,t),FS=(e,t)=>ES(wS.ATOMIC_XOR,e,t);let IS;function LS(e){IS||=new WeakMap;let t=IS.get(e);return t===void 0&&IS.set(e,t={}),t}function RS(e){let t=LS(e);return t.shadowMatrix||=uu(`mat4`).setGroup(su).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function zS(e,t=sm){let n=RS(e).mul(t),r=n.xyz.div(n.w);return r}function BS(e){let t=LS(e);return t.position||=uu(new C).setGroup(su).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function VS(e){let t=LS(e);return t.targetPosition||=uu(new C).setGroup(su).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function HS(e){let t=LS(e);return t.viewPosition||=uu(new C).setGroup(su).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new C,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const US=e=>Np.transformDirection(BS(e).sub(VS(e))),WS=e=>e.sort((e,t)=>e.id-t.id),GS=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},KS=new WeakMap,qS=[];var JS=class extends mc{static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=N().toVar(),this.totalSpecularNode=N().toVar(),this.outgoingLightNode=N().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(qS.push(n.id),qS.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;qS.push(e,t)}}let t=Hs(qS);return qS.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=WS(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(T(e));else{let r=null;if(n!==null&&(r=GS(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;KS.has(e)?r=KS.get(e):(r=T(new n(e)),KS.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=N(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const YS=(e=[])=>T(new JS).setLights(e);var XS=class extends mc{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=ac.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){ZS.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||sm)}};const ZS=Dl(`vec3`,`shadowPositionWorld`);function QS(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new ra),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function $S(e,t){return t=QS(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function eC(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function tC(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function nC(e,t){return t=tC(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function rC(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function iC(e,t,n){return n=$S(e,n),n=nC(t,n),n}function aC(e,t,n){eC(e,n),rC(t,n)}const oC=new WeakMap,sC=O(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=hp(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),cC=O(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=hp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=Bm(`mapSize`,`vec2`,n).setGroup(su),o=Bm(`radius`,`float`,n).setGroup(su),s=M(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return yu(i(t.xy.add(M(c,l)),t.z),i(t.xy.add(M(0,l)),t.z),i(t.xy.add(M(u,l)),t.z),i(t.xy.add(M(f,p)),t.z),i(t.xy.add(M(0,p)),t.z),i(t.xy.add(M(m,p)),t.z),i(t.xy.add(M(c,0)),t.z),i(t.xy.add(M(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(M(m,0)),t.z),i(t.xy.add(M(u,0)),t.z),i(t.xy.add(M(f,h)),t.z),i(t.xy.add(M(0,h)),t.z),i(t.xy.add(M(m,h)),t.z),i(t.xy.add(M(c,d)),t.z),i(t.xy.add(M(0,d)),t.z),i(t.xy.add(M(u,d)),t.z)).mul(1/17)}),lC=O(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=hp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=Bm(`mapSize`,`vec2`,n).setGroup(su),o=M(1).div(a),s=o.x,c=o.y,l=t.xy,u=ld(l.mul(a).add(.5));return l.subAssign(u.mul(o)),yu(i(l,t.z),i(l.add(M(s,0)),t.z),i(l.add(M(0,c)),t.z),i(l.add(o),t.z),Gd(i(l.add(M(s.negate(),0)),t.z),i(l.add(M(s.mul(2),0)),t.z),u.x),Gd(i(l.add(M(s.negate(),c)),t.z),i(l.add(M(s.mul(2),c)),t.z),u.x),Gd(i(l.add(M(0,c.negate())),t.z),i(l.add(M(0,c.mul(2))),t.z),u.y),Gd(i(l.add(M(s,c.negate())),t.z),i(l.add(M(s,c.mul(2))),t.z),u.y),Gd(Gd(i(l.add(M(s.negate(),c.negate())),t.z),i(l.add(M(s.mul(2),c.negate())),t.z),u.x),Gd(i(l.add(M(s.negate(),c.mul(2))),t.z),i(l.add(M(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),uC=O(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=k(1).toVar(),i=hp(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=Md(t.z,i.x);return sl(a.notEqual(k(1)),()=>{let e=t.z.sub(i.x),n=jd(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=Kd(bu(o,.3).div(.6499999999999999)),r.assign(Kd(jd(a,o)))}),r}),dC=O(([e,t,n])=>{let r=sm.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),fC=e=>{let t=e.shadow.camera,n=Bm(`near`,`float`,t).setGroup(su),r=Bm(`far`,`float`,t).setGroup(su),i=Vp(e);return dC(i,n,r)},pC=e=>{let t=oC.get(e);if(t===void 0){let n=e.isPointLight?fC(e):null;t=new T_,t.colorNode=_l(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,oC.set(e,t)}return t},mC=new qy,hC=[],gC=(e,t,n,r)=>{hC[0]=e,hC[1]=t;let i=mC.get(hC);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===te)&&(r&&(tc(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,mC.set(hC,i)),hC[0]=null,hC[1]=null,i},_C=O(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=k(0).toVar(`meanVertical`),o=k(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(k(1)).select(k(0),k(2).div(e.sub(1))),c=e.lessThanEqual(k(1)).select(k(0),k(-1));Cg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(yu(Ug.xy,M(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=id(o.sub(a.mul(a)));return M(a,l)}),vC=O(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=k(0).toVar(`meanHorizontal`),o=k(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(k(1)).select(k(0),k(2).div(e.sub(1))),c=e.lessThanEqual(k(1)).select(k(0),k(-1));Cg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(yu(Ug.xy,M(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(yu(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=id(o.sub(a.mul(a)));return M(a,l)}),yC=[sC,cC,lC,uC];let bC;const xC=new Nb;var SC=class extends XS{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,k(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=Bm(`bias`,`float`,n).setGroup(su),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===Gn&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=Bm(`near`,`float`,n.camera).setGroup(su),r=Bm(`far`,`float`,n.camera).setGroup(su);o=l_(e.negate(),t,r)}return a=N(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return yC[e]}setupRenderTarget(e,t){let n=new To(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=Fn;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===te&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Tt,type:mt,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Tt,type:mt,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Tt,type:mt,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:Tt,type:mt,depthBuffer:!1}));let t=hp(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=hp(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=Bm(`blurSamples`,`float`,r).setGroup(su),s=Bm(`radius`,`float`,r).setGroup(su),c=Bm(`mapSize`,`vec2`,r).setGroup(su),l=this.vsmMaterialVertical||=new T_;l.fragmentNode=_C({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new T_,l.fragmentNode=vC({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=Bm(`intensity`,`float`,r).setGroup(su),c=Bm(`normalBias`,`float`,r).setGroup(su),l=RS(n).mul(ZS.add(bm.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===te&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=hp(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=Gd(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return O(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;bC=iC(i,a,bC),a.overrideMaterial=pC(n),i.setRenderObjectFunction(gC(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===te&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,aC(i,a,bC)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),xC.material=this.vsmMaterialVertical,xC.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),xC.material=this.vsmMaterialHorizontal,xC.render(e)}dispose(){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),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const CC=(e,t)=>T(new SC(e,t)),wC=new ra,TC=O(([e,t])=>{let n=e.toVar(),r=gd(n),i=Su(1,jd(r.x,jd(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=M(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return sl(r.z.greaterThanEqual(s),()=>{sl(n.z.greaterThan(0),()=>{a.x.assign(bu(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=_d(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=_d(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),M(.125,.25).mul(a).add(M(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),EC=O(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>hp(e,TC(t,r.y)).compare(n)),DC=O(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=Bm(`radius`,`float`,i).setGroup(su),o=M(-1,1).mul(a).mul(r.y);return hp(e,TC(t.add(o.xyy),r.y)).compare(n).add(hp(e,TC(t.add(o.yyy),r.y)).compare(n)).add(hp(e,TC(t.add(o.xyx),r.y)).compare(n)).add(hp(e,TC(t.add(o.yyx),r.y)).compare(n)).add(hp(e,TC(t,r.y)).compare(n)).add(hp(e,TC(t.add(o.xxy),r.y)).compare(n)).add(hp(e,TC(t.add(o.yxy),r.y)).compare(n)).add(hp(e,TC(t.add(o.xxx),r.y)).compare(n)).add(hp(e,TC(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),OC=O(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=uu(`float`).setGroup(su).onRenderUpdate(()=>r.camera.near),s=uu(`float`).setGroup(su).onRenderUpdate(()=>r.camera.far),c=Bm(`bias`,`float`,r).setGroup(su),l=uu(r.mapSize).setGroup(su),u=k(1).toVar();return sl(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=M(1).div(l.mul(M(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),kC=new Pr,AC=new lr,jC=new lr;var MC=class extends SC{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===S?EC:DC}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return OC({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();jC.copy(t.mapSize),jC.multiply(o),n.setSize(jC.width,jC.height),AC.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(wC),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=AC.x*o.x,c=jC.y-AC.y-AC.y*o.y;kC.set(s,c,AC.x*o.z,AC.y*o.w),n.viewport.copy(kC),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const NC=(e,t)=>T(new MC(e,t));var PC=class extends Ng{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new ra,this.colorNode=e&&e.colorNode||uu(this.color).setGroup(su),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ac.FRAME}getHash(){return this.light.uuid}getLightVector(e){return HS(this.light).sub(e.context.positionView||lm)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return CC(this.light)}setupShadow(e){let{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){let e=this.light.shadow.shadowNode,t;t=e===void 0?this.setupShadowNode():T(e),this.shadowNode=t,this.shadowColorNode=n=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}};const FC=O(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),IC=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=FC({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}};var LC=class extends PC{static get type(){return`PointLightNode`}constructor(e=null){super(e),this.cutoffDistanceNode=uu(0).setGroup(su),this.decayExponentNode=uu(2).setGroup(su)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return NC(this.light)}setupDirect(e){return IC({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}};const RC=O(([e=sp()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),Tne=O(([e=sp()],{renderer:t,material:n})=>{let r=Wd(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=k(r.fwidth()).toVar();i=Yd(e.oneMinus(),e.add(1),r).oneMinus()}else i=af(r.greaterThan(1),0,1);return i}),zC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=ul(e).toVar();return af(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),BC=O(([e,t])=>{let n=ul(t).toVar(),r=k(e).toVar();return af(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),VC=O(([e])=>{let t=k(e).toVar();return A(od(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),HC=O(([e,t])=>{let n=k(e).toVar();return t.assign(VC(n)),n.sub(k(t))}),UC=O(([e,t,n,r,i,a])=>{let o=k(a).toVar(),s=k(i).toVar(),c=k(r).toVar(),l=k(n).toVar(),u=k(t).toVar(),d=k(e).toVar(),f=k(bu(1,s)).toVar();return bu(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).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`}]}),WC=O(([e,t,n,r,i,a])=>{let o=k(a).toVar(),s=k(i).toVar(),c=N(r).toVar(),l=N(n).toVar(),u=N(t).toVar(),d=N(e).toVar(),f=k(bu(1,s)).toVar();return bu(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).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`}]}),GC=hb([UC,WC]),KC=O(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=k(u).toVar(),f=k(l).toVar(),p=k(c).toVar(),m=k(s).toVar(),h=k(o).toVar(),g=k(a).toVar(),_=k(i).toVar(),v=k(r).toVar(),y=k(n).toVar(),b=k(t).toVar(),x=k(e).toVar(),S=k(bu(1,p)).toVar(),ee=k(bu(1,f)).toVar(),te=k(bu(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).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`}]}),qC=O(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=k(u).toVar(),f=k(l).toVar(),p=k(c).toVar(),m=N(s).toVar(),h=N(o).toVar(),g=N(a).toVar(),_=N(i).toVar(),v=N(r).toVar(),y=N(n).toVar(),b=N(t).toVar(),x=N(e).toVar(),S=k(bu(1,p)).toVar(),ee=k(bu(1,f)).toVar(),te=k(bu(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).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`}]}),JC=hb([KC,qC]),YC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=j(e).toVar(),o=j(a.bitAnd(j(7))).toVar(),s=k(zC(o.lessThan(j(4)),i,r)).toVar(),c=k(xu(2,zC(o.lessThan(j(4)),r,i))).toVar();return BC(s,ul(o.bitAnd(j(1)))).add(BC(c,ul(o.bitAnd(j(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),XC=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=k(t).toVar(),s=j(e).toVar(),c=j(s.bitAnd(j(15))).toVar(),l=k(zC(c.lessThan(j(8)),o,a)).toVar(),u=k(zC(c.lessThan(j(4)),a,zC(c.equal(j(12)).or(c.equal(j(14))),o,i))).toVar();return BC(l,ul(c.bitAnd(j(1)))).add(BC(u,ul(c.bitAnd(j(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`}]}),ZC=hb([YC,XC]),QC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=hl(e).toVar();return N(ZC(a.x,i,r),ZC(a.y,i,r),ZC(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),$C=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=k(t).toVar(),s=hl(e).toVar();return N(ZC(s.x,o,a,i),ZC(s.y,o,a,i),ZC(s.z,o,a,i))}).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`}]}),ew=hb([QC,$C]),tw=O(([e])=>{let t=k(e).toVar();return xu(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),nw=O(([e])=>{let t=k(e).toVar();return xu(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),rw=O(([e])=>{let t=N(e).toVar();return xu(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),iw=hb([tw,rw]),aw=O(([e])=>{let t=N(e).toVar();return xu(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),ow=hb([nw,aw]),sw=O(([e,t])=>{let n=A(t).toVar(),r=j(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(A(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),cw=O(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(sw(n,A(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(sw(e,A(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(sw(t,A(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(sw(n,A(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(sw(e,A(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(sw(t,A(4))),t.addAssign(e)}),lw=O(([e,t,n])=>{let r=j(n).toVar(),i=j(t).toVar(),a=j(e).toVar();return r.bitXorAssign(i),r.subAssign(sw(i,A(14))),a.bitXorAssign(r),a.subAssign(sw(r,A(11))),i.bitXorAssign(a),i.subAssign(sw(a,A(25))),r.bitXorAssign(i),r.subAssign(sw(i,A(16))),a.bitXorAssign(r),a.subAssign(sw(r,A(4))),i.bitXorAssign(a),i.subAssign(sw(a,A(14))),r.bitXorAssign(i),r.subAssign(sw(i,A(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),uw=O(([e])=>{let t=j(e).toVar();return k(t).div(k(j(A(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),dw=O(([e])=>{let t=k(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),fw=O(([e])=>{let t=A(e).toVar(),n=j(j(1)).toVar(),r=j(j(A(3735928559)).add(n.shiftLeft(j(2))).add(j(13))).toVar();return lw(r.add(j(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),pw=O(([e,t])=>{let n=A(t).toVar(),r=A(e).toVar(),i=j(j(2)).toVar(),a=j().toVar(),o=j().toVar(),s=j().toVar();return a.assign(o.assign(s.assign(j(A(3735928559)).add(i.shiftLeft(j(2))).add(j(13))))),a.addAssign(j(r)),o.addAssign(j(n)),lw(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),mw=O(([e,t,n])=>{let r=A(n).toVar(),i=A(t).toVar(),a=A(e).toVar(),o=j(j(3)).toVar(),s=j().toVar(),c=j().toVar(),l=j().toVar();return s.assign(c.assign(l.assign(j(A(3735928559)).add(o.shiftLeft(j(2))).add(j(13))))),s.addAssign(j(a)),c.addAssign(j(i)),l.addAssign(j(r)),lw(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),hw=O(([e,t,n,r])=>{let i=A(r).toVar(),a=A(n).toVar(),o=A(t).toVar(),s=A(e).toVar(),c=j(j(4)).toVar(),l=j().toVar(),u=j().toVar(),d=j().toVar();return l.assign(u.assign(d.assign(j(A(3735928559)).add(c.shiftLeft(j(2))).add(j(13))))),l.addAssign(j(s)),u.addAssign(j(o)),d.addAssign(j(a)),cw(l,u,d),l.addAssign(j(i)),lw(l,u,d)}).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`}]}),gw=O(([e,t,n,r,i])=>{let a=A(i).toVar(),o=A(r).toVar(),s=A(n).toVar(),c=A(t).toVar(),l=A(e).toVar(),u=j(j(5)).toVar(),d=j().toVar(),f=j().toVar(),p=j().toVar();return d.assign(f.assign(p.assign(j(A(3735928559)).add(u.shiftLeft(j(2))).add(j(13))))),d.addAssign(j(l)),f.addAssign(j(c)),p.addAssign(j(s)),cw(d,f,p),d.addAssign(j(o)),f.addAssign(j(a)),lw(d,f,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`}]}),_w=hb([fw,pw,mw,hw,gw]),vw=O(([e,t])=>{let n=A(t).toVar(),r=A(e).toVar(),i=j(_w(r,n)).toVar(),a=hl().toVar();return a.x.assign(i.bitAnd(A(255))),a.y.assign(i.shiftRight(A(8)).bitAnd(A(255))),a.z.assign(i.shiftRight(A(16)).bitAnd(A(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),yw=O(([e,t,n])=>{let r=A(n).toVar(),i=A(t).toVar(),a=A(e).toVar(),o=j(_w(a,i,r)).toVar(),s=hl().toVar();return s.x.assign(o.bitAnd(A(255))),s.y.assign(o.shiftRight(A(8)).bitAnd(A(255))),s.z.assign(o.shiftRight(A(16)).bitAnd(A(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),bw=hb([vw,yw]),xw=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(HC(t.x,n)).toVar(),a=k(HC(t.y,r)).toVar(),o=k(dw(i)).toVar(),s=k(dw(a)).toVar(),c=k(GC(ZC(_w(n,r),i,a),ZC(_w(n.add(A(1)),r),i.sub(1),a),ZC(_w(n,r.add(A(1))),i,a.sub(1)),ZC(_w(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return iw(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Sw=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(HC(t.x,n)).toVar(),o=k(HC(t.y,r)).toVar(),s=k(HC(t.z,i)).toVar(),c=k(dw(a)).toVar(),l=k(dw(o)).toVar(),u=k(dw(s)).toVar(),d=k(JC(ZC(_w(n,r,i),a,o,s),ZC(_w(n.add(A(1)),r,i),a.sub(1),o,s),ZC(_w(n,r.add(A(1)),i),a,o.sub(1),s),ZC(_w(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),ZC(_w(n,r,i.add(A(1))),a,o,s.sub(1)),ZC(_w(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),ZC(_w(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),ZC(_w(n.add(A(1)),r.add(A(1)),i.add(A(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return ow(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Cw=hb([xw,Sw]),ww=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(HC(t.x,n)).toVar(),a=k(HC(t.y,r)).toVar(),o=k(dw(i)).toVar(),s=k(dw(a)).toVar(),c=N(GC(ew(bw(n,r),i,a),ew(bw(n.add(A(1)),r),i.sub(1),a),ew(bw(n,r.add(A(1))),i,a.sub(1)),ew(bw(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return iw(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Tw=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(HC(t.x,n)).toVar(),o=k(HC(t.y,r)).toVar(),s=k(HC(t.z,i)).toVar(),c=k(dw(a)).toVar(),l=k(dw(o)).toVar(),u=k(dw(s)).toVar(),d=N(JC(ew(bw(n,r,i),a,o,s),ew(bw(n.add(A(1)),r,i),a.sub(1),o,s),ew(bw(n,r.add(A(1)),i),a,o.sub(1),s),ew(bw(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),ew(bw(n,r,i.add(A(1))),a,o,s.sub(1)),ew(bw(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),ew(bw(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),ew(bw(n.add(A(1)),r.add(A(1)),i.add(A(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return ow(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Ew=hb([ww,Tw]),Dw=O(([e])=>{let t=k(e).toVar(),n=A(VC(t)).toVar();return uw(_w(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Ow=O(([e])=>{let t=M(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar();return uw(_w(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),kw=O(([e])=>{let t=N(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar(),i=A(VC(t.z)).toVar();return uw(_w(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Aw=O(([e])=>{let t=_l(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar(),i=A(VC(t.z)).toVar(),a=A(VC(t.w)).toVar();return uw(_w(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),jw=hb([Dw,Ow,kw,Aw]),Mw=O(([e])=>{let t=k(e).toVar(),n=A(VC(t)).toVar();return N(uw(_w(n,A(0))),uw(_w(n,A(1))),uw(_w(n,A(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Nw=O(([e])=>{let t=M(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar();return N(uw(_w(n,r,A(0))),uw(_w(n,r,A(1))),uw(_w(n,r,A(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Pw=O(([e])=>{let t=N(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar(),i=A(VC(t.z)).toVar();return N(uw(_w(n,r,i,A(0))),uw(_w(n,r,i,A(1))),uw(_w(n,r,i,A(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Fw=O(([e])=>{let t=_l(e).toVar(),n=A(VC(t.x)).toVar(),r=A(VC(t.y)).toVar(),i=A(VC(t.z)).toVar(),a=A(VC(t.w)).toVar();return N(uw(_w(n,r,i,a,A(0))),uw(_w(n,r,i,a,A(1))),uw(_w(n,r,i,a,A(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),Iw=hb([Mw,Nw,Pw,Fw]),Lw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar(),c=k(0).toVar(),l=k(1).toVar();return Cg(o,()=>{c.addAssign(l.mul(Cw(s))),l.mulAssign(i),s.mulAssign(a)}),c}).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`}]}),Rw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar(),c=N(0).toVar(),l=k(1).toVar();return Cg(o,()=>{c.addAssign(l.mul(Ew(s))),l.mulAssign(i),s.mulAssign(a)}),c}).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`}]}),zw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar();return M(Lw(s,o,a,i),Lw(s.add(N(A(19),A(193),A(17))),o,a,i))}).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`}]}),Bw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar(),c=N(Rw(s,o,a,i)).toVar(),l=k(Lw(s.add(N(A(19),A(193),A(17))),o,a,i)).toVar();return _l(c,l)}).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`}]}),Vw=O(([e,t,n,r,i,a,o])=>{let s=A(o).toVar(),c=k(a).toVar(),l=A(i).toVar(),u=A(r).toVar(),d=A(n).toVar(),f=A(t).toVar(),p=M(e).toVar(),m=N(Iw(M(f.add(u),d.add(l)))).toVar(),h=M(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=M(M(k(f),k(d)).add(h)).toVar(),_=M(g.sub(p)).toVar();return sl(s.equal(A(2)),()=>gd(_.x).add(gd(_.y))),sl(s.equal(A(3)),()=>jd(gd(_.x),gd(_.y))),Id(_,_)}).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`}]}),Hw=O(([e,t,n,r,i,a,o,s,c])=>{let l=A(c).toVar(),u=k(s).toVar(),d=A(o).toVar(),f=A(a).toVar(),p=A(i).toVar(),m=A(r).toVar(),h=A(n).toVar(),g=A(t).toVar(),_=N(e).toVar(),v=N(Iw(N(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=N(N(k(g),k(h),k(m)).add(v)).toVar(),b=N(y.sub(_)).toVar();return sl(l.equal(A(2)),()=>gd(b.x).add(gd(b.y)).add(gd(b.z))),sl(l.equal(A(3)),()=>jd(gd(b.x),gd(b.y),gd(b.z))),Id(b,b)}).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`}]}),Uw=hb([Vw,Hw]),Ww=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=M(e).toVar(),o=A().toVar(),s=A().toVar(),c=M(HC(a.x,o),HC(a.y,s)).toVar(),l=k(1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Uw(c,e,t,o,s,i,r)).toVar();l.assign(Ad(l,n))})}),sl(r.equal(A(0)),()=>{l.assign(id(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Gw=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=M(e).toVar(),o=A().toVar(),s=A().toVar(),c=M(HC(a.x,o),HC(a.y,s)).toVar(),l=M(1e6,1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Uw(c,e,t,o,s,i,r)).toVar();sl(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),sl(r.equal(A(0)),()=>{l.assign(id(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Kw=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=M(e).toVar(),o=A().toVar(),s=A().toVar(),c=M(HC(a.x,o),HC(a.y,s)).toVar(),l=N(1e6,1e6,1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Uw(c,e,t,o,s,i,r)).toVar();sl(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),sl(r.equal(A(0)),()=>{l.assign(id(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),qw=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=N(e).toVar(),o=A().toVar(),s=A().toVar(),c=A().toVar(),l=N(HC(a.x,o),HC(a.y,s),HC(a.z,c)).toVar(),u=k(1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Cg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Uw(l,e,t,n,o,s,c,i,r)).toVar();u.assign(Ad(u,a))})})}),sl(r.equal(A(0)),()=>{u.assign(id(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Jw=hb([Ww,qw]),Yw=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=N(e).toVar(),o=A().toVar(),s=A().toVar(),c=A().toVar(),l=N(HC(a.x,o),HC(a.y,s),HC(a.z,c)).toVar(),u=M(1e6,1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Cg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Uw(l,e,t,n,o,s,c,i,r)).toVar();sl(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),sl(r.equal(A(0)),()=>{u.assign(id(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Xw=hb([Gw,Yw]),Zw=O(([e,t,n])=>{let r=A(n).toVar(),i=k(t).toVar(),a=N(e).toVar(),o=A().toVar(),s=A().toVar(),c=A().toVar(),l=N(HC(a.x,o),HC(a.y,s),HC(a.z,c)).toVar(),u=N(1e6,1e6,1e6).toVar();return Cg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Cg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Cg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Uw(l,e,t,n,o,s,c,i,r)).toVar();sl(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),sl(r.equal(A(0)),()=>{u.assign(id(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Qw=hb([Kw,Zw]),$w=O(([e])=>{let t=e.y,n=e.z,r=N().toVar();return sl(t.lessThan(1e-4),()=>{r.assign(N(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(od(i)).mul(6).toVar();let a=A(Td(i)),o=i.sub(k(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());sl(a.equal(A(0)),()=>{r.assign(N(n,l,s))}).ElseIf(a.equal(A(1)),()=>{r.assign(N(c,n,s))}).ElseIf(a.equal(A(2)),()=>{r.assign(N(s,n,l))}).ElseIf(a.equal(A(3)),()=>{r.assign(N(s,c,n))}).ElseIf(a.equal(A(4)),()=>{r.assign(N(l,s,n))}).Else(()=>{r.assign(N(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),eT=O(([e])=>{let t=N(e).toVar(),n=k(t.x).toVar(),r=k(t.y).toVar(),i=k(t.z).toVar(),a=k(Ad(n,Ad(r,i))).toVar(),o=k(jd(n,jd(r,i))).toVar(),s=k(o.sub(a)).toVar(),c=k().toVar(),l=k().toVar(),u=k().toVar();return u.assign(o),sl(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),sl(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{sl(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(yu(2,i.sub(n).div(s)))}).Else(()=>{c.assign(yu(4,n.sub(r).div(s)))}),c.mulAssign(1/6),sl(c.lessThan(0),()=>{c.addAssign(1)})}),N(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),tT=O(([e])=>{let t=N(e).toVar(),n=gl(Du(t,N(.04045))).toVar(),r=N(t.div(12.92)).toVar(),i=N(Rd(jd(t.add(N(.055)),N(0)).div(1.055),N(2.4))).toVar();return Gd(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),nT=(e,t)=>{e=k(e),t=k(t);let n=M(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Yd(e.sub(n),e.add(n),t)},rT=(e,t,n,r)=>Gd(e,t,n[r].clamp()),iT=(e,t,n=sp())=>rT(e,t,n,`x`),aT=(e,t,n=sp())=>rT(e,t,n,`y`),oT=(e,t,n,r,i)=>Gd(e,t,nT(n,r[i])),sT=(e,t,n,r=sp())=>oT(e,t,n,r,`x`),cT=(e,t,n,r=sp())=>oT(e,t,n,r,`y`),lT=(e=1,t=0,n=sp())=>n.mul(e).add(t),uT=(e,t=1)=>(e=k(e),e.abs().pow(t).mul(e.sign())),dT=(e,t=1,n=.5)=>k(e).sub(n).mul(t).add(n),fT=(e=sp(),t=1,n=0)=>Cw(e.convert(`vec2|vec3`)).mul(t).add(n),pT=(e=sp(),t=1,n=0)=>Ew(e.convert(`vec2|vec3`)).mul(t).add(n),mT=(e=sp(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=_l(Ew(e),Cw(e.add(M(19,73))));return r.mul(t).add(n)},hT=(e=sp(),t=1)=>Jw(e.convert(`vec2|vec3`),t,A(1)),gT=(e=sp(),t=1)=>Xw(e.convert(`vec2|vec3`),t,A(1)),_T=(e=sp(),t=1)=>Qw(e.convert(`vec2|vec3`),t,A(1)),vT=(e=sp())=>jw(e.convert(`vec2|vec3`)),yT=(e=sp(),t=3,n=2,r=.5,i=1)=>Lw(e,A(t),n,r).mul(i),bT=(e=sp(),t=3,n=2,r=.5,i=1)=>zw(e,A(t),n,r).mul(i),xT=(e=sp(),t=3,n=2,r=.5,i=1)=>Rw(e,A(t),n,r).mul(i),ST=(e=sp(),t=3,n=2,r=.5,i=1)=>Bw(e,A(t),n,r).mul(i),CT=O(([e,t,n])=>{let r=cd(e).toVar(),i=bu(k(.5).mul(t.sub(n)),sm).div(r).toVar(),a=bu(k(-.5).mul(t.sub(n)),sm).div(r).toVar(),o=N().toVar();o.x=r.x.greaterThan(k(0)).select(i.x,a.x),o.y=r.y.greaterThan(k(0)).select(i.y,a.y),o.z=r.z.greaterThan(k(0)).select(i.z,a.z);let s=Ad(o.x,o.y,o.z).toVar(),c=sm.add(r.mul(s)).toVar();return c.sub(n)}),wT=O(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(xu(n,n).sub(xu(r,r)))),a});var I=Object.freeze({__proto__:null,BRDF_GGX:hv,BRDF_Lambert:$_,BasicPointShadowFilter:EC,BasicShadowFilter:sC,Break:Tg,Const:mf,Continue:wg,DFGApprox:gv,D_GGX:fv,Discard:Qf,EPSILON:Ku,F_Schlick:Q_,Fn:O,INFINITY:qu,If:sl,Loop:Cg,NodeAccess:sc,NodeShaderStage:ic,NodeType:oc,NodeUpdateType:ac,PCFShadowFilter:cC,PCFSoftShadowFilter:lC,PI:Ju,PI2:Yu,PointShadowFilter:DC,Return:$f,Schlick_to_F0:vv,ScriptableNodeResources:Xx,ShaderNode:nl,Stack:cl,Switch:vee,TBNViewMatrix:rh,VSMShadowFilter:uC,V_GGX_SmithCorrelated:uv,Var:pf,abs:gd,acesFilmicToneMapping:Mx,acos:md,add:yu,addMethodChaining:w,addNodeElement:ip,agxToneMapping:Ix,all:Xu,alphaT:Bl,and:Au,anisotropy:Vl,anisotropyB:Ul,anisotropyT:Hl,any:Zu,append:See,array:fu,arrayBuffer:bee,asin:pd,assign:mu,atan:hd,atan2:ef,atomicAdd:kS,atomicAnd:NS,atomicFunc:ES,atomicLoad:DS,atomicMax:jS,atomicMin:MS,atomicOr:PS,atomicStore:OS,atomicSub:AS,atomicXor:FS,attenuationColor:tu,attenuationDistance:eu,attribute:op,attributeArray:yne,backgroundBlurriness:zb,backgroundIntensity:Bb,backgroundRotation:Vb,batch:fg,billboarding:ene,bitAnd:Pu,bitNot:Fu,bitOr:Iu,bitXor:Lu,bitangentGeometry:Zm,bitangentLocal:Qm,bitangentView:$m,bitangentWorld:eh,bitcast:Od,blendBurn:ex,blendColor:ix,blendDodge:tx,blendOverlay:rx,blendScreen:nx,blur:vy,bool:ul,buffer:xp,bufferAttribute:If,bumpMap:ph,burn:sx,bvec2:pl,bvec3:gl,bvec4:bl,bypass:Kf,cache:Uf,call:gu,cameraFar:Ap,cameraIndex:Op,cameraNear:kp,cameraNormalMatrix:Fp,cameraPosition:Ip,cameraProjectionMatrix:jp,cameraProjectionMatrixInverse:Mp,cameraViewMatrix:Np,cameraWorldMatrix:Pp,cbrt:Ud,cdl:gx,ceil:sd,checker:RC,cineonToneMapping:Ax,clamp:Kd,clearcoat:Nl,clearcoatRoughness:Pl,code:zx,color:ll,colorSpaceToWorking:Tf,colorToDirection:P_,compute:Vf,computeSkinning:xg,cond:sf,context:lf,convert:Tl,convertColorSpace:Ef,convertToTexture:mne,cos:dd,cross:Ld,cubeTexture:Im,cubeTextureBase:Fm,cubeToUV:TC,dFdx:xd,dFdy:Sd,dashSize:Jl,debug:rp,decrement:Uu,decrementBefore:Vu,defaultBuildStages:lc,defaultShaderStages:cc,defined:el,degrees:$u,deltaTime:_b,densityFog:iS,densityFogFactor:tS,depth:f_,depthPass:Tx,difference:Fd,diffuseColor:kl,directPointLight:IC,directionToColor:N_,dispersion:nu,distance:Pd,div:Su,dodge:cx,dot:Id,drawIndex:og,dynamicBufferAttribute:Lf,element:wl,emissive:Al,equal:wu,equals:kd,equirectUV:R_,exp:ed,exp2:td,expression:Zf,faceDirection:pm,faceForward:Xd,faceforward:tf,float:k,floor:od,fog:nS,fract:ld,frameGroup:ou,frameId:Wte,frontFacing:fm,fwidth:Ed,gain:Lte,gapSize:Yl,getConstNodeType:tl,getCurrentStack:ol,getDirection:my,getDistanceAttenuation:FC,getGeometryRoughness:cv,getNormalFromDepth:gne,getParallaxCorrectNormal:CT,getRoughness:lv,getScreenPosition:hne,getShIrradianceAt:wT,getShadowMaterial:pC,getShadowRenderObjectFunction:gC,getTextureIndex:db,getViewPosition:Fb,globalId:pS,glsl:Hx,glslFn:Gx,grayscale:dx,greaterThan:Du,greaterThanEqual:ku,hash:Ite,highpModelNormalViewMatrix:rm,highpModelViewMatrix:nm,hue:mx,increment:Hu,incrementBefore:Bu,instance:cg,instanceIndex:ng,instancedArray:bne,instancedBufferAttribute:Rf,instancedDynamicBufferAttribute:zf,instancedMesh:ug,int:A,inverseSqrt:ad,inversesqrt:nf,invocationLocalIndex:ag,invocationSubgroupIndex:ig,ior:Zl,iridescence:Ll,iridescenceIOR:Rl,iridescenceThickness:zl,ivec2:dl,ivec3:ml,ivec4:vl,js:Bx,label:uf,length:vd,lengthSq:Wd,lessThan:Eu,lessThanEqual:Ou,lightPosition:BS,lightProjectionUV:zS,lightShadowMatrix:RS,lightTargetDirection:US,lightTargetPosition:VS,lightViewPosition:HS,lightingContext:Ig,lights:YS,linearDepth:p_,linearToneMapping:Ox,localId:mS,log:nd,log2:rd,logarithmicDepthToViewZ:u_,loop:Eg,luminance:hx,mat2:xl,mat3:Sl,mat4:Cl,matcapUV:Wy,materialAO:Zh,materialAlphaTest:hh,materialAnisotropy:Ph,materialAnisotropyVector:Qh,materialAttenuationColor:Hh,materialAttenuationDistance:Vh,materialClearcoat:Oh,materialClearcoatNormal:Ah,materialClearcoatRoughness:kh,materialColor:gh,materialDispersion:Yh,materialEmissive:vh,materialEnvIntensity:Dm,materialEnvRotation:Om,materialIOR:Bh,materialIridescence:Fh,materialIridescenceIOR:Ih,materialIridescenceThickness:Lh,materialLightMap:Xh,materialLineDashOffset:qh,materialLineDashSize:Wh,materialLineGapSize:Gh,materialLineScale:Uh,materialLineWidth:Kh,materialMetalness:Eh,materialNormal:Dh,materialOpacity:yh,materialPointSize:Jh,materialReference:Um,materialReflectivity:wh,materialRefractionRatio:Em,materialRotation:jh,materialRoughness:Th,materialSheen:Mh,materialSheenRoughness:Nh,materialShininess:_h,materialSpecular:bh,materialSpecularColor:Sh,materialSpecularIntensity:xh,materialSpecularStrength:Ch,materialThickness:zh,materialTransmission:Rh,max:jd,maxMipLevel:dp,mediumpModelViewMatrix:tm,metalness:Ml,min:Ad,mix:Gd,mixElement:Qd,mod:Cu,modInt:Gu,modelDirection:Kp,modelNormalMatrix:Qp,modelPosition:Jp,modelRadius:Zp,modelScale:Yp,modelViewMatrix:em,modelViewPosition:Xp,modelViewProjection:$h,modelWorldMatrix:qp,modelWorldMatrixInverse:$p,morphReference:Mg,mrt:fb,mul:xu,mx_aastep:nT,mx_cell_noise_float:vT,mx_contrast:dT,mx_fractal_noise_float:yT,mx_fractal_noise_vec2:bT,mx_fractal_noise_vec3:xT,mx_fractal_noise_vec4:ST,mx_hsvtorgb:$w,mx_noise_float:fT,mx_noise_vec3:pT,mx_noise_vec4:mT,mx_ramplr:iT,mx_ramptb:aT,mx_rgbtohsv:eT,mx_safepower:uT,mx_splitlr:sT,mx_splittb:cT,mx_srgb_texture_to_lin_rec709:tT,mx_transform_uv:lT,mx_worley_noise_float:hT,mx_worley_noise_vec2:gT,mx_worley_noise_vec3:_T,namespace:Wf,negate:yd,neutralToneMapping:Lx,nodeArray:il,nodeImmutable:D,nodeObject:T,nodeObjects:rl,nodeProxy:E,normalFlat:gm,normalGeometry:mm,normalLocal:hm,normalMap:lh,normalView:_m,normalWorld:vm,normalize:cd,not:Mu,notEqual:Tu,numWorkgroups:dS,objectDirection:zp,objectGroup:cu,objectPosition:Vp,objectRadius:Wp,objectScale:Hp,objectViewPosition:Up,objectWorldMatrix:Bp,oneMinus:bd,or:ju,orthographicDepthToViewZ:o_,oscSawtooth:Zte,oscSine:Jte,oscSquare:Yte,oscTriangle:Xte,output:ql,outputStruct:Pte,overlay:ux,overloadingFn:hb,parabola:pb,parallaxDirection:ih,parallaxUV:ah,parameter:Ote,pass:Cx,passTexture:wx,pcurve:Rte,perspectiveDepthToViewZ:c_,pmremTexture:By,pointShadow:NC,pointUV:Sne,pointWidth:Xl,positionGeometry:im,positionLocal:am,positionPrevious:om,positionView:lm,positionViewDirection:um,positionWorld:sm,positionWorldDirection:cm,posterize:vx,pow:Rd,pow2:zd,pow3:Bd,pow4:Vd,premult:ax,property:Dl,radians:Qu,rand:Zd,range:cS,rangeFog:rS,rangeFogFactor:eS,reciprocal:wd,reference:Bm,referenceBuffer:Vm,reflect:Nd,reflectVector:jm,reflectView:km,reflector:lne,refract:Jd,refractVector:Mm,refractView:Am,reinhardToneMapping:kx,remainder:Wu,remap:Jf,remapClamp:Yf,renderGroup:su,renderOutput:tp,rendererReference:jf,rotate:Gy,rotateUV:Qte,roughness:jl,round:Cd,rtt:Pb,sRGBTransferEOTF:yf,sRGBTransferOETF:bf,sampler:vp,samplerComparison:yp,saturate:qd,saturation:fx,screen:lx,screenCoordinate:Ug,screenSize:Hg,screenUV:Vg,scriptable:Qx,scriptableValue:Jx,select:af,setCurrentStack:al,shaderStages:uc,shadow:CC,shadowPositionWorld:ZS,shapeCircle:Tne,sharedUniformGroup:au,sheen:Fl,sheenRoughness:Il,shiftLeft:Ru,shiftRight:zu,shininess:Kl,sign:_d,sin:ud,sinc:zte,skinning:bg,smoothstep:Yd,smoothstepElement:$d,specularColor:Wl,specularF90:Gl,spherizeUV:$te,split:xee,spritesheetUV:rne,sqrt:id,stack:lb,step:Md,storage:gg,storageBarrier:yS,storageObject:_g,storageTexture:Hb,string:yee,struct:Nte,sub:bu,subgroupIndex:rg,subgroupSize:hS,tan:fd,tangentGeometry:Wm,tangentLocal:Gm,tangentView:Km,tangentWorld:qm,temp:hf,texture:hp,texture3D:Kb,textureBarrier:bS,textureBicubic:Iv,textureCubeUV:hy,textureLoad:_p,textureSize:lp,textureStore:Ub,thickness:$l,time:gb,timerDelta:qte,timerGlobal:Kte,timerLocal:Gte,toneMapping:Nf,toneMappingExposure:Pf,toonOutlinePass:Dx,transformDirection:Hd,transformNormal:Sm,transformNormalToView:Cm,transformedBentNormalView:oh,transformedBitangentView:th,transformedBitangentWorld:nh,transformedClearcoatNormalView:xm,transformedNormalView:ym,transformedNormalWorld:bm,transformedTangentView:Jm,transformedTangentWorld:Ym,transmission:Ql,transpose:Dd,triNoise3D:Vte,triplanarTexture:ane,triplanarTextures:vb,trunc:Td,tslFn:Cee,uint:j,uniform:uu,uniformArray:wp,uniformCubeTexture:Lm,uniformGroup:iu,uniformTexture:gp,uniforms:Tp,unpremult:ox,userData:Jb,uv:sp,uvec2:fl,uvec3:hl,uvec4:yl,varying:_f,varyingProperty:Ol,vec2:M,vec3:N,vec4:_l,vectorComponents:dc,velocity:$b,vertexColor:w_,vertexIndex:tg,vertexStage:vf,vibrance:px,viewZToLogarithmicDepth:l_,viewZToOrthographicDepth:a_,viewZToPerspectiveDepth:s_,viewport:Wg,viewportBottomLeft:Xg,viewportCoordinate:Kg,viewportDepthTexture:r_,viewportLinearDepth:m_,viewportMipTexture:e_,viewportResolution:Jg,viewportSafeUV:tne,viewportSharedTexture:M_,viewportSize:Gg,viewportTexture:$g,viewportTopLeft:Yg,viewportUV:qg,wgsl:Vx,wgslFn:Kx,workgroupArray:CS,workgroupBarrier:vS,workgroupId:fS,workingToColorSpace:wf,xor:Nu});const TT=new sb;var ET=class extends Yy{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){let r=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(i===null)r._clearColor.getRGB(TT),TT.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(TT),TT.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;TT.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=lf(_l(a).mul(Bb),{getUV:()=>Vb.mul(vm),getTextureLevel:()=>zb}),t=$h;t=t.setZ(t.w);let r=new T_;r.name=`Background.material`,r.side=re,r.depthTest=!1,r.depthWrite=!1,r.allowOverride=!1,r.fog=!1,r.lights=!1,r.vertexNode=t,r.colorNode=e,n.backgroundMeshNode=e,n.backgroundMesh=o=new Ia(new Oo(1,32,32),r),o.frustumCulled=!1,o.name=`Background.mesh`,o.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)};function s(){i.removeEventListener(`dispose`,s),o.material.dispose(),o.geometry.dispose()}i.addEventListener(`dispose`,s)}let s=a.getCacheKey();n.backgroundCacheKey!==s&&(n.backgroundMeshNode.node=_l(a).mul(Bb),n.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,n.backgroundCacheKey=s),t.unshift(o,o.geometry,o.material,0,0,null,null)}else console.error(`THREE.Renderer: Unsupported background configuration.`,i);let o=r.xr.getEnvironmentBlendMode();if(o===`additive`?TT.set(0,0,0,1):o===`alpha-blend`&&TT.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=TT.r,e.g=TT.g,e.b=TT.b,e.a=TT.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}};let DT=0;var OT=class{constructor(e=``,t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=DT++}},kT=class{constructor(e,t,n,r,i,a,o,s,c,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=l,this.nodeAttributes=r,this.bindings=i,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=s,this.observer=c,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings){let n=t.bindings[0].groupNode.shared;if(n!==!0){let n=new OT(t.name,[],t.index,t);e.push(n);for(let e of t.bindings)n.bindings.push(e.clone())}else e.push(t)}return e}},AT=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},jT=class{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.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}},MT=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},NT=class extends MT{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},PT=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}};let FT=0;var IT=class{constructor(e=null){this.id=FT++,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)}},LT=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},RT=class{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}},zT=class extends RT{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},BT=class extends RT{constructor(e,t=new lr){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},VT=class extends RT{constructor(e,t=new C){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},HT=class extends RT{constructor(e,t=new Pr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},UT=class extends RT{constructor(e,t=new ra){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},WT=class extends RT{constructor(e,t=new Ls){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},GT=class extends RT{constructor(e,t=new pr){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},KT=class extends RT{constructor(e,t=new di){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},qT=class extends zT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},JT=class extends BT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},YT=class extends VT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},XT=class extends HT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},ZT=class extends UT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},QT=class extends WT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},$T=class extends GT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},eE=class extends KT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}};const tE=new WeakMap,nE=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),rE=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`));var iE=class{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=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.declarations={},this.flow={code:``},this.chaining=[],this.stack=lb(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new IT,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=tE.get(this.renderer);return e===void 0&&(e=new qy,tE.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Fr(e,t,n)}createCubeRenderTarget(e,t){return new z_(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){let n=this.getBindGroupsCache(),r=[],i=!0;for(let e of t)r.push(e),i&&=e.groupNode.shared!==!0;let a;return i?(a=n.get(r),a===void 0&&(a=new OT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new OT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){let n=this.bindings[t],r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){let t={},n=this.bindings;for(let e of uc)for(let r in n[e]){let i=n[e][r],a=t[r]||(t[r]=[]);a.push(...i)}for(let n in e=[],t){let r=t[n],i=this._getBindGroup(n,r);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let n=e[t];this.bindingsIndexes[n.name].group=t,n.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)))}addSequentialNode(e){this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(let e of this.nodes){let t=e.getUpdateType();t!==ac.NONE&&this.updateNodes.push(e.getSelf())}for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==ac.NONE&&this.updateBeforeNodes.push(e.getSelf()),n!==ac.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===rt||e.magFilter===it||e.magFilter===nt||e.magFilter===at||e.minFilter===rt||e.minFilter===it||e.minFilter===nt||e.minFilter===at}addChain(e){this.chaining.push(e)}removeChain(e){let t=this.chaining.pop();if(t!==e)throw 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){let n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new IT(t?this.getCache():null)),n.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){let 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.`)}generateArrayDeclaration(e,t){return this.getType(e)+`[ `+t+` ]`}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+`( `;for(let i=0;i<t;i++){let a=n?n[i]:null;a===null?r+=this.generateConst(e):r+=a.build(this,e),i<t-1&&(r+=`, `)}return r+=` )`,r}generateStruct(e,t,n=null){let r=[];for(let e of t){let{name:t,type:i}=e;n&&n[t]&&n[t].isNode?r.push(n[t].build(this,i)):r.push(this.generateConst(i))}return e+`( `+r.join(`, `)+` )`}generateConst(e,t=null){if(t===null&&(e===`float`||e===`int`||e===`uint`?t=0:e===`bool`?t=!1:e===`color`?t=new ra:e===`vec2`?t=new lr:e===`vec3`?t=new C:e===`vec4`&&(t=new Pr)),e===`float`)return rE(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`)}( ${rE(t.r)}, ${rE(t.g)}, ${rE(t.b)} )`;let n=this.getTypeLength(e),r=this.getComponentType(e),i=e=>this.generateConst(r,e);if(n===2)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)} )`;if(n===3)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)} )`;if(n===4&&e!==`mat2`)return`${this.getType(e)}( ${i(t.x)}, ${i(t.y)}, ${i(t.z)}, ${i(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(i).join(`, `)} )`;if(n>4)return`${this.getType(e)}()`;throw 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){let n=this.attributes;for(let t of n)if(t.name===e)return t;let r=new AT(e,t);return this.registerDeclaration(r),n.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===`samplerComparison`||e===`texture`||e===`cubeTexture`||e===`storageTexture`||e===`depthTexture`||e===`texture3D`}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===dt)return`int`;if(t===ft)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;let 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;let n=Js(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return nE.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);let n=t.array,r=e.itemSize,i=e.normalized,a;return!(e instanceof ha)&&i!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){let t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n===null?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:Number(n[1])}getVectorFromMatrix(e){return e.replace(`mat`,`vec`)}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return t===`int`||t===`uint`?e:this.changeComponentType(e,`int`)}addStack(){return this.stack=lb(this.stack),this.stacks.push(ol()||this.stack),al(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,al(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t=`any`){let n=this.getDataFromNode(e,t);return n.properties||={outputNode:null}}getBufferAttributeFromNode(e,t){let n=this.getDataFromNode(e),r=n.bufferAttribute;if(r===void 0){let i=this.uniforms.index++;r=new AT(`nodeAttribute`+i,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){let i=this.getDataFromNode(e,r,this.globalCache),a=i.structType;if(a===void 0){let e=this.structs.index++;n===null&&(n=`StructType`+e),a=new LT(n,t),this.structs[r].push(a),i.structType=a}return a}getOutputStructTypeFromNode(e,t){let n=this.getStructTypeFromNode(e,t,`OutputType`,`fragment`);return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){let i=this.getDataFromNode(e,n,this.globalCache),a=i.uniform;if(a===void 0){let o=this.uniforms.index++;a=new jT(r||`nodeUniform`+o,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),i.uniform=a}return a}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,i=!1){let a=this.getDataFromNode(e,r),o=a.variable;if(o===void 0){let s=i?`_const`:`_var`,c=this.vars[r]||(this.vars[r]=[]),l=this.vars[s]||(this.vars[s]=0);t===null&&(t=(i?`nodeConst`:`nodeVar`)+l,this.vars[s]++);let u=this.getArrayCount(e);o=new MT(t,n,i,u),i||c.push(o),this.registerDeclaration(o),a.variable=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,i=null){let a=this.getDataFromNode(e,`any`),o=a.varying;if(o===void 0){let e=this.varyings,s=e.length;t===null&&(t=`nodeVarying`+s),o=new NT(t,n,r,i),e.push(o),this.registerDeclaration(o),a.varying=o}return o}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace(`outputNode`)}getNamespace(e=``){let t=this.namespace,n;return n=t?e?t+`_`+e:t:e,n}registerDeclaration(e){let t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e),i=1,a=r;for(;n[a]!==void 0;)a=r+`_`+ i++;i>1&&(e.name=a,console.warn(`THREE.TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${a}'.`)),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){let r=this.getDataFromNode(e),i=r.code;if(i===void 0){let e=this.codes[n]||(this.codes[n]=[]),a=e.length;i=new PT(`nodeCode`+a,t),e.push(i),r.code=i}return i}addFlowCodeHierarchy(e,t){let{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e),i=!0,a=t;for(;a;){if(r.get(a)===!0){i=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(i)for(let e of n)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,n){let r=this.getDataFromNode(e),i=r.flowCodes||=[],a=r.flowCodeBlock||=new WeakMap;i.push(t),a.set(n,!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+=`;
64
+ `),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){let t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=new Ux,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){let t=e.layout,n={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(let e of t.inputs)n[e.name]=new cb(e.type,e.name);e.layout=null;let r=e.call(n),i=this.flowStagesNode(r,t.type);return e.layout=t,i}flowStagesNode(e,t=null){let n=this.flow,r=this.vars,i=this.declarations,a=this.cache,o=this.buildStage,s=this.stack,c={code:``};this.flow=c,this.vars={},this.declarations={},this.cache=new IT,this.stack=lb();for(let n of lc)this.setBuildStage(n),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=i,this.cache=a,this.stack=s,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){console.warn(`Abstract function.`)}flowChildNode(e,t=null){let n=this.flow,r={code:``};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){let i=this.tab,a=this.cache,o=this.shaderStage,s=this.context;this.setShaderStage(e);let c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=` `,this.context=c;let l=null;if(this.buildStage===`generate`){let i=this.flowChildNode(t,n);r!==null&&(i.code+=`${this.tab+r} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=i,this.context=s,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn(`Abstract function.`)}getVaryings(){console.warn(`Abstract function.`)}getVar(e,t,n=null){return`${n===null?this.getType(e):this.generateArrayDeclaration(e,n)} ${t}`}getVars(e){let t=``,n=this.vars[e];if(n!==void 0)for(let e of n)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn(`Abstract function.`)}getCodes(e){let t=this.codes[e],n=``;if(t!==void 0)for(let e of t)n+=e.code+`
65
+ `;return n}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(){let{object:e,material:t,renderer:n}=this;if(t!==null){let e=n.library.fromMaterial(t);e===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new T_),e.build(this)}else this.addFlow(`compute`,e);for(let e of lc){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.vertex);for(let t of uc){this.setShaderStage(t);let n=this.flowNodes[t];for(let t of n)e===`generate`?this.flowNode(t):t.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 qT(e);if(t===`vec2`||t===`ivec2`||t===`uvec2`)return new JT(e);if(t===`vec3`||t===`ivec3`||t===`uvec3`)return new YT(e);if(t===`vec4`||t===`ivec4`||t===`uvec4`)return new XT(e);if(t===`color`)return new ZT(e);if(t===`mat2`)return new QT(e);if(t===`mat3`)return new $T(e);if(t===`mat4`)return new eE(e);throw Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;let r=this.getTypeLength(t),i=this.getTypeLength(n);return r===16&&i===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&i===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||i>4||i===0?e:r===i?`${this.getType(n)}( ${e} )`:r>i?(e=n===`bool`?`all( ${e} )`:`${e}.${`xyz`.slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),n)):i===4&&r>1?`${this.getType(n)}( ${this.format(e,t,`vec3`)}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,`vec2`)}, 0.0 )`:(r===1&&i>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${v} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e=`NodeMaterial`){throw Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}},aE=class{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){let t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===ac.FRAME){let{frameMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&t.set(n,this.frameId)}else if(t===ac.RENDER){let{renderMap:t}=this._getMaps(this.updateBeforeMap,n);t.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&t.set(n,this.renderId)}else t===ac.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===ac.FRAME){let{frameMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&t.set(n,this.frameId)}else if(t===ac.RENDER){let{renderMap:t}=this._getMaps(this.updateAfterMap,n);t.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&t.set(n,this.renderId)}else t===ac.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===ac.FRAME){let{frameMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.frameId&&e.update(this)!==!1&&t.set(n,this.frameId)}else if(t===ac.RENDER){let{renderMap:t}=this._getMaps(this.updateMap,n);t.get(n)!==this.renderId&&e.update(this)!==!1&&t.set(n,this.renderId)}else t===ac.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}},oE=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};oE.isNodeFunctionInput=!0;var sE=class extends PC{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode,t=US(this.light);return{lightDirection:t,lightColor:e}}};const cE=new di,lE=new di;let uE=null;var dE=class extends PC{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=uu(new C).setGroup(su),this.halfWidth=uu(new C).setGroup(su),this.updateType=ac.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;lE.identity(),cE.copy(t.matrixWorld),cE.premultiply(n),lE.extractRotation(cE),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(lE),this.halfHeight.value.applyMatrix4(lE)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=hp(uE.LTC_FLOAT_1),n=hp(uE.LTC_FLOAT_2)):(t=hp(uE.LTC_HALF_1),n=hp(uE.LTC_HALF_2));let{colorNode:r,light:i}=this,a=HS(i);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){uE=e}},fE=class extends PC{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=uu(0).setGroup(su),this.penumbraCosNode=uu(0).setGroup(su),this.cutoffDistanceNode=uu(0).setGroup(su),this.decayExponentNode=uu(0).setGroup(su),this.colorNode=uu(this.color).setGroup(su)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:n,penumbraCosNode:r}=this;return Yd(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=zS(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){let{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:i}=this,a=this.getLightVector(e),o=a.normalize(),s=o.dot(US(i)),c=this.getSpotAttenuation(e,s),l=a.length(),u=FC({lightDistance:l,cutoffDistance:n,decayExponent:r}),d=t.mul(c).mul(u),f,p;if(i.colorNode?(p=this.getLightCoord(e),f=i.colorNode(p)):i.map&&(p=this.getLightCoord(e),f=hp(i.map,p.xy).onRenderUpdate(()=>i.map)),f){let e=p.mul(2).sub(1).abs().lessThan(1).all();d=e.select(d.mul(f),d)}return{lightColor:d,lightDirection:o}}},pE=class extends fE{static get type(){return`IESSpotLightNode`}getSpotAttenuation(e,t){let n=this.light.iesMap,r=null;if(n&&n.isTexture===!0){let e=t.acos().mul(1/Math.PI);r=hp(n,M(e,0),0).r}else r=super.getSpotAttenuation(t);return r}};const mE=O(([e,t])=>{let n=e.abs().sub(t);return vd(jd(n,0)).add(Ad(jd(n.x,n.y),0))});var hE=class extends fE{static get type(){return`ProjectorLightNode`}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let e=1;t.map!==null&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=this.penumbraCosNode,n=this.getLightCoord(e),r=n.xyz.div(n.w),i=mE(r.xy.sub(M(.5)),M(.5)),a=Su(-1,bu(1,md(t)).sub(1)),o=qd(i.mul(-2).mul(a));return o}},gE=class extends PC{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},_E=class extends PC{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=BS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=uu(new ra).setGroup(su)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,i=vm.dot(r),a=i.mul(.5).add(.5),o=Gd(n,t,a);e.context.irradiance.addAssign(o)}},vE=class extends PC{static get type(){return`LightProbeNode`}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new C);this.lightProbe=wp(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=wT(vm,this.lightProbe);e.context.irradiance.addAssign(t)}},yE=class{parseFunction(){console.warn(`Abstract function.`)}},bE=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};bE.isNodeFunction=!0;const xE=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,SE=/[a-z_0-9]+/gi,CE=`#pragma main`,wE=e=>{e=e.trim();let t=e.indexOf(CE),n=t===-1?e:e.slice(t+CE.length),r=n.match(xE);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=SE.exec(i))!==null;)a.push(o);let s=[],c=0;for(;c<a.length;){let e=a[c][0]===`const`;e===!0&&c++;let t=a[c][0];t===`in`||t===`out`||t===`inout`?c++:t=``;let n=a[c++][0],r=Number.parseInt(a[c][0]);Number.isNaN(r)===!1?c++:r=null;let i=a[c++][0];s.push(new oE(n,i,r,t,e))}let l=n.substring(r[0].length),u=r[3]===void 0?``:r[3],d=r[2],f=r[1]===void 0?``:r[1],p=t===-1?``:e.slice(0,t);return{type:d,inputs:s,name:u,precision:f,inputsCode:i,blockCode:l,headerCode:p}}else throw Error(`FunctionNode: Function is not a GLSL code.`)};var TE=class extends bE{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=wE(e);super(t,n,r,i),this.inputsCode=a,this.blockCode=o,this.headerCode=s}getCode(e=this.name){let t,n=this.blockCode;if(n!==``){let{type:r,inputsCode:i,headerCode:a,precision:o}=this,s=`${r} ${e} ( ${i.trim()} )`;o!==``&&(s=`${o} ${s}`),t=a+s+n}else t=``;return t}},EE=class extends yE{parseFunction(e){return new TE(e)}};const DE=new WeakMap,OE=[],kE=[];var AE=class extends Yy{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new aE,this.nodeBuilderCache=new Map,this.callHashCache=new qy,this.groupsData=new qy,this.cacheLib={}}updateGroup(e){let t=e.groupNode,n=t.name;if(n===cu.name)return!0;if(n===su.name){let t=this.get(e),n=this.nodeFrame.renderId;return t.renderId===n?!1:(t.renderId=n,!0)}if(n===ou.name){let t=this.get(e),n=this.nodeFrame.frameId;return t.frameId===n?!1:(t.frameId=n,!0)}OE[0]=t,OE[1]=e;let r=this.groupsData.get(OE);return r===void 0&&this.groupsData.set(OE,r={}),OE.length=0,r.version===t.version?!1:(r.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0){let{nodeBuilderCache:r}=this,i=this.getForRenderCacheKey(e);if(n=r.get(i),n===void 0){let t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&t.enableMultiview(),t.build(),n=this._createNodeBuilderState(t),r.set(i,n)}n.usedTimes++,t.nodeBuilderState=n}return n}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){let t=this.get(e),n=t.nodeBuilderState;if(n===void 0){let r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new kT(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){OE[0]=e,OE[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(OE)||{};if(r.callId!==n){let i=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&kE.push(t.getCacheKey(!0)),i&&kE.push(i.getCacheKey()),a&&kE.push(a.getCacheKey()),kE.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),kE.push(this.renderer.shadowMap.enabled?1:0),r.callId=n,r.cacheKey=Hs(kE),this.callHashCache.set(OE,r),kE.length=0}return OE.length=0,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),n=e.background;if(n){let r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){let i=this.getCacheNode(`background`,n,()=>{if(n.isCubeTexture===!0||n.mapping===Je||n.mapping===Ye||n.mapping===Xe){if(e.backgroundBlurriness>0||n.mapping===Xe)return By(n);{let e;return e=n.isCubeTexture===!0?Im(n):hp(n),G_(e)}}else if(n.isTexture===!0)return hp(n,Vg.flipY()).setUpdateMatrix(!0);else n.isColor!==!0&&console.error(`WebGPUNodes: Unsupported background configuration.`,n)},r);t.backgroundNode=i,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){let i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),a=i.get(t);return(a===void 0||r)&&(a=n(),i.set(t,a)),a}updateFog(e){let t=this.get(e),n=e.fog;if(n){if(t.fog!==n){let e=this.getCacheNode(`fog`,n,()=>{if(n.isFogExp2){let e=Bm(`color`,`color`,n).setGroup(su),t=Bm(`density`,`float`,n).setGroup(su);return nS(e,tS(t))}else if(n.isFog){let e=Bm(`color`,`color`,n).setGroup(su),t=Bm(`near`,`float`,n).setGroup(su),r=Bm(`far`,`float`,n).setGroup(su);return nS(e,eS(t,r))}else console.error(`THREE.Renderer: Unsupported fog configuration.`,n)});t.fogNode=e,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){let t=this.get(e),n=e.environment;if(n){if(t.environment!==n){let e=this.getCacheNode(`environment`,n,()=>{if(n.isCubeTexture===!0)return Im(n);if(n.isTexture===!0)return hp(n);console.error(`Nodes: Unsupported environment configuration.`,n)});t.environmentNode=e,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,i=null){let a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=i,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+`,`+e.currentColorSpace+`,`+e.xr.isPresenting}hasOutputChange(e){let t=DE.get(e);return t!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?Kb(e,N(Vg,Dp(`gl_ViewID_OVR`))).renderOutput(t.toneMapping,t.currentColorSpace):hp(e,Vg).renderOutput(t.toneMapping,t.currentColorSpace);return DE.set(e,n),r}updateBefore(e){let t=e.getNodeBuilderState();for(let n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){let t=e.getNodeBuilderState();for(let n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){let t=this.getNodeFrame(),n=this.getForCompute(e);for(let e of n.updateNodes)t.updateNode(e)}updateForRender(e){let t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(let e of n.updateNodes)t.updateNode(e)}needsRefresh(e){let t=this.getNodeFrameForRender(e),n=e.getMonitor();return n.needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new aE,this.nodeBuilderCache=new Map,this.cacheLib={}}};const jE=new ho;var ME=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewNormalMatrix=new pr,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){let r=e.length;for(let i=0;i<r;i++){jE.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=jE.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=jE.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let r=t.clippingPlanes,i=r.length,a,o;if(this.clipIntersection?(a=this.intersectionPlanes,o=e.intersectionPlanes.length):(a=this.unionPlanes,o=e.unionPlanes.length),a.length!==o+i){a.length=o+i;for(let e=0;e<i;e++)a[o+e]=new Pr;n=!0}this.projectPlanes(r,a,o),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(t){if(this.shadowPass&&!t.clipShadows)return this;let n=this.clippingGroupContexts.get(t);return n===void 0&&(n=new e(this),this.clippingGroupContexts.set(t,n)),n.update(this,t),n}get unionClippingCount(){return this.unionPlanes.length}},NE=class{constructor(e,t){this.bundleGroup=e,this.camera=t}};const PE=[];var FE=class{constructor(){this.bundles=new qy}get(e,t){let n=this.bundles;PE[0]=e,PE[1]=t;let r=n.get(PE);return r===void 0&&(r=new NE(e,t),n.set(PE,r)),PE.length=0,r}dispose(){this.bundles=new qy}},IE=class{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,n=this.getMaterialNodeClass(e.type);if(n!==null)for(let r in t=new n,e)t[r]=e[r];return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t==`function`||typeof t==`object`)throw Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!=`function`)throw Error(`Node class ${e.name} is not a class.`);if(typeof t!=`function`)throw Error(`Base class ${t.name} is not a class.`);n.set(t,e)}};const LE=new JS,RE=[];var zE=class extends qy{constructor(){super()}createNode(e=[]){return new JS().setLights(e)}getNode(e,t){if(e.isQuadMesh)return LE;RE[0]=e,RE[1]=t;let n=this.get(RE);return n===void 0&&(n=this.createNode(),this.set(RE,n)),RE.length=0,n}},BE=class extends Fr{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this.hasExternalTextures=!1,this.autoAllocateDepthBuffer=!0}copy(e){return super.copy(e),this.hasExternalTextures=e.hasExternalTextures,this.autoAllocateDepthBuffer=e.autoAllocateDepthBuffer,this}};const VE=new C,HE=new C;var UE=class extends Kn{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Ya,this._cameraL.viewport=new Pr,this._cameraR=new Ya,this._cameraR.viewport=new Pr,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Cs,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._supportsLayers=!1,this._frameBufferTargets=null,this._createXRLayer=XE.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new lr,this._onSessionEvent=qE.bind(this),this._onSessionEnd=JE.bind(this),this._onInputSourcesChange=YE.bind(this),this._onAnimationFrame=ZE.bind(this),this._referenceSpace=null,this._referenceSpaceType=`local-floor`,this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._useLayers=typeof XRWebGLBinding<`u`&&`createProjectionLayer`in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){let t=this._getController(e);return t.getTargetRaySpace()}getControllerGrip(e){let t=this._getController(e);return t.getGripSpace()}getHand(e){let t=this._getController(e);return t.getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&console.warn(`THREE.XRManager: Cannot change framebuffer scale while presenting.`)}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&console.warn(`THREE.XRManager: Cannot change reference space type while presenting.`)}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,r,i,a,o,s={}){let c=new Do(e,t),l=new BE(i,a,{format:bt,type:st,depthTexture:new To(i,a,s.stencil?_t:ft,void 0,void 0,void 0,void 0,void 0,void 0,s.stencil?St:xt),stencilBuffer:s.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});l.autoAllocateDepthBuffer=!0;let u=new oa({color:16777215,side:ne});u.map=l.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new Ia(c,u);d.position.copy(n),d.quaternion.copy(r);let f={type:`quad`,width:e,height:t,translation:n,quaternion:r,pixelwidth:i,pixelheight:a,plane:d,material:u,rendercall:o,renderTarget:l};if(this._layers.push(f),this._session!==null){f.plane.material=new oa({color:16777215,side:ne}),f.plane.material.blending=ue,f.plane.material.blendEquation=de,f.plane.material.blendSrc=ge,f.plane.material.blendDst=ge,f.xrlayer=this._createXRLayer(f);let e=this._session.renderState.layers;e.unshift(f.xrlayer),this._session.updateRenderState({layers:e})}else l.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,n,r,i,a,o,s,c={}){let l=new Eo(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new BE(a,o,{format:bt,type:st,depthTexture:new To(a,o,c.stencil?_t:ft,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?St:xt),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u.autoAllocateDepthBuffer=!0;let d=new oa({color:16777215,side:re});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new Ia(l,d);f.position.copy(r),f.quaternion.copy(i);let p={type:`cylinder`,radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:i,pixelwidth:a,pixelheight:o,plane:f,material:d,rendercall:s,renderTarget:u};if(this._layers.push(p),this._session!==null){p.plane.material=new oa({color:16777215,side:re}),p.plane.material.blending=ue,p.plane.material.blendEquation=de,p.plane.material.blendSrc=ge,p.plane.material.blendDst=ge,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return f}renderLayers(){let e=new C,t=new ur,n=this._renderer,r=this.isPresenting,i=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;let o=new lr;n.getSize(o);let s=n._quad;for(let r of this._layers)if(r.renderTarget.isXRRenderTarget=this._session!==null,r.renderTarget.hasExternalTextures=r.renderTarget.isXRRenderTarget,r.renderTarget.isXRRenderTarget&&this._supportsLayers){r.xrlayer.transform=new XRRigidTransform(r.plane.getWorldPosition(e),r.plane.getWorldQuaternion(t));let i=this._glBinding.getSubImage(r.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(r.renderTarget,i.colorTexture,void 0),n._setXRLayerSize(r.renderTarget.width,r.renderTarget.height),n.setOutputRenderTarget(r.renderTarget),n.setRenderTarget(null),n._frameBufferTarget=null,this._frameBufferTargets||=new WeakMap;let{frameBufferTarget:a,quad:o}=this._frameBufferTargets.get(r.renderTarget)||{frameBufferTarget:null,quad:null};a?(n._frameBufferTarget=a,n._quad=o):(n._quad=new Nb(new T_),this._frameBufferTargets.set(r.renderTarget,{frameBufferTarget:n._getFrameBufferTarget(),quad:n._quad})),r.rendercall(),n._frameBufferTarget=null}else n.setRenderTarget(r.renderTarget),r.rendercall();n.setRenderTarget(null),n.setOutputRenderTarget(i),n._frameBufferTarget=a,n._setXRLayerSize(o.x,o.y),n._quad=s,this.isPresenting=r}getSession(){return this._session}async setSession(e){let t=this._renderer,n=t.backend;this._gl=t.getContext();let r=this._gl,i=r.getContextAttributes();if(this._session=e,e!==null){if(n.isWebGPUBackend===!0)throw Error(`THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.`);if(e.addEventListener(`select`,this._onSessionEvent),e.addEventListener(`selectstart`,this._onSessionEvent),e.addEventListener(`selectend`,this._onSessionEvent),e.addEventListener(`squeeze`,this._onSessionEvent),e.addEventListener(`squeezestart`,this._onSessionEvent),e.addEventListener(`squeezeend`,this._onSessionEvent),e.addEventListener(`end`,this._onSessionEnd),e.addEventListener(`inputsourceschange`,this._onInputSourcesChange),await n.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._useLayers===!0){let n=null,a=null,o=null;t.depth&&(o=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,n=t.stencil?St:xt,a=t.stencil?_t:ft);let s={colorFormat:r.RGBA8,depthFormat:o,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature(`OVR_multiview2`)&&(s.textureType=`texture-array`,this._useMultiview=!0);let c=new XRWebGLBinding(e,r),l=c.createProjectionLayer(s),u=[l];this._glBinding=c,this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);let d=this._useMultiview?2:1,f=new To(l.textureWidth,l.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n,d);if(this._xrRenderTarget=new BE(l.textureWidth,l.textureHeight,{format:bt,type:st,colorSpace:t.outputColorSpace,depthTexture:f,stencilBuffer:t.stencil,samples:i.antialias?4:0,resolveDepthBuffer:l.ignoreDepthValues===!1,resolveStencilBuffer:l.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget.hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._supportsLayers=e.enabledFeatures.includes(`layers`),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._supportsLayers)for(let e of this._layers)e.plane.material=new oa({color:16777215,side:e.type===`cylinder`?re:ne}),e.plane.material.blending=ue,e.plane.material.blendEquation=de,e.plane.material.blendSrc=ge,e.plane.material.blendDst=ge,e.xrlayer=this._createXRLayer(e),u.unshift(e.xrlayer);e.updateRenderState({layers:u})}else{let n={antialias:t.samples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,n);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new BE(i.framebufferWidth,i.framebufferHeight,{format:bt,type:st,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:i.ignoreDepthValues===!1,resolveStencilBuffer:i.ignoreDepthValues===!1}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:`sessionstart`})}}updateCamera(e){let t=this._session;if(t===null)return;let n=e.near,r=e.far,i=this._cameraXR,a=this._cameraL,o=this._cameraR;i.near=o.near=a.near=n,i.far=o.far=a.far=r,i.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==i.near||this._currentDepthFar!==i.far)&&(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),a.layers.mask=e.layers.mask|2,o.layers.mask=e.layers.mask|4,i.layers.mask=a.layers.mask|o.layers.mask;let s=e.parent,c=i.cameras;GE(i,s);for(let e=0;e<c.length;e++)GE(c[e],s);c.length===2?WE(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),KE(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new ro,this._controllers[e]=t),t}};function WE(e,t,n){VE.setFromMatrixPosition(t.matrixWorld),HE.setFromMatrixPosition(n.matrixWorld);let r=VE.distanceTo(HE),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function GE(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function KE(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Xn*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function qE(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(t===-1)return;let n=this._controllers[t];if(n!==void 0){let t=this.getReferenceSpace();n.update(e.inputSource,e.frame,t),n.dispatchEvent({type:e.type,data:e.inputSource})}}function JE(){let e=this._session,t=this._renderer;e.removeEventListener(`select`,this._onSessionEvent),e.removeEventListener(`selectstart`,this._onSessionEvent),e.removeEventListener(`selectend`,this._onSessionEvent),e.removeEventListener(`squeeze`,this._onSessionEvent),e.removeEventListener(`squeezestart`,this._onSessionEvent),e.removeEventListener(`squeezeend`,this._onSessionEvent),e.removeEventListener(`end`,this._onSessionEnd),e.removeEventListener(`inputsourceschange`,this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){let t=this._controllerInputSources[e];t!==null&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,this._supportsLayers===!0)for(let e of this._layers)e.renderTarget=new BE(e.pixelwidth,e.pixelheight,{format:bt,type:st,depthTexture:new To(e.pixelwidth,e.pixelheight,e.stencilBuffer?_t:ft,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?St:xt),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:`sessionend`})}function YE(e){let t=this._controllers,n=this._controllerInputSources;for(let r=0;r<e.removed.length;r++){let i=e.removed[r],a=n.indexOf(i);a>=0&&(n[a]=null,t[a].disconnect(i))}for(let r=0;r<e.added.length;r++){let i=e.added[r],a=n.indexOf(i);if(a===-1){for(let e=0;e<t.length;e++)if(e>=n.length){n.push(i),a=e;break}else if(n[e]===null){n[e]=i,a=e;break}if(a===-1)break}let o=t[a];o&&o.connect(i)}}function XE(e){return e.type===`quad`?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function ZE(e,t){if(t===void 0)return;let n=this._cameraXR,r=this._renderer,i=r.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),s=t.getViewerPose(o);if(this._xrFrame=t,s!==null){let e=s.views;this._glBaseLayer!==null&&i.setXRTarget(a.framebuffer);let t=!1;e.length!==n.cameras.length&&(n.cameras.length=0,t=!0);for(let r=0;r<e.length;r++){let o=e[r],s;if(this._useLayers===!0){let e=this._glBinding.getViewSubImage(this._glProjLayer,o);s=e.viewport,r===0&&i.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else s=a.getViewport(o);let c=this._cameras[r];c===void 0&&(c=new Ya,c.layers.enable(r),c.viewport=new Pr,this._cameras[r]=c),c.matrix.fromArray(o.transform.matrix),c.matrix.decompose(c.position,c.quaternion,c.scale),c.projectionMatrix.fromArray(o.projectionMatrix),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),c.viewport.set(s.x,s.y,s.width,s.height),r===0&&(n.matrix.copy(c.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),t===!0&&n.cameras.push(c)}r.setOutputRenderTarget(this._xrRenderTarget)}for(let e=0;e<this._controllers.length;e++){let n=this._controllerInputSources[e],r=this._controllers[e];n!==null&&r!==void 0&&r.update(n,t,o)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:`planesdetected`,data:t}),this._xrFrame=null}const QE=new io,$E=new lr,eD=new Pr,tD=new vo,nD=new xo,rD=new di,iD=new Pr;var aD=class{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:n=!1,alpha:r=!0,depth:i=!0,stencil:a=!1,antialias:o=!1,samples:s=0,getFallback:c=null,colorBufferType:l=mt,multiview:u=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=s||o===!0?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=r,this.logarithmicDepthBuffer=n,this.outputColorSpace=hn,this.toneMapping=Re,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=i,this.stencil=a,this.info=new fte,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new IE,this.lighting=new zE,this._getFallback=c,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Pr(0,0,this._width,this._height),this._scissor=new Pr(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new Nb(new T_),this._quad.material.name=`Renderer_output`,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;let d=this.alpha===!0?0:1;this._clearColor=new sb(0,0,0,d),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=l,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:ee},this.xr=new UE(this,u),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,n)=>{await this.compileAsync(e,t);let r=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),a=e.overrideMaterial||n.material,o=this._objects.get(n,a,e,t,r.lightsNode,i,i.clippingContext),{fragmentShader:s,vertexShader:c}=o.getNodeBuilderState();return{fragmentShader:s,vertexShader:c}}}}async init(){if(this._initialized)throw Error(`Renderer: Backend has already been initialized.`);return this._initPromise===null&&(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(e){if(this._getFallback!==null)try{this.backend=n=this._getFallback(e),await n.init(this)}catch(e){t(e);return}else{t(e);return}}this._nodes=new AE(this,n),this._animation=new rte(this._nodes,this.info),this._attributes=new ute(n),this._background=new ET(this,this._nodes),this._geometries=new dte(this._attributes,this.info),this._textures=new Dte(this,n,this.info),this._pipelines=new gte(n,this._nodes),this._bindings=new _te(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new ste(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new bte(this.lighting),this._bundles=new FE,this._renderContexts=new Tte,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();let r=this._nodes.nodeFrame,i=r.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,s=this._compilationPromises,c=e.isScene===!0?e:QE;n===null&&(n=e);let l=this._renderTarget,u=this._renderContexts.get(n,t,l),d=this._activeMipmapLevel,f=[];this._currentRenderContext=u,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=f,r.renderId++,r.update(),u.depth=this.depth,u.stencil=this.stencil,u.clippingContext||=new ME,u.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,l);let p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,u.clippingContext),n!==e&&n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)}),p.finish(),l!==null){this._textures.updateRenderTarget(l,d);let e=this._textures.get(l);u.textures=e.textures,u.depthTexture=e.depthTexture}else u.textures=null,u.depthTexture=null;this._background.update(c,p,u);let m=p.opaque,h=p.transparent,g=p.transparentDoublePass,_=p.lightsNode;this.opaque===!0&&m.length>0&&this._renderObjects(m,t,c,_),this.transparent===!0&&h.length>0&&this._renderTransparents(h,g,t,c,_),r.renderId=i,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._compilationPromises=s,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(f)}async renderAsync(e,t){this._initialized===!1&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=nm,this.overrideNodes.modelNormalViewMatrix=rm):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===nm&&this.overrideNodes.modelNormalViewMatrix===rm}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){let{bundleGroup:r,camera:i,renderList:a}=e,o=this._currentRenderContext,s=this._bundles.get(r,i),c=this.backend.get(s);c.renderContexts===void 0&&(c.renderContexts=new Set);let l=r.version!==c.version,u=c.renderContexts.has(o)===!1||l;if(c.renderContexts.add(o),u){this.backend.beginBundle(o),(c.renderObjects===void 0||l)&&(c.renderObjects=[]),this._currentRenderBundle=s;let{transparentDoublePass:e,transparent:u,opaque:d}=a;this.opaque===!0&&d.length>0&&this._renderObjects(d,i,t,n),this.transparent===!0&&u.length>0&&this._renderTransparents(u,e,i,t,n),this._currentRenderBundle=null,this.backend.finishBundle(o,s),c.version=r.version}else{let{renderObjects:e}=c;for(let t=0,n=e.length;t<n;t++){let n=e[t];this._nodes.needsRefresh(n)&&(this._nodes.updateBefore(n),this._nodes.updateForRender(n),this._bindings.updateForRender(n),this._nodes.updateAfter(n))}}this.backend.addBundle(o,s)}render(e,t){if(this._initialized===!1)return console.warn(`THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead.`),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,n=e!==Re,r=t!==gn;if(n===!1&&r===!1)return null;let{width:i,height:a}=this.getDrawingBufferSize($E),{depth:o,stencil:s}=this,c=this._frameBufferTarget;c===null&&(c=new Fr(i,a,{depthBuffer:o,stencilBuffer:s,type:this._colorBufferType,format:bt,colorSpace:gn,generateMipmaps:!1,minFilter:rt,magFilter:rt,samples:this.samples}),c.isPostProcessingRenderTarget=!0,this._frameBufferTarget=c);let l=this.getOutputRenderTarget();return c.depthBuffer=o,c.stencilBuffer=s,l===null?c.setSize(i,a,1):c.setSize(l.width,l.height,l.depth),c.viewport.copy(this._viewport),c.scissor.copy(this._scissor),c.viewport.multiplyScalar(this._pixelRatio),c.scissor.multiplyScalar(this._pixelRatio),c.scissorTest=this._scissorTest,c.multiview=l===null?!1:l.multiview,c.resolveDepthBuffer=l===null?!0:l.resolveDepthBuffer,c.autoAllocateDepthBuffer=l===null?!1:l.autoAllocateDepthBuffer,c}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;let r=n?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,a=i.renderId,o=this._currentRenderContext,s=this._currentRenderObjectFunction,c=e.isScene===!0?e:QE,l=this._renderTarget||this._outputRenderTarget,u=this._activeCubeFace,d=this._activeMipmapLevel,f;r===null?f=l:(f=r,this.setRenderTarget(f));let p=this._renderContexts.get(e,t,f);this._currentRenderContext=p,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls;let m=this.coordinateSystem,h=this.xr;if(t.coordinateSystem!==m&&h.isPresenting===!1&&(t.coordinateSystem=m,t.updateProjectionMatrix(),t.isArrayCamera))for(let e of t.cameras)e.coordinateSystem=m,e.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),h.enabled===!0&&h.isPresenting===!0&&(h.cameraAutoUpdate===!0&&h.updateCamera(t),t=h.getCamera());let g=this._viewport,_=this._scissor,v=this._pixelRatio;f!==null&&(g=f.viewport,_=f.scissor,v=1),this.getDrawingBufferSize($E),eD.set(0,0,$E.width,$E.height);let y=g.minDepth===void 0?0:g.minDepth,b=g.maxDepth===void 0?1:g.maxDepth;p.viewportValue.copy(g).multiplyScalar(v).floor(),p.viewportValue.width>>=d,p.viewportValue.height>>=d,p.viewportValue.minDepth=y,p.viewportValue.maxDepth=b,p.viewport=p.viewportValue.equals(eD)===!1,p.scissorValue.copy(_).multiplyScalar(v).floor(),p.scissor=this._scissorTest&&p.scissorValue.equals(eD)===!1,p.scissorValue.width>>=d,p.scissorValue.height>>=d,p.clippingContext||=new ME,p.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,f);let x=t.isArrayCamera?nD:tD;t.isArrayCamera||(rD.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(rD,m));let S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,p.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort),f!==null){this._textures.updateRenderTarget(f,d);let e=this._textures.get(f);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=f,p.depth=f.depthBuffer,p.stencil=f.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=d,p.height>>=d,p.activeCubeFace=u,p.activeMipmapLevel=d,p.occlusionQueryCount=S.occlusionQueryCount,this._background.update(c,S,p),p.camera=t,this.backend.beginRender(p);let{bundles:ee,lightsNode:te,transparentDoublePass:ne,transparent:re,opaque:ie}=S;return ee.length>0&&this._renderBundles(ee,c,te),this.opaque===!0&&ie.length>0&&this._renderObjects(ie,t,c,te),this.transparent===!0&&re.length>0&&this._renderTransparents(re,ne,t,c,te),this.backend.finishRender(p),i.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=s,r!==null&&(this.setRenderTarget(l,u,d),this._renderOutput(f)),c.onAfterRender(this,e,t,f),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);let n=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+`px`,this.domElement.style.height=t+`px`),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){let i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,i=0,a=1){let o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,n,r),o.minDepth=i,o.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn(`THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead.`),this.clearAsync(e,t,n);let r=this._renderTarget||this._getFrameBufferTarget(),i=null;if(r!==null){this._textures.updateRenderTarget(r);let e=this._textures.get(r);i=this._renderContexts.getForClear(r),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=r,i.depth=r.depthBuffer,i.stencil=r.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,i),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Re}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:gn}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()}),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return console.warn(`THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.`),this.computeAsync(e);let t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;let r=this.backend,i=this._pipelines,a=this._bindings,o=this._nodes,s=Array.isArray(e)?e:[e];if(s[0]===void 0||s[0].isComputeNode!==!0)throw Error(`THREE.Renderer: .compute() expects a ComputeNode.`);r.beginCompute(e);for(let t of s){if(i.has(t)===!1){let e=()=>{t.removeEventListener(`dispose`,e),i.delete(t),a.delete(t),o.delete(t)};t.addEventListener(`dispose`,e);let n=t.onInitFunction;n!==null&&n.call(t,{renderer:this})}o.updateForCompute(t),a.updateForCompute(t);let n=a.getForCompute(t),s=i.getForCompute(t,n);r.compute(e,t,n,s)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e=`render`){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return this._initialized===!1?(console.warn(`THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead.`),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn(`THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead.`),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=iD.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=iD.copy(t).floor();else{console.error(`THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=iD.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n===null?(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))):r=n.renderTarget,this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,i,a)}async readRenderTargetPixelsAsync(e,t,n,r,i,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,i,o)}_projectObject(e,t,n,r,i){if(e.visible===!1)return;let a=e.layers.test(t.layers);if(a){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){let a=t.isArrayCamera?nD:tD;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&iD.setFromMatrixPosition(e.matrixWorld).applyMatrix4(rD);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,iD.z,null,i)}}else if(e.isLineLoop)console.error(`THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.`);else if(e.isMesh||e.isLine||e.isPoints){let a=t.isArrayCamera?nD:tD;if(!e.frustumCulled||a.intersectsObject(e,t)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),iD.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(rD)),Array.isArray(a)){let o=t.groups;for(let s=0,c=o.length;s<c;s++){let c=o[s],l=a[c.materialIndex];l&&l.visible&&r.push(e,t,l,n,iD.z,c,i)}}else a.visible&&r.push(e,t,a,n,iD.z,null,i)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){let n=r;r=this._renderLists.get(e,t),r.begin(),n.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}let o=e.children;for(let e=0,a=o.length;e<a;e++)this._projectObject(o[e],t,n,r,i)}_renderBundles(e,t,n){for(let r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,i){if(t.length>0){for(let{material:e}of t)e.side=re;this._renderObjects(t,n,r,i,`backSide`);for(let{material:e}of t)e.side=ne;this._renderObjects(e,n,r,i);for(let{material:e}of t)e.side=ie}else this._renderObjects(e,n,r,i)}_renderObjects(e,t,n,r,i=null){for(let a=0,o=e.length;a<o;a++){let{object:o,geometry:s,material:c,group:l,clippingContext:u}=e[a];this._currentRenderObjectFunction(o,n,t,s,c,l,r,u,i)}}renderObject(e,t,n,r,i,a,o,s=null,c=null){let l,u,d;if(e.onBeforeRender(this,t,n,r,i,a),i.allowOverride===!0&&t.overrideMaterial!==null){let e=t.overrideMaterial;i.positionNode&&i.positionNode.isNode&&(l=e.positionNode,e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0,e.isShadowPassMaterial&&(e.side=i.shadowSide===null?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(d=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(u=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}i.transparent===!0&&i.side===ie&&i.forceSinglePass===!1?(i.side=re,this._handleObjectFunction(e,i,t,n,o,a,s,`backSide`),i.side=ne,this._handleObjectFunction(e,i,t,n,o,a,s,c),i.side=ie):this._handleObjectFunction(e,i,t,n,o,a,s,c),l!==void 0&&(t.overrideMaterial.positionNode=l),d!==void 0&&(t.overrideMaterial.depthNode=d),u!==void 0&&(t.overrideMaterial.colorNode=u),e.onAfterRender(this,t,n,r,i,a)}_renderObjectDirect(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a;let l=this._nodes.needsRefresh(c);if(l&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._currentRenderBundle!==null){let e=this.backend.get(this._currentRenderBundle);e.renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(c,this.info),l&&this._nodes.updateAfter(c)}_createObjectPipeline(e,t,n,r,i,a,o,s){let c=this._objects.get(e,t,n,r,i,this._currentRenderContext,o,s);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}get compile(){return this.compileAsync}},oD=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}};function sD(e){return e+(Zy-e%Zy)%Zy}var cD=class extends oD{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return sD(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},lD=class extends cD{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}};let uD=0;var dD=class extends lD{constructor(e,t){super(`UniformBuffer_`+ uD++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}},fD=class extends lD{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){let t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=this.bytesPerElement,t=0;for(let n=0,r=this.uniforms.length;n<r;n++){let r=this.uniforms[n],i=r.boundary,a=r.itemSize*e,o=t%Zy,s=o%i,c=o+s;t+=s,c!==0&&Zy-c<a&&(t+=Zy-c),r.offset=t/e,t+=a}return Math.ceil(t/Zy)*Zy}update(){let e=!1;for(let t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);console.error(`THREE.WebGPUUniformsGroup: Unsupported uniform type.`,e)}updateNumber(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i]!==r){let e=this._getBufferForType(a);e[i]=n[i]=r,t=!0}return t}updateVector2(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y){let e=this._getBufferForType(a);e[i+0]=n[i+0]=r.x,e[i+1]=n[i+1]=r.y,t=!0}return t}updateVector3(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z){let e=this._getBufferForType(a);e[i+0]=n[i+0]=r.x,e[i+1]=n[i+1]=r.y,e[i+2]=n[i+2]=r.z,t=!0}return t}updateVector4(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset,a=e.getType();if(n[i+0]!==r.x||n[i+1]!==r.y||n[i+2]!==r.z||n[i+4]!==r.w){let e=this._getBufferForType(a);e[i+0]=n[i+0]=r.x,e[i+1]=n[i+1]=r.y,e[i+2]=n[i+2]=r.z,e[i+3]=n[i+3]=r.w,t=!0}return t}updateColor(e){let t=!1,n=this.values,r=e.getValue(),i=e.offset;if(n[i+0]!==r.r||n[i+1]!==r.g||n[i+2]!==r.b){let e=this.buffer;e[i+0]=n[i+0]=r.r,e[i+1]=n[i+1]=r.g,e[i+2]=n[i+2]=r.b,t=!0}return t}updateMatrix3(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;if(n[i+0]!==r[0]||n[i+1]!==r[1]||n[i+2]!==r[2]||n[i+4]!==r[3]||n[i+5]!==r[4]||n[i+6]!==r[5]||n[i+8]!==r[6]||n[i+9]!==r[7]||n[i+10]!==r[8]){let e=this.buffer;e[i+0]=n[i+0]=r[0],e[i+1]=n[i+1]=r[1],e[i+2]=n[i+2]=r[2],e[i+4]=n[i+4]=r[3],e[i+5]=n[i+5]=r[4],e[i+6]=n[i+6]=r[5],e[i+8]=n[i+8]=r[6],e[i+9]=n[i+9]=r[7],e[i+10]=n[i+10]=r[8],t=!0}return t}updateMatrix4(e){let t=!1,n=this.values,r=e.getValue().elements,i=e.offset;if(mD(n,r,i)===!1){let e=this.buffer;e.set(r,i),pD(n,r,i),t=!0}return t}_getBufferForType(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`?new Int32Array(this.buffer.buffer):e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`?new Uint32Array(this.buffer.buffer):this.buffer}};function pD(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function mD(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}let hD=0;var gD=class extends fD{constructor(e,t){super(e),this.id=hD++,this.groupNode=t,this.isNodeUniformsGroup=!0}};let _D=0;var vD=class extends oD{constructor(e,t){super(e),this.id=_D++,this.texture=t,this.version=t?t.version:0,this.store=!1,this.generation=null,this.isSampledTexture=!0}needsBindingsUpdate(e){let{texture:t}=this;return e===this.generation?t.isVideoTexture:(this.generation=e,!0)}update(){let{texture:e,version:t}=this;return t===e.version?!1:(this.version=e.version,!0)}},yD=class extends vD{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}needsBindingsUpdate(e){return this.textureNode.value!==this.texture||super.needsBindingsUpdate(e)}update(){let{textureNode:e}=this;return this.texture===e.value?super.update():(this.texture=e.value,!0)}},bD=class extends yD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},xD=class extends yD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}};const SD={textureDimensions:`textureSize`,equals:`equal`},CD={low:`lowp`,medium:`mediump`,high:`highp`},wD={swizzleAssign:!0,storageBuffer:!1},TD={perspective:`smooth`,linear:`noperspective`},ED={centroid:`centroid`,"flat first":`flat`,"flat either":`flat`},DD=`
66
+ precision highp float;
67
+ precision highp int;
68
+ precision highp sampler2D;
69
+ precision highp sampler3D;
70
+ precision highp samplerCube;
71
+ precision highp sampler2DArray;
72
+
73
+ precision highp usampler2D;
74
+ precision highp usampler3D;
75
+ precision highp usamplerCube;
76
+ precision highp usampler2DArray;
77
+
78
+ precision highp isampler2D;
79
+ precision highp isampler3D;
80
+ precision highp isamplerCube;
81
+ precision highp isampler2DArray;
82
+
83
+ precision lowp sampler2DShadow;
84
+ precision lowp sampler2DArrayShadow;
85
+ precision lowp samplerCubeShadow;
86
+ `;var OD=class extends iE{constructor(e,t){super(e,t,new EE),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==mn}getMethod(e){return SD[e]||e}getOutputStructName(){return``}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(this.getType(e.type)+` `+e.name);let i=`${this.getType(t.type)} ${t.name}( ${r.join(`, `)} ) {
87
+
88
+ ${n.vars}
89
+
90
+ ${n.code}
91
+ return ${n.result};
92
+
93
+ }`;return i}setupPBO(e){let t=e.value;if(t.pbo===void 0){let e=t.array,n=t.count*t.itemSize,{itemSize:r}=t,i=t.array.constructor.name.toLowerCase().includes(`int`),a=i?wt:Ct;r===2?a=i?Et:Tt:r===3?a=i?Dt:yt:r===4&&(a=i?Ot:bt);let o={Float32Array:pt,Uint8Array:st,Uint16Array:ut,Uint32Array:ft,Int8Array:ct,Int16Array:lt,Int32Array:dt,Uint8ClampedArray:st},s=2**Math.ceil(Math.log2(Math.sqrt(n/r))),c=Math.ceil(n/r/s);s*c*r<n&&c++;let l=s*c*r,u=new e.constructor(l);u.set(e,0),t.array=u;let d=new lo(t.array,s,c,a,o[t.array.constructor.name]||pt);d.needsUpdate=!0,d.isPBOTexture=!0;let f=new pp(d,null,null);f.setPrecision(`high`),t.pboNode=f,t.pbo=f.value,this.getUniformFromNode(t.pboNode,`texture`,this.shaderStage,this.context.label)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+`_`+e.name:super.getPropertyName(e,t)}generatePBO(e){let{node:t,indexNode:n}=e,r=t.value;if(this.renderer.backend.has(r)){let e=this.renderer.backend.get(r);e.pbo=r.pbo}let i=this.getUniformFromNode(r.pboNode,`texture`,this.shaderStage,this.context.label),a=this.getPropertyName(i);this.increaseUsage(n);let o=n.build(this,`uint`),s=this.getDataFromNode(e),c=s.propertyName;if(c===void 0){let n=this.getVarFromNode(e);c=this.getPropertyName(n);let i=this.getDataFromNode(t),l=i.propertySizeName;l===void 0&&(l=c+`Size`,this.getVarFromNode(t,l,`uint`),this.addLineFlowCode(`${l} = uint( textureSize( ${a}, 0 ).x )`,e),i.propertySizeName=l);let{itemSize:u}=r,d=`.`+dc.join(``).slice(0,u),f=`ivec2(${o} % ${l}, ${o} / ${l})`,p=this.generateTextureLoad(null,a,f,null,`0`),m=`vec4`;r.pbo.type===ft?m=`uvec4`:r.pbo.type===dt&&(m=`ivec4`),this.addLineFlowCode(`${c} = ${m}(${p})${d}`,e),s.propertyName=c}return c}generateTextureLoad(e,t,n,r,i=`0`){return r?`texelFetch( ${t}, ivec3( ${n}, ${r} ), ${i} )`:`texelFetch( ${t}, ${n}, ${i} )`}generateTexture(e,t,n,r){return e.isDepthTexture?(r&&(n=`vec4( ${n}, ${r} )`),`texture( ${t}, ${n} ).x`):(r&&(n=`vec3( ${n}, ${r} )`),`texture( ${t}, ${n} )`)}generateTextureLevel(e,t,n,r){return`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r){return`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r){return`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,i,a=this.shaderStage){if(a===`fragment`)return i?`texture( ${t}, vec4( ${n}, ${i}, ${r} ) )`:`texture( ${t}, vec3( ${n}, ${r} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}getVars(e){let t=[],n=this.vars[e];if(n!==void 0)for(let e of n)t.push(`${this.getVar(e.type,e.name,e.count)};`);return t.join(`
94
+ `)}getUniforms(e){let t=this.uniforms[e],n=[],r={};for(let i of t){let t=null,a=!1;if(i.type===`texture`||i.type===`texture3D`){let e=i.node.value,n=``;(e.isDataTexture===!0||e.isData3DTexture===!0)&&(e.type===ft?n=`u`:e.type===dt&&(n=`i`)),t=i.type===`texture3D`&&e.isArrayTexture===!1?`${n}sampler3D ${i.name};`:e.compareFunction?e.isArrayTexture===!0?`sampler2DArrayShadow ${i.name};`:`sampler2DShadow ${i.name};`:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?`${n}sampler2DArray ${i.name};`:`${n}sampler2D ${i.name};`}else if(i.type===`cubeTexture`)t=`samplerCube ${i.name};`;else if(i.type===`buffer`){let e=i.node,n=this.getType(e.bufferType),r=e.bufferCount,a=r>0?r:``;t=`${e.name} {\n\t${n} ${i.name}[${a}];\n};\n`}else{let n=this.getVectorType(i.type);t=`${n} ${this.getPropertyName(i,e)};`,a=!0}let o=i.node.precision;if(o!==null&&(t=CD[o]+` `+t),a){t=` `+t;let e=i.groupNode.name,n=r[e]||(r[e]=[]);n.push(t)}else t=`uniform `+t,n.push(t)}let i=``;for(let t in r){let n=r[t];i+=this._getGLSLUniformStruct(e+`_`+t,n.join(`
95
+ `))+`
96
+ `}return i+=n.join(`
97
+ `),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==dt){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);let r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t=``;if(e===`vertex`||e===`compute`){let e=this.getAttributesArray(),n=0;for(let r of e)t+=`layout( location = ${n++} ) in ${r.type} ${r.name};\n`}return t}getStructMembers(e){let t=[];for(let n of e.members)t.push(`\t${n.type} ${n.name};`);return t.join(`
98
+ `)}getStructs(e){let t=[],n=this.structs[e],r=[];for(let e of n)if(e.output)for(let t of e.members)r.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let n=`struct `+e.name+` {
99
+ `;n+=this.getStructMembers(e),n+=`
100
+ };
101
+ `,t.push(n)}return r.length===0&&r.push(`layout( location = 0 ) out vec4 fragColor;`),`
102
+ `+r.join(`
103
+ `)+`
104
+
105
+ `+t.join(`
106
+ `)}getVaryings(e){let t=``,n=this.varyings;if(e===`vertex`||e===`compute`)for(let r of n){e===`compute`&&(r.needsInterpolation=!0);let n=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){let e=TD[r.interpolationType]||r.interpolationType,i=ED[r.interpolationSampling]||``;t+=`${e} ${i} out ${n} ${r.name};\n`}else{let e=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${e}out ${n} ${r.name};\n`}else t+=`${n} ${r.name};\n`}else if(e===`fragment`){for(let e of n)if(e.needsInterpolation){let n=this.getType(e.type);if(e.interpolationType){let r=TD[e.interpolationType]||e.interpolationType,i=ED[e.interpolationSampling]||``;t+=`${r} ${i} in ${n} ${e.name};\n`}else{let r=n.includes(`int`)||n.includes(`uv`)||n.includes(`iv`)?`flat `:``;t+=`${r}in ${n} ${e.name};\n`}}}for(let n of this.builtins[e])t+=`${n};\n`;return t}getVertexIndex(){return`uint( gl_VertexID )`}getInstanceIndex(){return`uint( gl_InstanceID )`}getInvocationLocalIndex(){let e=this.object.workgroupSize,t=e.reduce((e,t)=>e*t,1);return`uint( gl_InstanceID ) % ${t}u`}getDrawIndex(){let e=this.renderer.backend.extensions;return e.has(`WEBGL_multi_draw`)?`uint( gl_DrawID )`:null}getFrontFacing(){return`gl_FrontFacing`}getFragCoord(){return`gl_FragCoord.xy`}getFragDepth(){return`gl_FragDepth`}enableExtension(e,t,n=this.shaderStage){let r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if(e===`vertex`){let t=this.renderer.backend.extensions,n=this.object.isBatchedMesh;n&&t.has(`WEBGL_multi_draw`)&&this.enableExtension(`GL_ANGLE_multi_draw`,`require`,e)}let n=this.extensions[e];if(n!==void 0)for(let{name:e,behavior:r}of n.values())t.push(`#extension ${e} : ${r}`);return t.join(`
107
+ `)}getClipDistance(){return`gl_ClipDistance`}isAvailable(e){let t=wD[e];if(t===void 0){let n;switch(t=!1,e){case`float32Filterable`:n=`OES_texture_float_linear`;break;case`clipDistance`:n=`WEBGL_clip_cull_distance`;break}if(n!==void 0){let e=this.renderer.backend.extensions;e.has(n)&&(e.get(n),t=!0)}wD[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension(`GL_ANGLE_clip_cull_distance`,`require`),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension(`GL_OVR_multiview2`,`require`,`fragment`),this.enableExtension(`GL_OVR_multiview2`,`require`,`vertex`),this.builtins.vertex.push(`layout(num_views = 2) in`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t=``;for(let n=0;n<e.length;n++){let r=e[n],i=this.getPropertyName(r.attributeNode);i&&(t+=`${r.varyingName} = ${i};\n\t`)}return t}_getGLSLUniformStruct(e,t){return`
108
+ layout( std140 ) uniform ${e} {
109
+ ${t}
110
+ };`}_getGLSLVertexCode(e){return`#version 300 es
111
+
112
+ ${this.getSignature()}
113
+
114
+ // extensions
115
+ ${e.extensions}
116
+
117
+ // precision
118
+ ${DD}
119
+
120
+ // uniforms
121
+ ${e.uniforms}
122
+
123
+ // varyings
124
+ ${e.varyings}
125
+
126
+ // attributes
127
+ ${e.attributes}
128
+
129
+ // codes
130
+ ${e.codes}
131
+
132
+ void main() {
133
+
134
+ // vars
135
+ ${e.vars}
136
+
137
+ // transforms
138
+ ${e.transforms}
139
+
140
+ // flow
141
+ ${e.flow}
142
+
143
+ gl_PointSize = 1.0;
144
+
145
+ }
146
+ `}_getGLSLFragmentCode(e){return`#version 300 es
147
+
148
+ ${this.getSignature()}
149
+
150
+ // extensions
151
+ ${e.extensions}
152
+
153
+ // precision
154
+ ${DD}
155
+
156
+ // uniforms
157
+ ${e.uniforms}
158
+
159
+ // varyings
160
+ ${e.varyings}
161
+
162
+ // codes
163
+ ${e.codes}
164
+
165
+ // structs
166
+ ${e.structs}
167
+
168
+ void main() {
169
+
170
+ // vars
171
+ ${e.vars}
172
+
173
+ // flow
174
+ ${e.flow}
175
+
176
+ }
177
+ `}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};for(let t in this.sortBindingGroups(),e){let n=`// code
178
+
179
+ `;n+=this.flowCode[t];let r=this.flowNodes[t],i=r[r.length-1];for(let e of r){let r=this.getFlowData(e),a=e.name;a&&(n.length>0&&(n+=`
180
+ `),n+=`\t// flow -> ${a}\n\t`),n+=`${r.code}\n\t`,e===i&&t!==`compute`&&(n+=`// result
181
+ `,t===`vertex`?(n+=`gl_Position = `,n+=`${r.result};`):t===`fragment`&&(e.outputNode.isOutputStructNode||(n+=`fragColor = `,n+=`${r.result};`)))}let a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material===null?this.computeShader=this._getGLSLVertexCode(e.compute):(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment))}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache),o=a.uniformGPU;if(o===void 0){let r=e.groupNode,s=r.name,c=this.getBindGroupArray(s,n);if(t===`texture`)o=new yD(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`)o=new bD(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new xD(i.name,i.node,r),c.push(o);else if(t===`buffer`){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;let t=new dD(e,r);t.name=e.name,c.push(t),o=t}else{let e=this.uniformGroups[n]||(this.uniformGroups[n]={}),a=e[s];a===void 0&&(a=new gD(n+`_`+s,r),e[s]=a,c.push(a)),o=this.getNodeUniform(i,t),a.addUniform(o)}a.uniformGPU=o}return i}};let kD=null,AD=null;var jD=class{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e=`render`){if(!this.trackTimestamp){yr(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t){yr(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}let n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return kD||=new lr,this.renderer.getDrawingBufferSize(kD)}setScissorTest(){}getClearColor(){let e=this.renderer;return AD||=new sb,e.getClearColor(AD),AD.getRGB(AD),AD}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?_r():this.parameters.canvas,`setAttribute`in e&&e.setAttribute(`data-engine`,`three.js r${v} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}};let MD=0;var ND=class{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}},PD=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this.backend,{gl:r}=n,i=e.array,a=e.usage||r.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,s=n.get(o),c=s.bufferGPU;c===void 0&&(c=this._createBuffer(r,t,i,a),s.bufferGPU=c,s.bufferType=t,s.version=o.version);let l;if(i instanceof Float32Array)l=r.FLOAT;else if(i instanceof Uint16Array)l=e.isFloat16BufferAttribute?r.HALF_FLOAT:r.UNSIGNED_SHORT;else if(i instanceof Int16Array)l=r.SHORT;else if(i instanceof Uint32Array)l=r.UNSIGNED_INT;else if(i instanceof Int32Array)l=r.INT;else if(i instanceof Int8Array)l=r.BYTE;else if(i instanceof Uint8Array)l=r.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)l=r.UNSIGNED_BYTE;else throw Error(`THREE.WebGLBackend: Unsupported buffer data format: `+i);let u={bufferGPU:c,bufferType:t,type:l,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:l===r.INT||l===r.UNSIGNED_INT||e.gpuType===dt,id:MD++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new ND(u,e)}n.set(e,u)}updateAttribute(e){let t=this.backend,{gl:n}=t,r=e.array,i=e.isInterleavedBufferAttribute?e.data:e,a=t.get(i),o=a.bufferType,s=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(o,a.bufferGPU),s.length===0)n.bufferSubData(o,0,r);else{for(let e=0,t=s.length;e<t;e++){let t=s[e];n.bufferSubData(o,t.start*r.BYTES_PER_ELEMENT,r,t.start,t.count)}i.clearUpdateRanges()}n.bindBuffer(o,null),a.version=i.version}destroyAttribute(e){let t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,{gl:n}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:i}=t.get(r),a=e.array,o=a.byteLength;n.bindBuffer(n.COPY_READ_BUFFER,i);let s=n.createBuffer();n.bindBuffer(n.COPY_WRITE_BUFFER,s),n.bufferData(n.COPY_WRITE_BUFFER,o,n.STREAM_READ),n.copyBufferSubData(n.COPY_READ_BUFFER,n.COPY_WRITE_BUFFER,0,0,o),await t.utils._clientWaitAsync();let c=new e.array.constructor(a.length);return n.bindBuffer(n.COPY_WRITE_BUFFER,s),n.getBufferSubData(n.COPY_WRITE_BUFFER,0,c),n.deleteBuffer(s),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),c.buffer}_createBuffer(e,t,n,r){let i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,n,r),e.bindBuffer(t,null),i}};let FD,ID;var LD=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;FD={[de]:e.FUNC_ADD,[fe]:e.FUNC_SUBTRACT,[pe]:e.FUNC_REVERSE_SUBTRACT},ID={[ge]:e.ZERO,[_e]:e.ONE,[ve]:e.SRC_COLOR,[be]:e.SRC_ALPHA,[Ee]:e.SRC_ALPHA_SATURATE,[we]:e.DST_COLOR,[Se]:e.DST_ALPHA,[ye]:e.ONE_MINUS_SRC_COLOR,[xe]:e.ONE_MINUS_SRC_ALPHA,[Te]:e.ONE_MINUS_DST_COLOR,[Ce]:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new Pr().fromArray(t),this.currentViewport=new Pr().fromArray(n),this._tempVec4=new Pr}enable(e){let{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e===y?this.disable(t.CULL_FACE):(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===b?t.cullFace(t.BACK):e===x?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,n,r,i,a,o,s){let{gl:c}=this;if(e===ae){this.currentBlendingEnabled===!0&&(this.disable(c.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(c.BLEND),this.currentBlendingEnabled=!0),e!==ue){if(e!==this.currentBlending||s!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==de||this.currentBlendEquationAlpha!==de)&&(c.blendEquation(c.FUNC_ADD),this.currentBlendEquation=de,this.currentBlendEquationAlpha=de),s)switch(e){case oe:c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case se:c.blendFunc(c.ONE,c.ONE);break;case ce:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case le:c.blendFuncSeparate(c.ZERO,c.SRC_COLOR,c.ZERO,c.SRC_ALPHA);break;default:console.error(`THREE.WebGLState: Invalid blending: `,e);break}else switch(e){case oe:c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA);break;case se:c.blendFunc(c.SRC_ALPHA,c.ONE);break;case ce:c.blendFuncSeparate(c.ZERO,c.ONE_MINUS_SRC_COLOR,c.ZERO,c.ONE);break;case le:c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:console.error(`THREE.WebGLState: Invalid blending: `,e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=s}return}i||=t,a||=n,o||=r,(t!==this.currentBlendEquation||i!==this.currentBlendEquationAlpha)&&(c.blendEquationSeparate(FD[t],FD[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(ID[n],ID[r],ID[a],ID[o]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=o),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case De:t.depthFunc(t.NEVER);break;case Oe:t.depthFunc(t.ALWAYS);break;case ke:t.depthFunc(t.LESS);break;case Ae:t.depthFunc(t.LEQUAL);break;case je:t.depthFunc(t.EQUAL);break;case Me:t.depthFunc(t.GEQUAL);break;case Ne:t.depthFunc(t.GREATER);break;case Pe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(i)===!1){let{gl:e}=this;e.scissor(i.x,i.y,i.z,i.w),this.currentScissor.copy(i)}}viewport(e,t,n,r){let i=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(i)===!1){let{gl:e}=this;e.viewport(i.x,i.y,i.z,i.w),this.currentViewport.copy(i)}}setScissorTest(e){let t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){let{gl:r}=this;e.side===ie?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let i=e.side===re;t&&(i=!i),this.setFlipSided(i),e.blending===oe&&e.transparent===!1?this.setBlending(ae):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.samples>1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n){let e=12288;for(let t=0;t<8;t++)t<n?this.enable(e+t):this.disable(e+t)}}setPolygonOffset(e,t,n){let{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram===e?!1:(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:n,currentBoundFramebuffers:r}=this;return r[e]===t?!1:(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:n}=this,r=[],i=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));let a=e.textures;if(r.length!==a.length||r[0]!==n.COLOR_ATTACHMENT0){for(let e=0,t=a.length;e<t;e++)r[e]=n.COLOR_ATTACHMENT0+e;r.length=a.length,i=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,i=!0);i&&n.drawBuffers(r)}activeTexture(e){let{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){let{gl:r,currentTextureSlot:i,currentBoundTextures:a,maxTextures:o}=this;n===void 0&&(n=i===null?r.TEXTURE0+o-1:i);let s=a[n];s===void 0&&(s={type:void 0,texture:void 0},a[n]=s),(s.type!==e||s.texture!==t)&&(i!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),s.type=e,s.texture=t)}bindBufferBase(e,t,n){let{gl:r}=this,i=`${e}-${t}`;return this.currentBoundBufferBases[i]===n?!1:(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[i]=n,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}},RD=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=mn){let{gl:n,extensions:r}=this,i,a=Cr.getTransfer(t);if(e===st)return n.UNSIGNED_BYTE;if(e===ht)return n.UNSIGNED_SHORT_4_4_4_4;if(e===gt)return n.UNSIGNED_SHORT_5_5_5_1;if(e===vt)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===ct)return n.BYTE;if(e===lt)return n.SHORT;if(e===ut)return n.UNSIGNED_SHORT;if(e===dt)return n.INT;if(e===ft)return n.UNSIGNED_INT;if(e===pt)return n.FLOAT;if(e===mt)return n.HALF_FLOAT;if(e===eee)return n.ALPHA;if(e===yt)return n.RGB;if(e===bt)return n.RGBA;if(e===xt)return n.DEPTH_COMPONENT;if(e===St)return n.DEPTH_STENCIL;if(e===Ct)return n.RED;if(e===wt)return n.RED_INTEGER;if(e===Tt)return n.RG;if(e===Et)return n.RG_INTEGER;if(e===Ot)return n.RGBA_INTEGER;if(e===kt||e===At||e===jt||e===Mt)if(a===vn)if(i=r.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(e===kt)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===At)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===jt)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===Mt)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=r.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(e===kt)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===At)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===jt)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Mt)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===Nt||e===Pt||e===Ft||e===It)if(i=r.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(e===Nt)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Pt)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Ft)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===It)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===Lt||e===Rt||e===zt)if(i=r.get(`WEBGL_compressed_texture_etc`),i!==null){if(e===Lt||e===Rt)return a===vn?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(e===zt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===Bt||e===Vt||e===Ht||e===Ut||e===Wt||e===Gt||e===Kt||e===qt||e===Jt||e===Yt||e===Xt||e===Zt||e===Qt||e===$t)if(i=r.get(`WEBGL_compressed_texture_astc`),i!==null){if(e===Bt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===Vt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===Ht)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===Ut)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===Wt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===Gt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===Kt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===qt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===Jt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===Yt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===Xt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===Zt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===Qt)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===$t)return a===vn?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===en)if(i=r.get(`EXT_texture_compression_bptc`),i!==null){if(e===en)return a===vn?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===tn||e===nn||e===rn||e===an)if(i=r.get(`EXT_texture_compression_rgtc`),i!==null){if(e===en)return i.COMPRESSED_RED_RGTC1_EXT;if(e===nn)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===rn)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===an)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===_t?n.UNSIGNED_INT_24_8:n[e]===void 0?null:n[e]}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function i(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(i);return}e.deleteSync(t),n()}i()})}};let zD=!1,BD,VD,HD;var UD=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},zD===!1&&(this._init(),zD=!0)}_init(){let e=this.gl;BD={[Ze]:e.REPEAT,[Qe]:e.CLAMP_TO_EDGE,[$e]:e.MIRRORED_REPEAT},VD={[et]:e.NEAREST,[tt]:e.NEAREST_MIPMAP_NEAREST,[nt]:e.NEAREST_MIPMAP_LINEAR,[rt]:e.LINEAR,[it]:e.LINEAR_MIPMAP_NEAREST,[at]:e.LINEAR_MIPMAP_LINEAR},HD={[Pn]:e.NEVER,[Vn]:e.ALWAYS,[Fn]:e.LESS,[Ln]:e.LEQUAL,[In]:e.EQUAL,[Bn]:e.GEQUAL,[Rn]:e.GREATER,[zn]:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this,n;return n=e.isCubeTexture===!0?t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?t.TEXTURE_3D:t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,i=!1){let{gl:a,extensions:o}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+e+`'`)}let s=t;if(t===a.RED&&(n===a.FLOAT&&(s=a.R32F),n===a.HALF_FLOAT&&(s=a.R16F),n===a.UNSIGNED_BYTE&&(s=a.R8),n===a.UNSIGNED_SHORT&&(s=a.R16),n===a.UNSIGNED_INT&&(s=a.R32UI),n===a.BYTE&&(s=a.R8I),n===a.SHORT&&(s=a.R16I),n===a.INT&&(s=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.R8UI),n===a.UNSIGNED_SHORT&&(s=a.R16UI),n===a.UNSIGNED_INT&&(s=a.R32UI),n===a.BYTE&&(s=a.R8I),n===a.SHORT&&(s=a.R16I),n===a.INT&&(s=a.R32I)),t===a.RG&&(n===a.FLOAT&&(s=a.RG32F),n===a.HALF_FLOAT&&(s=a.RG16F),n===a.UNSIGNED_BYTE&&(s=a.RG8),n===a.UNSIGNED_SHORT&&(s=a.RG16),n===a.UNSIGNED_INT&&(s=a.RG32UI),n===a.BYTE&&(s=a.RG8I),n===a.SHORT&&(s=a.RG16I),n===a.INT&&(s=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RG8UI),n===a.UNSIGNED_SHORT&&(s=a.RG16UI),n===a.UNSIGNED_INT&&(s=a.RG32UI),n===a.BYTE&&(s=a.RG8I),n===a.SHORT&&(s=a.RG16I),n===a.INT&&(s=a.RG32I)),t===a.RGB){let e=i?_n:Cr.getTransfer(r);n===a.FLOAT&&(s=a.RGB32F),n===a.HALF_FLOAT&&(s=a.RGB16F),n===a.UNSIGNED_BYTE&&(s=a.RGB8),n===a.UNSIGNED_SHORT&&(s=a.RGB16),n===a.UNSIGNED_INT&&(s=a.RGB32UI),n===a.BYTE&&(s=a.RGB8I),n===a.SHORT&&(s=a.RGB16I),n===a.INT&&(s=a.RGB32I),n===a.UNSIGNED_BYTE&&(s=e===vn?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(s=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(s=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(s=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(s=a.RGB9_E5)}if(t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RGB8UI),n===a.UNSIGNED_SHORT&&(s=a.RGB16UI),n===a.UNSIGNED_INT&&(s=a.RGB32UI),n===a.BYTE&&(s=a.RGB8I),n===a.SHORT&&(s=a.RGB16I),n===a.INT&&(s=a.RGB32I)),t===a.RGBA){let e=i?_n:Cr.getTransfer(r);n===a.FLOAT&&(s=a.RGBA32F),n===a.HALF_FLOAT&&(s=a.RGBA16F),n===a.UNSIGNED_BYTE&&(s=a.RGBA8),n===a.UNSIGNED_SHORT&&(s=a.RGBA16),n===a.UNSIGNED_INT&&(s=a.RGBA32UI),n===a.BYTE&&(s=a.RGBA8I),n===a.SHORT&&(s=a.RGBA16I),n===a.INT&&(s=a.RGBA32I),n===a.UNSIGNED_BYTE&&(s=e===vn?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(s=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(s=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(s=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(s=a.RGBA16UI),n===a.UNSIGNED_INT&&(s=a.RGBA32UI),n===a.BYTE&&(s=a.RGBA8I),n===a.SHORT&&(s=a.RGBA16I),n===a.INT&&(s=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_SHORT&&(s=a.DEPTH_COMPONENT16),n===a.UNSIGNED_INT&&(s=a.DEPTH_COMPONENT24),n===a.FLOAT&&(s=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(s=a.DEPTH24_STENCIL8),(s===a.R16F||s===a.R32F||s===a.RG16F||s===a.RG32F||s===a.RGBA16F||s===a.RGBA32F)&&o.get(`EXT_color_buffer_float`),s}setTextureParameters(e,t){let{gl:n,extensions:r,backend:i}=this,a=Cr.getPrimaries(Cr.workingColorSpace),o=t.colorSpace===mn?null:Cr.getPrimaries(t.colorSpace),s=t.colorSpace===mn||a===o?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,s),n.texParameteri(e,n.TEXTURE_WRAP_S,BD[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,BD[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,BD[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,VD[t.magFilter]);let c=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===rt&&c?at:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,VD[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,HD[t.compareFunction])),r.has(`EXT_texture_filter_anisotropic`)===!0){if(t.magFilter===et||t.minFilter!==nt&&t.minFilter!==at||t.type===pt&&r.has(`OES_texture_float_linear`)===!1)return;if(t.anisotropy>1){let a=r.get(`EXT_texture_filter_anisotropic`);n.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:n,defaultTextures:r}=this,i=this.getGLTextureType(e),a=r[i];a===void 0&&(a=t.createTexture(),n.state.bindTexture(i,a),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),r[i]=a),n.set(e,{textureGPU:a,glTextureType:i,isDefault:!0})}createTexture(e,t){let{gl:n,backend:r}=this,{levels:i,width:a,height:o,depth:s}=t,c=r.utils.convert(e.format,e.colorSpace),l=r.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,c,l,e.colorSpace,e.isVideoTexture),d=n.createTexture(),f=this.getGLTextureType(e);r.state.bindTexture(f,d),this.setTextureParameters(f,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,i,u,a,o,s):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,i,u,a,o,s):e.isVideoTexture||n.texStorage2D(f,i,u,a,o),r.set(e,{textureGPU:d,glTextureType:f,glFormat:c,glType:l,glInternalFormat:u})}copyBufferToTexture(e,t){let{gl:n,backend:r}=this,{textureGPU:i,glTextureType:a,glFormat:o,glType:s}=r.get(t),{width:c,height:l}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,i),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,c,l,o,s,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){let{gl:n}=this,{width:r,height:i}=t,{textureGPU:a,glTextureType:o,glFormat:s,glType:c,glInternalFormat:l}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){let r=e.mipmaps,i=t.image;for(let t=0;t<r.length;t++){let a=r[t];e.isCompressedArrayTexture?e.format===n.RGBA?n.texSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,c,a.data):s===null?console.warn(`THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,i.depth,s,a.data):s===null?console.warn(`Unsupported compressed texture format`):n.compressedTexSubImage2D(n.TEXTURE_2D,t,0,0,a.width,a.height,s,a.data)}}else if(e.isCubeTexture){let e=t.images;for(let t=0;t<6;t++){let a=WD(e[t]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,r,i,s,c,a)}}else if(e.isDataArrayTexture||e.isArrayTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isData3DTexture){let e=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,s,c,e.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(o,0,l,s,c,t.image);else{let e=WD(t.image);n.texSubImage2D(o,0,0,0,r,i,s,c,e)}}generateMipmaps(e){let{gl:t,backend:n}=this,{textureGPU:r,glTextureType:i}=n.get(e);n.state.bindTexture(i,r),t.generateMipmap(i)}deallocateRenderBuffers(e){let{gl:t,backend:n}=this;if(e){let r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(let e in r.framebuffers)t.deleteFramebuffer(r.framebuffers[e]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let e=0;e<r.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(r.msaaRenderbuffers[e]);delete r.msaaRenderbuffers}}}destroyTexture(e){let{gl:t,backend:n}=this,{textureGPU:r,renderTarget:i}=n.get(e);this.deallocateRenderBuffers(i),t.deleteTexture(r),n.delete(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let{gl:o,backend:s}=this,{state:c}=this.backend,{textureGPU:l,glTextureType:u,glType:d,glFormat:f}=s.get(t);c.bindTexture(u,l);let p,m,h,g,_,v,y,b,x,S=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)p=n.max.x-n.min.x,m=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,g=n.min.x,_=n.min.y,v=n.isBox3?n.min.z:0;else{let t=2**-i;p=Math.floor(S.width*t),m=Math.floor(S.height*t),h=e.isDataArrayTexture||e.isArrayTexture?S.depth:e.isData3DTexture?Math.floor(S.depth*t):1,g=0,_=0,v=0}r===null?(y=0,b=0,x=0):(y=r.x,b=r.y,x=r.z),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,t.unpackAlignment);let ee=o.getParameter(o.UNPACK_ROW_LENGTH),te=o.getParameter(o.UNPACK_IMAGE_HEIGHT),ne=o.getParameter(o.UNPACK_SKIP_PIXELS),re=o.getParameter(o.UNPACK_SKIP_ROWS),ie=o.getParameter(o.UNPACK_SKIP_IMAGES);o.pixelStorei(o.UNPACK_ROW_LENGTH,S.width),o.pixelStorei(o.UNPACK_IMAGE_HEIGHT,S.height),o.pixelStorei(o.UNPACK_SKIP_PIXELS,g),o.pixelStorei(o.UNPACK_SKIP_ROWS,_),o.pixelStorei(o.UNPACK_SKIP_IMAGES,v);let ae=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){let n=s.get(e),r=s.get(t),i=s.get(n.renderTarget),a=s.get(r.renderTarget),l=i.framebuffers[n.cacheKey],u=a.framebuffers[r.cacheKey];c.bindFramebuffer(o.READ_FRAMEBUFFER,l),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,u);let d=o.COLOR_BUFFER_BIT;e.isDepthTexture&&(d=o.DEPTH_BUFFER_BIT),o.blitFramebuffer(g,_,p,m,y,b,p,m,d,o.NEAREST),c.bindFramebuffer(o.READ_FRAMEBUFFER,null),c.bindFramebuffer(o.DRAW_FRAMEBUFFER,null)}else ae?e.isDataTexture||e.isData3DTexture?o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S.data):t.isCompressedArrayTexture?o.compressedTexSubImage3D(u,a,y,b,x,p,m,h,f,S.data):o.texSubImage3D(u,a,y,b,x,p,m,h,f,d,S):e.isDataTexture?o.texSubImage2D(u,a,y,b,p,m,f,d,S.data):e.isCompressedTexture?o.compressedTexSubImage2D(u,a,y,b,S.width,S.height,f,S.data):o.texSubImage2D(u,a,y,b,p,m,f,d,S);o.pixelStorei(o.UNPACK_ROW_LENGTH,ee),o.pixelStorei(o.UNPACK_IMAGE_HEIGHT,te),o.pixelStorei(o.UNPACK_SKIP_PIXELS,ne),o.pixelStorei(o.UNPACK_SKIP_ROWS,re),o.pixelStorei(o.UNPACK_SKIP_IMAGES,ie),a===0&&t.generateMipmaps&&o.generateMipmap(u),c.unbindTexture()}copyFramebufferToTexture(e,t,n){let{gl:r}=this,{state:i}=this.backend,{textureGPU:a}=this.backend.get(e),{x:o,y:s,z:c,w:l}=n,u=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(u){let n=o!==0||s!==0,u,f;if(e.isDepthTexture===!0?(u=r.DEPTH_BUFFER_BIT,f=r.DEPTH_ATTACHMENT,t.stencil&&(u|=r.STENCIL_BUFFER_BIT)):(u=r.COLOR_BUFFER_BIT,f=r.COLOR_ATTACHMENT0),n){let e=this.backend.get(t.renderTarget),n=e.framebuffers[t.getCacheKey()],f=e.msaaFrameBuffer;i.bindFramebuffer(r.DRAW_FRAMEBUFFER,n),i.bindFramebuffer(r.READ_FRAMEBUFFER,f);let p=d-s-l;r.blitFramebuffer(o,p,o+c,p+l,o,p,o+c,p+l,u,r.NEAREST),i.bindFramebuffer(r.READ_FRAMEBUFFER,n),i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,p,c,l),i.unbindTexture()}else{let e=r.createFramebuffer();i.bindFramebuffer(r.DRAW_FRAMEBUFFER,e),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,f,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,c,l,0,0,c,l,u,r.NEAREST),r.deleteFramebuffer(e)}}else i.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,o,d-l-s,c,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){let{gl:i}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:s,stencilBuffer:c,width:l,height:u}=a;if(i.bindRenderbuffer(i.RENDERBUFFER,e),s&&!c){let t=i.DEPTH_COMPONENT24;if(r===!0){let e=this.extensions.get(`WEBGL_multisampled_render_to_texture`);e.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,a.samples,t,l,u)}else n>0?(o&&o.isDepthTexture&&o.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,t,l,u)):i.renderbufferStorage(i.RENDERBUFFER,t,l,u);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else s&&c&&(n>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.DEPTH24_STENCIL8,l,u):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,u),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,i,a){let{backend:o,gl:s}=this,{textureGPU:c,glFormat:l,glType:u}=this.backend.get(e),d=s.createFramebuffer();s.bindFramebuffer(s.READ_FRAMEBUFFER,d);let f=e.isCubeTexture?s.TEXTURE_CUBE_MAP_POSITIVE_X+a:s.TEXTURE_2D;s.framebufferTexture2D(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,f,c,0);let p=this._getTypedArrayType(u),m=this._getBytesPerTexel(u,l),h=r*i,g=h*m,_=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,_),s.bufferData(s.PIXEL_PACK_BUFFER,g,s.STREAM_READ),s.readPixels(t,n,r,i,l,u,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();let v=new p(g/p.BYTES_PER_ELEMENT);return s.bindBuffer(s.PIXEL_PACK_BUFFER,_),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,v),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),s.deleteFramebuffer(d),v}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:n}=this,r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}};function WD(e){return e.isDataTexture?e.image.data:typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?e:e.data}var GD=class{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}},KD=class{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(t.has(`EXT_texture_filter_anisotropic`)===!0){let n=t.get(`EXT_texture_filter_anisotropic`);this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}};const qD={WEBGL_multi_draw:`WEBGL_multi_draw`,WEBGL_compressed_texture_astc:`texture-compression-astc`,WEBGL_compressed_texture_etc:`texture-compression-etc2`,WEBGL_compressed_texture_etc1:`texture-compression-etc1`,WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBKIT_WEBGL_compressed_texture_pvrtc:`texture-compression-pvrtc`,WEBGL_compressed_texture_s3tc:`texture-compression-bc`,EXT_texture_compression_bptc:`texture-compression-bptc`,EXT_disjoint_timer_query_webgl2:`timestamp-query`,OVR_multiview2:`OVR_multiview2`};var JD=class{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:n,mode:r,object:i,type:a,info:o,index:s}=this;s===0?n.drawArrays(r,e,t):n.drawElements(r,t,a,e),o.update(i,t,1)}renderInstances(e,t,n){let{gl:r,mode:i,type:a,index:o,object:s,info:c}=this;n!==0&&(o===0?r.drawArraysInstanced(i,e,t,n):r.drawElementsInstanced(i,t,a,e,n),c.update(s,t,n))}renderMultiDraw(e,t,n){let{extensions:r,mode:i,object:a,info:o}=this;if(n===0)return;let s=r.get(`WEBGL_multi_draw`);if(s===null)for(let r=0;r<n;r++)this.render(e[r],t[r]);else{this.index===0?s.multiDrawArraysWEBGL(i,e,0,t,0,n):s.multiDrawElementsWEBGL(i,t,0,this.type,e,0,n);let r=0;for(let e=0;e<n;e++)r+=t[e];o.update(a,r,1)}}renderMultiDrawInstances(e,t,n,r){let{extensions:i,mode:a,object:o,info:s}=this;if(n===0)return;let c=i.get(`WEBGL_multi_draw`);if(c===null)for(let i=0;i<n;i++)this.renderInstances(e[i],t[i],r[i]);else{this.index===0?c.multiDrawArraysInstancedWEBGL(a,e,0,t,0,r,0,n):c.multiDrawElementsInstancedWEBGL(a,t,0,this.type,e,0,r,0,n);let i=0;for(let e=0;e<n;e++)i+=t[e]*r[e];s.update(o,i,1)}}},YD=class{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}},XD=class extends YD{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension(`EXT_disjoint_timer_query_webgl2`)||e.getExtension(`EXT_disjoint_timer_query`),!this.ext){console.warn(`EXT_disjoint_timer_query not supported; timestamps will be disabled.`),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return yr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,`inactive`),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e.id);if(t==null||this.activeQuery!==null)return;let n=this.queries[t];if(n)try{this.queryStates.get(t)===`inactive`&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,`started`))}catch(e){console.error(`Error in beginQuery:`,e),this.activeQuery=null,this.queryStates.set(t,`inactive`)}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e.id);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,`ended`),this.activeQuery=null}catch(e){console.error(`Error in endQuery:`,e),this.queryStates.set(t,`inactive`),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=[];for(let[t,n]of this.queryStates)if(n===`ended`){let n=this.queries[t];e.push(this.resolveQuery(n))}if(e.length===0)return this.lastValue;let t=await Promise.all(e),n=t.reduce((e,t)=>e+t,0);return this.lastValue=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return console.error(`Error resolving queries:`,e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1,i=()=>{n&&(clearTimeout(n),n=null)},a=e=>{r||(r=!0,i(),t(e))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{let r=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(r){a(this.lastValue);return}let i=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE);if(!i){n=setTimeout(o,1);return}let s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error(`Error checking query:`,e),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}};const ZD=new lr;var QD=class extends jD{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,n={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context===void 0?e.domElement.getContext(`webgl2`,n):t.context;function i(t){t.preventDefault();let n={api:`WebGL`,message:t.statusMessage||`Unknown reason`,reason:null,originalEvent:t};e.onDeviceLost(n)}this._onContextLost=i,e.domElement.addEventListener(`webglcontextlost`,i,!1),this.gl=r,this.extensions=new GD(this),this.capabilities=new KD(this),this.attributeUtils=new PD(this),this.textureUtils=new UD(this),this.bufferRenderer=new JD(this),this.state=new LD(this),this.utils=new RD(this),this.extensions.get(`EXT_color_buffer_float`),this.extensions.get(`WEBGL_clip_cull_distance`),this.extensions.get(`OES_texture_float_linear`),this.extensions.get(`EXT_color_buffer_half_float`),this.extensions.get(`WEBGL_multisampled_render_to_texture`),this.extensions.get(`WEBGL_render_shared_exponent`),this.extensions.get(`WEBGL_multi_draw`),this.extensions.get(`OVR_multiview2`),this.disjoint=this.extensions.get(`EXT_disjoint_timer_query_webgl2`),this.parallel=this.extensions.get(`KHR_parallel_shader_compile`)}get coordinateSystem(){return Wn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){let e=this.gl.getContextAttributes();e.xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){let r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){let t=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:t}),this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e.autoAllocateDepthBuffer===!0&&e.multiview===!1&&console.warn(`THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided`),e.autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;let t=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new XD(this.gl,t,2048));let n=this.timestampQueryPool[t],r=n.allocateQueriesForContext(e);r!==null&&n.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;let t=e.isComputeNode?`compute`:`render`,n=this.timestampQueryPool[t];n.endQuery(e)}getContext(){return this.gl}beginRender(e){let{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:n}=this.getDrawingBufferSize(ZD);t.viewport(0,0,e,n)}if(e.scissor){let{x:n,y:r,width:i,height:a}=e.scissorValue;t.scissor(n,e.height-a-r,i,a)}this.initTimestampQuery(e),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=Array(r),n.occlusionQueryObjects=Array(r),n.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:n}=this,r=this.get(e),i=r.previousContext;n.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let o=e.textures;if(o!==null)for(let e=0;e<o.length;e++){let t=o[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=i,e.textures!==null&&e.renderTarget){let r=this.get(e.renderTarget),{resolveDepthBuffer:i,samples:a}=e.renderTarget;if(a>0&&this._useMultisampledExtension(e.renderTarget)===!1){let i=r.framebuffers[e.getCacheKey()],a=t.COLOR_BUFFER_BIT,o=r.msaaFrameBuffer,s=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,o),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let n=0;n<s.length;n++)if(e.scissor){let{x:n,y:i,width:o,height:s}=e.scissorValue,c=e.height-s-i;t.blitFramebuffer(n,c,n+o,c+s,n,c,n+o,c+s,a,t.NEAREST),this._supportsInvalidateFramebuffer===!0&&t.invalidateSubFramebuffer(t.READ_FRAMEBUFFER,r.invalidationArray,n,c,o,s)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,a,t.NEAREST),this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,r.invalidationArray)}else if(i===!1&&r.framebuffers){let i=r.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,r.depthInvalidationArray)}}if(i!==null)if(this._setFramebuffer(i),i.viewport)this.updateViewport(i);else{let{width:e,height:t}=this.getDrawingBufferSize(ZD);n.viewport(0,0,e,t)}this.prepareTimestampBuffer(e)}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet,{gl:i}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let o=0;for(let t=0;t<n.length;t++){let a=n[t];a!==null&&i.getQueryParameter(a,i.QUERY_RESULT_AVAILABLE)&&(i.getQueryParameter(a,i.QUERY_RESULT)===0&&e.add(r[t]),n[t]=null,i.deleteQuery(a),o++)}o<n.length?requestAnimationFrame(a):t.occluded=e};a()}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:n,y:r,width:i,height:a}=e.viewportValue;t.viewport(n,e.height-a-r,i,a)}setScissorTest(e){let t=this.state;t.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,r=null,i=!0){let{gl:a,renderer:o}=this;if(r===null){let e=this.getClearColor();r={textures:null,clearColorValue:e}}let s=0;if(e&&(s|=a.COLOR_BUFFER_BIT),t&&(s|=a.DEPTH_BUFFER_BIT),n&&(s|=a.STENCIL_BUFFER_BIT),s!==0){let c;c=r.clearColorValue?r.clearColorValue:this.getClearColor();let l=o.getClearDepth(),u=o.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)a.clearColor(c.r,c.g,c.b,c.a),a.clear(s);else{if(i&&this._setFramebuffer(r),e)for(let e=0;e<r.textures.length;e++)e===0?a.clearBufferfv(a.COLOR,e,[c.r,c.g,c.b,c.a]):a.clearBufferfv(a.COLOR,e,[0,0,0,1]);t&&n?a.clearBufferfi(a.DEPTH_STENCIL,0,l,u):t?a.clearBufferfv(a.DEPTH,0,[l]):n&&a.clearBufferiv(a.STENCIL,0,[u])}}}beginCompute(e){let{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(e)}compute(e,t,n,r){let{state:i,gl:a}=this;this.discard===!1&&(a.enable(a.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:o,transformBuffers:s,attributes:c}=this.get(r),l=this._getVaoKey(c),u=this.vaoCache[l];u===void 0?this._createVao(c):i.setVertexState(u),i.useProgram(o),this._bindUniforms(n);let d=this._getTransformFeedback(s);a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,d),a.beginTransformFeedback(a.POINTS),c[0].isStorageInstancedBufferAttribute?a.drawArraysInstanced(a.POINTS,0,1,t.count):a.drawArrays(a.POINTS,0,t.count),a.endTransformFeedback(),a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,null);for(let e=0;e<s.length;e++){let t=s[e];t.pbo&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){let t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(e),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){let{object:t,pipeline:n,material:r,context:i,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(n),{gl:s,state:c}=this,l=this.get(i),u=e.getDrawParameters();if(u===null)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&t.matrixWorld.determinant()<0;c.setMaterial(r,d,a),c.useProgram(o);let f=this.get(e),p=f.staticVao;if(p===void 0||f.geometryId!==e.geometry.id){let t=this._getVaoKey(e.getAttributes());if(p=this.vaoCache[t],p===void 0){let t;({vaoGPU:p,staticVao:t}=this._createVao(e.getAttributes())),t&&(f.staticVao=p,f.geometryId=e.geometry.id)}}let m=e.getIndex(),h=m===null?null:this.get(m).bufferGPU;c.setVertexState(p,h);let g=l.lastOcclusionObject;if(g!==t&&g!==void 0){if(g!==null&&g.occlusionTest===!0&&(s.endQuery(s.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),t.occlusionTest===!0){let e=s.createQuery();s.beginQuery(s.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}let _=this.bufferRenderer;t.isPoints?_.mode=s.POINTS:t.isLineSegments?_.mode=s.LINES:t.isLine?_.mode=s.LINE_STRIP:t.isLineLoop?_.mode=s.LINE_LOOP:r.wireframe===!0?(c.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),_.mode=s.LINES):_.mode=s.TRIANGLES;let{vertexCount:v,instanceCount:y}=u,{firstVertex:b}=u;if(_.object=t,m!==null){b*=m.array.BYTES_PER_ELEMENT;let e=this.get(m);_.index=m.count,_.type=e.type}else _.index=0;let x=()=>{t.isBatchedMesh?t._multiDrawInstances===null?this.hasFeature(`WEBGL_multi_draw`)?_.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):yr(`THREE.WebGLRenderer: WEBGL_multi_draw not supported.`):(yr(`THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),_.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):y>1?_.renderInstances(b,v,y):_.render(b,v)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){let n=this.get(e.camera),r=e.camera.cameras,i=e.getBindingGroup(`cameraIndex`).bindings[0];if(n.indexesGPU===void 0||n.indexesGPU.length!==r.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let n=0,i=r.length;n<i;n++){let r=s.createBuffer();e[0]=n,s.bindBuffer(s.UNIFORM_BUFFER,r),s.bufferData(s.UNIFORM_BUFFER,e,s.STATIC_DRAW),t.push(r)}n.indexesGPU=t}let a=this.get(i),o=this.renderer.getPixelRatio(),l=this._currentContext.renderTarget,u=this._isRenderCameraDepthArray(this._currentContext),d=this._currentContext.activeCubeFace;if(u){let e=this.get(l.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=l;for(let e=0,n=r.length;e<n;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1);this.renderer._activeCubeFace=d,this._currentContext.activeCubeFace=d}}for(let i=0,l=r.length;i<l;i++){let l=r[i];if(t.layers.test(l.layers)){u&&(this.renderer._activeCubeFace=i,this._currentContext.activeCubeFace=i,this._setFramebuffer(this._currentContext));let t=l.viewport;if(t!==void 0){let n=t.x*o,r=t.y*o,i=t.width*o,a=t.height*o;c.viewport(Math.floor(n),Math.floor(e.context.height-a-r),Math.floor(i),Math.floor(a))}c.bindBufferBase(s.UNIFORM_BUFFER,a.index,n.indexesGPU[i]),x()}this._currentContext.activeCubeFace=d,this.renderer._activeCubeFace=d}}else x()}needsRenderUpdate(){return!1}getRenderCacheKey(){return``}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new OD(e,t)}createProgram(e){let t=this.gl,{stage:n,code:r}=e,i=n===`fragment`?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(i,r),t.compileShader(i),this.set(e,{shaderGPU:i})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let n=this.gl,r=e.pipeline,{fragmentProgram:i,vertexProgram:a}=r,o=n.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU;if(n.attachShader(o,s),n.attachShader(o,c),n.linkProgram(o),this.set(r,{programGPU:o,fragmentShader:s,vertexShader:c}),t!==null&&this.parallel){let i=new Promise(t=>{let i=this.parallel,a=()=>{n.getProgramParameter(o,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),t()):requestAnimationFrame(a)};a()});t.push(i);return}this._completeCompile(e,r)}_handleSource(e,t){let n=e.split(`
182
+ `),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){let i=e+1;r.push(`${i===t?`>`:` `} ${i}: ${n[e]}`)}return r.join(`
183
+ `)}_getShaderErrors(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+`
184
+
185
+ `+i+`
186
+
187
+ `+this._handleSource(e.getShaderSource(t),r)}else return i}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){let r=this.gl,i=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError==`function`)this.renderer.debug.onShaderError(r,e,n,t);else{let a=this._getShaderErrors(r,n,`vertex`),o=this._getShaderErrors(r,t,`fragment`);console.error(`THREE.WebGLProgram: Shader Error `+r.getError()+` - VALIDATE_STATUS `+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
188
+
189
+ Program Info Log: `+i+`
190
+ `+a+`
191
+ `+o)}else i!==``&&console.warn(`THREE.WebGLProgram: Program Info Log:`,i)}}_completeCompile(e,t){let{state:n,gl:r}=this,i=this.get(t),{programGPU:a,fragmentShader:o,vertexShader:s}=i;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,o,s),n.useProgram(a);let c=e.getBindings();this._setupBindings(c,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){let{state:n,gl:r}=this,i={stage:`fragment`,code:`#version 300 es
192
+ precision highp float;
193
+ void main() {}`};this.createProgram(i);let{computeProgram:a}=e,o=r.createProgram(),s=this.get(i).shaderGPU,c=this.get(a).shaderGPU,l=a.transforms,u=[],d=[];for(let e=0;e<l.length;e++){let t=l[e];u.push(t.varyingName),d.push(t.attributeNode)}r.attachShader(o,s),r.attachShader(o,c),r.transformFeedbackVaryings(o,u,r.SEPARATE_ATTRIBS),r.linkProgram(o),r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,s,c),n.useProgram(o),this._setupBindings(t,o);let f=a.attributes,p=[],m=[];for(let e=0;e<f.length;e++){let t=f[e].node.attribute;p.push(t),this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER)}for(let e=0;e<d.length;e++){let t=d[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,r.ARRAY_BUFFER);let n=this.get(t);m.push(n)}this.set(e,{programGPU:o,transformBuffers:m,attributes:p})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let e=0,n=0;for(let r of t){this.set(r,{textures:n,uniformBuffers:e});for(let t of r.bindings)t.isUniformBuffer&&e++,t.isSampledTexture&&n++}}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this,n=this.get(e),r=n.uniformBuffers,i=n.textures;for(let n of e.bindings)if(n.isUniformsGroup||n.isUniformBuffer){let e=n.buffer,i=t.createBuffer();t.bindBuffer(t.UNIFORM_BUFFER,i),t.bufferData(t.UNIFORM_BUFFER,e,t.DYNAMIC_DRAW),this.set(n,{index:r++,bufferGPU:i})}else if(n.isSampledTexture){let{textureGPU:e,glTextureType:t}=this.get(n.texture);this.set(n,{index:i++,textureGPU:e,glTextureType:t})}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let n=this.get(e),r=n.bufferGPU,i=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW)}}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(qD).filter(t=>qD[t]===e),n=this.extensions;for(let e=0;e<t.length;e++)if(n.has(t[e]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,r,i,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}_setFramebuffer(e){let{gl:t,state:n}=this,r=null;if(e.textures!==null){let i=e.renderTarget,a=this.get(i),{samples:o,depthBuffer:s,stencilBuffer:c}=i,l=i.isWebGLCubeRenderTarget===!0,u=i.isRenderTarget3D===!0,d=i.depth>1,f=i.isXRRenderTarget===!0,p=f===!0&&i.hasExternalTextures===!0,m=a.msaaFrameBuffer,h=a.depthRenderbuffer,g=this.extensions.get(`WEBGL_multisampled_render_to_texture`),_=this.extensions.get(`OVR_multiview2`),v=this._useMultisampledExtension(i),y=ab(e),b;if(l?(a.cubeFramebuffers||={},b=a.cubeFramebuffers[y]):f&&p===!1?b=this._xrFramebuffer:(a.framebuffers||={},b=a.framebuffers[y]),b===void 0){b=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,b);let r=e.textures,s=[];if(l){a.cubeFramebuffers[y]=b;let{textureGPU:e}=this.get(r[0]),n=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+n,e,0)}else{a.framebuffers[y]=b;for(let n=0;n<r.length;n++){let a=r[n],s=this.get(a);s.renderTarget=e.renderTarget,s.cacheKey=y;let c=t.COLOR_ATTACHMENT0+n;if(i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,c,s.textureGPU,0,o,0,2);else if(u||d){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,c,s.textureGPU,0,e)}else v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,c,t.TEXTURE_2D,s.textureGPU,0)}n.drawBuffers(e,b)}let f=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i.autoAllocateDepthBuffer===!0){let n=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(n,e,0,v),a.xrDepthRenderbuffer=n,s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,f,t.RENDERBUFFER,n)}else if(e.depthTexture!==null){s.push(c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let n=this.get(e.depthTexture);if(n.renderTarget=e.renderTarget,n.cacheKey=y,i.multiview)_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,f,n.textureGPU,0,o,0,2);else if(p&&v)g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,f,n.textureGPU,0,e)}else t.framebufferTexture2D(t.FRAMEBUFFER,f,t.TEXTURE_2D,n.textureGPU,0)}a.depthInvalidationArray=s}else{let r=this._isRenderCameraDepthArray(e);if(r){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.renderer._activeCubeFace,i=this.get(e.depthTexture),a=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,a,i.textureGPU,0,r)}if(f||v||i.multiview){n.bindFramebuffer(t.FRAMEBUFFER,b);let r=this.get(e.textures[0]);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,r.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r.textureGPU,0);let s=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(i.autoAllocateDepthBuffer===!0){let e=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,e)}else{let n=this.get(e.depthTexture);i.multiview?_.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,s,n.textureGPU,0,o,0,2):v?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,s,t.TEXTURE_2D,n.textureGPU,0)}}}if(o>0&&v===!1&&!i.multiview){if(m===void 0){let r=[];m=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,m);let i=[],l=e.textures;for(let n=0;n<l.length;n++){if(i[n]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,i[n]),r.push(t.COLOR_ATTACHMENT0+n),s){let e=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r.push(e)}let a=e.textures[n],l=this.get(a);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,l.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+n,t.RENDERBUFFER,i[n])}if(a.msaaFrameBuffer=m,a.msaaRenderbuffers=i,h===void 0){h=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(h,e,o),a.depthRenderbuffer=h;let n=c?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r.push(n)}a.invalidationArray=r}r=a.msaaFrameBuffer}else r=b}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t=``;for(let n=0;n<e.length;n++){let r=this.get(e[n]);t+=`:`+r.id}return t}_createVao(e){let{gl:t}=this,n=t.createVertexArray(),r=``,i=!0;t.bindVertexArray(n);for(let n=0;n<e.length;n++){let a=e[n],o=this.get(a);r+=`:`+o.id,t.bindBuffer(t.ARRAY_BUFFER,o.bufferGPU),t.enableVertexAttribArray(n),(a.isStorageBufferAttribute||a.isStorageInstancedBufferAttribute)&&(i=!1);let s,c;a.isInterleavedBufferAttribute===!0?(s=a.data.stride*o.bytesPerElement,c=a.offset*o.bytesPerElement):(s=0,c=0),o.isInteger?t.vertexAttribIPointer(n,a.itemSize,o.type,s,c):t.vertexAttribPointer(n,a.itemSize,o.type,a.normalized,s,c),a.isInstancedBufferAttribute&&!a.isInterleavedBufferAttribute?t.vertexAttribDivisor(n,a.meshPerAttribute):a.isInterleavedBufferAttribute&&a.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(n,a.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),this.vaoCache[r]=n,{vaoGPU:n,staticVao:i}}_getTransformFeedback(e){let t=``;for(let n=0;n<e.length;n++)t+=`:`+e[n].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;let{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let t=0;t<e.length;t++){let n=e[t];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,t,n.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){let n=this.gl;for(let r of e)for(let e of r.bindings){let r=this.get(e),i=r.index;if(e.isUniformsGroup||e.isUniformBuffer){let r=n.getUniformBlockIndex(t,e.name);n.uniformBlockBinding(t,r,i)}else if(e.isSampledTexture){let r=n.getUniformLocation(t,e.name);n.uniform1i(r,i)}}}_bindUniforms(e){let{gl:t,state:n}=this;for(let r of e)for(let e of r.bindings){let r=this.get(e),i=r.index;e.isUniformsGroup||e.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,i,r.bufferGPU):e.isSampledTexture&&n.bindTexture(r.glTextureType,r.textureGPU,t.TEXTURE0+i)}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has(`WEBGL_multisampled_render_to_texture`)===!0&&e.autoAllocateDepthBuffer!==!1}dispose(){let e=this.extensions.get(`WEBGL_lose_context`);e&&e.loseContext(),this.renderer.domElement.removeEventListener(`webglcontextlost`,this._onContextLost)}};const $D={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`,TriangleStrip:`triangle-strip`},eO={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},tO={Store:`store`},nO={Load:`load`,Clear:`clear`},rO={CCW:`ccw`},iO={None:`none`,Front:`front`,Back:`back`},aO={Uint16:`uint16`,Uint32:`uint32`},L={R8Unorm:`r8unorm`,R8Snorm:`r8snorm`,R8Uint:`r8uint`,R8Sint:`r8sint`,R16Uint:`r16uint`,R16Sint:`r16sint`,R16Float:`r16float`,RG8Unorm:`rg8unorm`,RG8Snorm:`rg8snorm`,RG8Uint:`rg8uint`,RG8Sint:`rg8sint`,R32Uint:`r32uint`,R32Sint:`r32sint`,R32Float:`r32float`,RG16Uint:`rg16uint`,RG16Sint:`rg16sint`,RG16Float:`rg16float`,RGBA8Unorm:`rgba8unorm`,RGBA8UnormSRGB:`rgba8unorm-srgb`,RGBA8Snorm:`rgba8snorm`,RGBA8Uint:`rgba8uint`,RGBA8Sint:`rgba8sint`,BGRA8Unorm:`bgra8unorm`,BGRA8UnormSRGB:`bgra8unorm-srgb`,RGB9E5UFloat:`rgb9e5ufloat`,RGB10A2Unorm:`rgb10a2unorm`,RG11B10UFloat:`rgb10a2unorm`,RG32Uint:`rg32uint`,RG32Sint:`rg32sint`,RG32Float:`rg32float`,RGBA16Uint:`rgba16uint`,RGBA16Sint:`rgba16sint`,RGBA16Float:`rgba16float`,RGBA32Uint:`rgba32uint`,RGBA32Sint:`rgba32sint`,RGBA32Float:`rgba32float`,Depth16Unorm:`depth16unorm`,Depth24Plus:`depth24plus`,Depth24PlusStencil8:`depth24plus-stencil8`,Depth32Float:`depth32float`,Depth32FloatStencil8:`depth32float-stencil8`,BC1RGBAUnorm:`bc1-rgba-unorm`,BC1RGBAUnormSRGB:`bc1-rgba-unorm-srgb`,BC2RGBAUnorm:`bc2-rgba-unorm`,BC2RGBAUnormSRGB:`bc2-rgba-unorm-srgb`,BC3RGBAUnorm:`bc3-rgba-unorm`,BC3RGBAUnormSRGB:`bc3-rgba-unorm-srgb`,BC4RUnorm:`bc4-r-unorm`,BC4RSnorm:`bc4-r-snorm`,BC5RGUnorm:`bc5-rg-unorm`,BC5RGSnorm:`bc5-rg-snorm`,BC6HRGBUFloat:`bc6h-rgb-ufloat`,BC6HRGBFloat:`bc6h-rgb-float`,BC7RGBAUnorm:`bc7-rgba-unorm`,BC7RGBAUnormSRGB:`bc7-rgba-srgb`,ETC2RGB8Unorm:`etc2-rgb8unorm`,ETC2RGB8UnormSRGB:`etc2-rgb8unorm-srgb`,ETC2RGB8A1Unorm:`etc2-rgb8a1unorm`,ETC2RGB8A1UnormSRGB:`etc2-rgb8a1unorm-srgb`,ETC2RGBA8Unorm:`etc2-rgba8unorm`,ETC2RGBA8UnormSRGB:`etc2-rgba8unorm-srgb`,EACR11Unorm:`eac-r11unorm`,EACR11Snorm:`eac-r11snorm`,EACRG11Unorm:`eac-rg11unorm`,EACRG11Snorm:`eac-rg11snorm`,ASTC4x4Unorm:`astc-4x4-unorm`,ASTC4x4UnormSRGB:`astc-4x4-unorm-srgb`,ASTC5x4Unorm:`astc-5x4-unorm`,ASTC5x4UnormSRGB:`astc-5x4-unorm-srgb`,ASTC5x5Unorm:`astc-5x5-unorm`,ASTC5x5UnormSRGB:`astc-5x5-unorm-srgb`,ASTC6x5Unorm:`astc-6x5-unorm`,ASTC6x5UnormSRGB:`astc-6x5-unorm-srgb`,ASTC6x6Unorm:`astc-6x6-unorm`,ASTC6x6UnormSRGB:`astc-6x6-unorm-srgb`,ASTC8x5Unorm:`astc-8x5-unorm`,ASTC8x5UnormSRGB:`astc-8x5-unorm-srgb`,ASTC8x6Unorm:`astc-8x6-unorm`,ASTC8x6UnormSRGB:`astc-8x6-unorm-srgb`,ASTC8x8Unorm:`astc-8x8-unorm`,ASTC8x8UnormSRGB:`astc-8x8-unorm-srgb`,ASTC10x5Unorm:`astc-10x5-unorm`,ASTC10x5UnormSRGB:`astc-10x5-unorm-srgb`,ASTC10x6Unorm:`astc-10x6-unorm`,ASTC10x6UnormSRGB:`astc-10x6-unorm-srgb`,ASTC10x8Unorm:`astc-10x8-unorm`,ASTC10x8UnormSRGB:`astc-10x8-unorm-srgb`,ASTC10x10Unorm:`astc-10x10-unorm`,ASTC10x10UnormSRGB:`astc-10x10-unorm-srgb`,ASTC12x10Unorm:`astc-12x10-unorm`,ASTC12x10UnormSRGB:`astc-12x10-unorm-srgb`,ASTC12x12Unorm:`astc-12x12-unorm`,ASTC12x12UnormSRGB:`astc-12x12-unorm-srgb`},oO={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},sO={Linear:`linear`,Nearest:`nearest`},cO={Zero:`zero`,One:`one`,Src:`src`,OneMinusSrc:`one-minus-src`,SrcAlpha:`src-alpha`,OneMinusSrcAlpha:`one-minus-src-alpha`,Dst:`dst`,OneMinusDst:`one-minus-dst`,DstAlpha:`dst-alpha`,OneMinusDstAlpha:`one-minus-dst-alpha`,SrcAlphaSaturated:`src-alpha-saturated`,Constant:`constant`,OneMinusConstant:`one-minus-constant`},lO={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},uO={None:0,All:15},dO={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},fO={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},pO={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},mO={NonFiltering:`non-filtering`,Comparison:`comparison`},hO={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},gO={TwoD:`2d`,ThreeD:`3d`},_O={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},vO={All:`all`},yO={Vertex:`vertex`,Instance:`instance`},bO={DepthClipControl:`depth-clip-control`,Depth32FloatStencil8:`depth32float-stencil8`,TextureCompressionBC:`texture-compression-bc`,TextureCompressionETC2:`texture-compression-etc2`,TextureCompressionASTC:`texture-compression-astc`,TimestampQuery:`timestamp-query`,IndirectFirstInstance:`indirect-first-instance`,ShaderF16:`shader-f16`,RG11B10UFloat:`rg11b10ufloat-renderable`,BGRA8UNormStorage:`bgra8unorm-storage`,Float32Filterable:`float32-filterable`,ClipDistances:`clip-distances`,DualSourceBlending:`dual-source-blending`,Subgroups:`subgroups`};var xO=class extends oD{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}},SO=class extends xO{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}},CO=class extends cD{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}};let wO=0;var TO=class extends CO{constructor(e,t){super(`StorageBuffer_`+ wO++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:sc.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}},EO=class extends Yy{constructor(e){super(),this.device=e;let t=`
194
+ struct VarysStruct {
195
+ @builtin( position ) Position: vec4<f32>,
196
+ @location( 0 ) vTex : vec2<f32>
197
+ };
198
+
199
+ @vertex
200
+ fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
201
+
202
+ var Varys : VarysStruct;
203
+
204
+ var pos = array< vec2<f32>, 4 >(
205
+ vec2<f32>( -1.0, 1.0 ),
206
+ vec2<f32>( 1.0, 1.0 ),
207
+ vec2<f32>( -1.0, -1.0 ),
208
+ vec2<f32>( 1.0, -1.0 )
209
+ );
210
+
211
+ var tex = array< vec2<f32>, 4 >(
212
+ vec2<f32>( 0.0, 0.0 ),
213
+ vec2<f32>( 1.0, 0.0 ),
214
+ vec2<f32>( 0.0, 1.0 ),
215
+ vec2<f32>( 1.0, 1.0 )
216
+ );
217
+
218
+ Varys.vTex = tex[ vertexIndex ];
219
+ Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
220
+
221
+ return Varys;
222
+
223
+ }
224
+ `,n=`
225
+ @group( 0 ) @binding( 0 )
226
+ var imgSampler : sampler;
227
+
228
+ @group( 0 ) @binding( 1 )
229
+ var img : texture_2d<f32>;
230
+
231
+ @fragment
232
+ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
233
+
234
+ return textureSample( img, imgSampler, vTex );
235
+
236
+ }
237
+ `,r=`
238
+ @group( 0 ) @binding( 0 )
239
+ var imgSampler : sampler;
240
+
241
+ @group( 0 ) @binding( 1 )
242
+ var img : texture_2d<f32>;
243
+
244
+ @fragment
245
+ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
246
+
247
+ return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
248
+
249
+ }
250
+ `;this.mipmapSampler=e.createSampler({minFilter:sO.Linear}),this.flipYSampler=e.createSampler({minFilter:sO.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:`mipmapVertex`,code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:`mipmapFragment`,code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:`flipYFragment`,code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:`main`},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:`main`,targets:[{format:e}]},primitive:{topology:$D.TriangleStrip,stripIndexFormat:aO.Uint32},layout:`auto`}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:`main`},fragment:{module:this.flipYFragmentShaderModule,entryPoint:`main`,targets:[{format:e}]},primitive:{topology:$D.TriangleStrip,stripIndexFormat:aO.Uint32},layout:`auto`}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){let r=t.format,{width:i,height:a}=t.size,o=this.getTransferPipeline(r),s=this.getFlipYPipeline(r),c=this.device.createTexture({size:{width:i,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_O.TwoD,baseArrayLayer:n}),u=c.createView({baseMipLevel:0,mipLevelCount:1,dimension:_O.TwoD,baseArrayLayer:0}),d=this.device.createCommandEncoder({}),f=(e,t,n)=>{let r=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),a=d.beginRenderPass({colorAttachments:[{view:n,loadOp:nO.Clear,storeOp:tO.Store,clearValue:[0,0,0,0]}]});a.setPipeline(e),a.setBindGroup(0,i),a.draw(4,1,0,0),a.end()};f(o,l,u),f(s,u,l),this.device.queue.submit([d.finish()]),c.destroy()}generateMipmaps(e,t,n=0){let r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);let i=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,i),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=i),r.useCount++}_mipmapCreateBundles(e,t,n){let r=this.getTransferPipeline(t.format),i=r.getBindGroupLayout(0),a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_O.TwoD,baseArrayLayer:n}),o=[];for(let s=1;s<t.mipLevelCount;s++){let c=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:a}]}),l=e.createView({baseMipLevel:s,mipLevelCount:1,dimension:_O.TwoD,baseArrayLayer:n}),u={colorAttachments:[{view:l,loadOp:nO.Clear,storeOp:tO.Store,clearValue:[0,0,0,0]}]},d=this.device.createRenderBundleEncoder({colorFormats:[t.format]});d.setPipeline(r),d.setBindGroup(0,c),d.draw(4,1,0,0),o.push({renderBundles:[d.finish()],passDescriptor:u}),a=l}return o}_mipmapRunBundles(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=e.beginRenderPass(n.passDescriptor);i.executeBundles(n.renderBundles),i.end()}}};const DO={[Pn]:`never`,[Fn]:`less`,[In]:`equal`,[Ln]:`less-equal`,[Rn]:`greater`,[Bn]:`greater-equal`,[Vn]:`always`,[zn]:`not-equal`},OO=[0,1,3,2,4,5];var kO=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new To,this.depthTexture.name=`depthBuffer`}createSampler(e){let t=this.backend,n=t.device,r=t.get(e),i={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};i.magFilter===sO.Linear&&i.minFilter===sO.Linear&&i.mipmapFilter===sO.Linear&&(i.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(i.compare=DO[e.compareFunction]),r.sampler=n.createSampler(i)}createDefaultTexture(e){let t,n=AO(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(n):e.isVideoTexture?this.backend.get(e).externalTexture=this._getDefaultVideoFrame():t=this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){let n=this.backend,r=n.get(e);if(r.initialized)throw Error(`WebGPUTextureUtils: Texture already initialized.`);t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);let{width:i,height:a,depth:o,levels:s}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let c=this._getDimension(e),l=e.internalFormat||t.format||AO(e,n.device);r.format=l;let{samples:u,primarySamples:d,isMSAA:f}=n.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(p|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m={label:e.name,size:{width:i,height:a,depthOrArrayLayers:o},mipLevelCount:s,sampleCount:d,dimension:c,format:l,usage:p};if(e.isVideoTexture){let t=e.source.data,n=new VideoFrame(t);m.size.width=n.displayWidth,m.size.height=n.displayHeight,n.close(),r.externalTexture=t}else{if(l===void 0){console.warn(`WebGPURenderer: Texture format not supported.`),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=_O.Cube),r.texture=n.device.createTexture(m)}if(f){let e=Object.assign({},m);e.label+=`-msaa`,e.sampleCount=u,r.msaaTexture=n.device.createTexture(e)}r.initialized=!0,r.textureDescriptorGPU=m}destroyTexture(e){let t=this.backend,n=t.get(e);n.texture!==void 0&&n.texture.destroy(),n.msaaTexture!==void 0&&n.msaaTexture.destroy(),t.delete(e)}destroySampler(e){let t=this.backend,n=t.get(e);delete n.sampler}generateMipmaps(e){let t=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e);else{let n=e.image.depth||1;for(let e=0;e<n;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();let e=this.backend,{width:t,height:n}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:`colorBuffer`,size:{width:t,height:n,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){let n=this.backend,{width:r,height:i}=n.getDrawingBufferSize(),a=this.depthTexture,o=n.get(a).texture,s,c;if(t?(s=St,c=_t):e&&(s=xt,c=ft),o!==void 0){if(a.image.width===r&&a.image.height===i&&a.format===s&&a.type===c)return o;this.destroyTexture(a)}return a.name=`depthBuffer`,a.format=s,a.type=c,a.image.width=r,a.image.height=i,this.createTexture(a,{width:r,height:i}),n.get(a).texture}updateTexture(e,t){let n=this.backend.get(e),{textureDescriptorGPU:r}=n;if(!(e.isRenderTargetTexture||r===void 0)){if(e.isDataTexture)this._copyBufferToTexture(t.image,n.texture,r,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let i=0;i<t.image.depth;i++)this._copyBufferToTexture(t.image,n.texture,r,i,e.flipY,i);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,r);else if(e.isCubeTexture)this._copyCubeMapToTexture(t.images,n.texture,r,e.flipY,e.premultiplyAlpha);else if(e.isVideoTexture){let t=e.source.data;n.externalTexture=t}else this._copyImageToTexture(t.image,n.texture,r,0,e.flipY,e.premultiplyAlpha);n.version=e.version,e.onUpdate&&e.onUpdate(e)}}async copyTextureToBuffer(e,t,n,r,i,a){let o=this.backend.device,s=this.backend.get(e),c=s.texture,l=s.textureDescriptorGPU.format,u=this._getBytesPerTexel(l),d=r*u;d=Math.ceil(d/256)*256;let f=o.createBuffer({size:r*i*u,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),p=o.createCommandEncoder();p.copyTextureToBuffer({texture:c,origin:{x:t,y:n,z:a}},{buffer:f,bytesPerRow:d},{width:r,height:i});let m=this._getTypedArrayType(l);o.queue.submit([p.finish()]),await f.mapAsync(GPUMapMode.READ);let h=f.getMappedRange();return new m(h)}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let n=new Nr;n.minFilter=et,n.magFilter=et,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){let n=new $a;n.minFilter=et,n.magFilter=et,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultVideoFrame(){let e=this.defaultVideoFrame;if(e===null){let t={timestamp:0,codedWidth:1,codedHeight:1,format:`RGBA`};this.defaultVideoFrame=e=new VideoFrame(new Uint8Array([0,0,0,255]),t)}return e}_copyCubeMapToTexture(e,t,n,r,i){for(let a=0;a<6;a++){let o=e[a],s=r===!0?OO[a]:a;o.isDataTexture?this._copyBufferToTexture(o.image,t,n,s,r):this._copyImageToTexture(o,t,n,s,r,i)}}_copyImageToTexture(e,t,n,r,i,a){let o=this.backend.device;o.queue.copyExternalImageToTexture({source:e,flipY:i},{texture:t,mipLevel:0,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:e.width,height:e.height,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new EO(this.backend.device)),e}_generateMipmaps(e,t,n=0){this._getPassUtils().generateMipmaps(e,t,n)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,i,a=0){let o=this.backend.device,s=e.data,c=this._getBytesPerTexel(n.format),l=e.width*c;o.queue.writeTexture({texture:t,mipLevel:0,origin:{x:0,y:0,z:r}},s,{offset:e.width*e.height*c*a,bytesPerRow:l},{width:e.width,height:e.height,depthOrArrayLayers:1}),i===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n){let r=this.backend.device,i=this._getBlockData(n.format),a=n.size.depthOrArrayLayers>1;for(let o=0;o<e.length;o++){let s=e[o],c=s.width,l=s.height,u=a?n.size.depthOrArrayLayers:1,d=Math.ceil(c/i.width)*i.byteLength,f=d*Math.ceil(l/i.height);for(let e=0;e<u;e++)r.queue.writeTexture({texture:t,mipLevel:o,origin:{x:0,y:0,z:e}},s.data,{offset:e*f,bytesPerRow:d,rowsPerImage:Math.ceil(l/i.height)},{width:Math.ceil(c/i.width)*i.width,height:Math.ceil(l/i.height)*i.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===L.BC1RGBAUnorm||e===L.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===L.BC2RGBAUnorm||e===L.BC2RGBAUnormSRGB||e===L.BC3RGBAUnorm||e===L.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===L.BC4RUnorm||e===L.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===L.BC5RGUnorm||e===L.BC5RGSnorm||e===L.BC6HRGBUFloat||e===L.BC6HRGBFloat||e===L.BC7RGBAUnorm||e===L.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===L.ETC2RGB8Unorm||e===L.ETC2RGB8UnormSRGB||e===L.ETC2RGB8A1Unorm||e===L.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===L.ETC2RGBA8Unorm||e===L.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===L.EACR11Unorm||e===L.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===L.EACRG11Unorm||e===L.EACRG11Snorm||e===L.ASTC4x4Unorm||e===L.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===L.ASTC5x4Unorm||e===L.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===L.ASTC5x5Unorm||e===L.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===L.ASTC6x5Unorm||e===L.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===L.ASTC6x6Unorm||e===L.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===L.ASTC8x5Unorm||e===L.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===L.ASTC8x6Unorm||e===L.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===L.ASTC8x8Unorm||e===L.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===L.ASTC10x5Unorm||e===L.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===L.ASTC10x6Unorm||e===L.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===L.ASTC10x8Unorm||e===L.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===L.ASTC10x10Unorm||e===L.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===L.ASTC12x10Unorm||e===L.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===L.ASTC12x12Unorm||e===L.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=oO.ClampToEdge;return e===Ze?t=oO.Repeat:e===$e&&(t=oO.MirrorRepeat),t}_convertFilterMode(e){let t=sO.Linear;return(e===et||e===tt||e===nt)&&(t=sO.Nearest),t}_getBytesPerTexel(e){if(e===L.R8Unorm||e===L.R8Snorm||e===L.R8Uint||e===L.R8Sint)return 1;if(e===L.R16Uint||e===L.R16Sint||e===L.R16Float||e===L.RG8Unorm||e===L.RG8Snorm||e===L.RG8Uint||e===L.RG8Sint)return 2;if(e===L.R32Uint||e===L.R32Sint||e===L.R32Float||e===L.RG16Uint||e===L.RG16Sint||e===L.RG16Float||e===L.RGBA8Unorm||e===L.RGBA8UnormSRGB||e===L.RGBA8Snorm||e===L.RGBA8Uint||e===L.RGBA8Sint||e===L.BGRA8Unorm||e===L.BGRA8UnormSRGB||e===L.RGB9E5UFloat||e===L.RGB10A2Unorm||e===L.RG11B10UFloat||e===L.Depth32Float||e===L.Depth24Plus||e===L.Depth24PlusStencil8||e===L.Depth32FloatStencil8)return 4;if(e===L.RG32Uint||e===L.RG32Sint||e===L.RG32Float||e===L.RGBA16Uint||e===L.RGBA16Sint||e===L.RGBA16Float)return 8;if(e===L.RGBA32Uint||e===L.RGBA32Sint||e===L.RGBA32Float)return 16}_getTypedArrayType(e){if(e===L.R8Uint)return Uint8Array;if(e===L.R8Sint)return Int8Array;if(e===L.R8Unorm)return Uint8Array;if(e===L.R8Snorm)return Int8Array;if(e===L.RG8Uint)return Uint8Array;if(e===L.RG8Sint)return Int8Array;if(e===L.RG8Unorm)return Uint8Array;if(e===L.RG8Snorm)return Int8Array;if(e===L.RGBA8Uint)return Uint8Array;if(e===L.RGBA8Sint)return Int8Array;if(e===L.RGBA8Unorm)return Uint8Array;if(e===L.RGBA8Snorm)return Int8Array;if(e===L.R16Uint)return Uint16Array;if(e===L.R16Sint)return Int16Array;if(e===L.RG16Uint)return Uint16Array;if(e===L.RG16Sint)return Int16Array;if(e===L.RGBA16Uint)return Uint16Array;if(e===L.RGBA16Sint)return Int16Array;if(e===L.R16Float||e===L.RG16Float||e===L.RGBA16Float)return Uint16Array;if(e===L.R32Uint)return Uint32Array;if(e===L.R32Sint)return Int32Array;if(e===L.R32Float)return Float32Array;if(e===L.RG32Uint)return Uint32Array;if(e===L.RG32Sint)return Int32Array;if(e===L.RG32Float)return Float32Array;if(e===L.RGBA32Uint)return Uint32Array;if(e===L.RGBA32Sint)return Int32Array;if(e===L.RGBA32Float)return Float32Array;if(e===L.BGRA8Unorm||e===L.BGRA8UnormSRGB)return Uint8Array;if(e===L.RGB10A2Unorm||e===L.RGB9E5UFloat||e===L.RG11B10UFloat)return Uint32Array;if(e===L.Depth32Float)return Float32Array;if(e===L.Depth24Plus||e===L.Depth24PlusStencil8)return Uint32Array;if(e===L.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return t=e.isData3DTexture?gO.ThreeD:gO.TwoD,t}};function AO(e,t=null){let n=e.format,r=e.type,i=e.colorSpace,a=Cr.getTransfer(i),o;if(e.isCompressedTexture===!0||e.isCompressedArrayTexture===!0)switch(n){case At:o=a===vn?L.BC1RGBAUnormSRGB:L.BC1RGBAUnorm;break;case jt:o=a===vn?L.BC2RGBAUnormSRGB:L.BC2RGBAUnorm;break;case Mt:o=a===vn?L.BC3RGBAUnormSRGB:L.BC3RGBAUnorm;break;case Rt:o=a===vn?L.ETC2RGB8UnormSRGB:L.ETC2RGB8Unorm;break;case zt:o=a===vn?L.ETC2RGBA8UnormSRGB:L.ETC2RGBA8Unorm;break;case Bt:o=a===vn?L.ASTC4x4UnormSRGB:L.ASTC4x4Unorm;break;case Vt:o=a===vn?L.ASTC5x4UnormSRGB:L.ASTC5x4Unorm;break;case Ht:o=a===vn?L.ASTC5x5UnormSRGB:L.ASTC5x5Unorm;break;case Ut:o=a===vn?L.ASTC6x5UnormSRGB:L.ASTC6x5Unorm;break;case Wt:o=a===vn?L.ASTC6x6UnormSRGB:L.ASTC6x6Unorm;break;case Gt:o=a===vn?L.ASTC8x5UnormSRGB:L.ASTC8x5Unorm;break;case Kt:o=a===vn?L.ASTC8x6UnormSRGB:L.ASTC8x6Unorm;break;case qt:o=a===vn?L.ASTC8x8UnormSRGB:L.ASTC8x8Unorm;break;case Jt:o=a===vn?L.ASTC10x5UnormSRGB:L.ASTC10x5Unorm;break;case Yt:o=a===vn?L.ASTC10x6UnormSRGB:L.ASTC10x6Unorm;break;case Xt:o=a===vn?L.ASTC10x8UnormSRGB:L.ASTC10x8Unorm;break;case Zt:o=a===vn?L.ASTC10x10UnormSRGB:L.ASTC10x10Unorm;break;case Qt:o=a===vn?L.ASTC12x10UnormSRGB:L.ASTC12x10Unorm;break;case $t:o=a===vn?L.ASTC12x12UnormSRGB:L.ASTC12x12Unorm;break;case bt:o=a===vn?L.RGBA8UnormSRGB:L.RGBA8Unorm;break;default:console.error(`WebGPURenderer: Unsupported texture format.`,n)}else switch(n){case bt:switch(r){case ct:o=L.RGBA8Snorm;break;case lt:o=L.RGBA16Sint;break;case ut:o=L.RGBA16Uint;break;case ft:o=L.RGBA32Uint;break;case dt:o=L.RGBA32Sint;break;case st:o=a===vn?L.RGBA8UnormSRGB:L.RGBA8Unorm;break;case mt:o=L.RGBA16Float;break;case pt:o=L.RGBA32Float;break;default:console.error(`WebGPURenderer: Unsupported texture type with RGBAFormat.`,r)}break;case yt:switch(r){case vt:o=L.RGB9E5UFloat;break;default:console.error(`WebGPURenderer: Unsupported texture type with RGBFormat.`,r)}break;case Ct:switch(r){case ct:o=L.R8Snorm;break;case lt:o=L.R16Sint;break;case ut:o=L.R16Uint;break;case ft:o=L.R32Uint;break;case dt:o=L.R32Sint;break;case st:o=L.R8Unorm;break;case mt:o=L.R16Float;break;case pt:o=L.R32Float;break;default:console.error(`WebGPURenderer: Unsupported texture type with RedFormat.`,r)}break;case Tt:switch(r){case ct:o=L.RG8Snorm;break;case lt:o=L.RG16Sint;break;case ut:o=L.RG16Uint;break;case ft:o=L.RG32Uint;break;case dt:o=L.RG32Sint;break;case st:o=L.RG8Unorm;break;case mt:o=L.RG16Float;break;case pt:o=L.RG32Float;break;default:console.error(`WebGPURenderer: Unsupported texture type with RGFormat.`,r)}break;case xt:switch(r){case ut:o=L.Depth16Unorm;break;case ft:o=L.Depth24Plus;break;case pt:o=L.Depth32Float;break;default:console.error(`WebGPURenderer: Unsupported texture type with DepthFormat.`,r)}break;case St:switch(r){case _t:o=L.Depth24PlusStencil8;break;case pt:t&&t.features.has(bO.Depth32FloatStencil8)===!1&&console.error(`WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.`),o=L.Depth32FloatStencil8;break;default:console.error(`WebGPURenderer: Unsupported texture type with DepthStencilFormat.`,r)}break;case wt:switch(r){case dt:o=L.R32Sint;break;case ft:o=L.R32Uint;break;default:console.error(`WebGPURenderer: Unsupported texture type with RedIntegerFormat.`,r)}break;case Et:switch(r){case dt:o=L.RG32Sint;break;case ft:o=L.RG32Uint;break;default:console.error(`WebGPURenderer: Unsupported texture type with RGIntegerFormat.`,r)}break;case Ot:switch(r){case dt:o=L.RGBA32Sint;break;case ft:o=L.RGBA32Uint;break;default:console.error(`WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.`,r)}break;default:console.error(`WebGPURenderer: Unsupported texture format.`,n)}return o}const jO=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,MO=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,NO={f32:`float`,i32:`int`,u32:`uint`,bool:`bool`,"vec2<f32>":`vec2`,"vec2<i32>":`ivec2`,"vec2<u32>":`uvec2`,"vec2<bool>":`bvec2`,vec2f:`vec2`,vec2i:`ivec2`,vec2u:`uvec2`,vec2b:`bvec2`,"vec3<f32>":`vec3`,"vec3<i32>":`ivec3`,"vec3<u32>":`uvec3`,"vec3<bool>":`bvec3`,vec3f:`vec3`,vec3i:`ivec3`,vec3u:`uvec3`,vec3b:`bvec3`,"vec4<f32>":`vec4`,"vec4<i32>":`ivec4`,"vec4<u32>":`uvec4`,"vec4<bool>":`bvec4`,vec4f:`vec4`,vec4i:`ivec4`,vec4u:`uvec4`,vec4b:`bvec4`,"mat2x2<f32>":`mat2`,mat2x2f:`mat2`,"mat3x3<f32>":`mat3`,mat3x3f:`mat3`,"mat4x4<f32>":`mat4`,mat4x4f:`mat4`,sampler:`sampler`,texture_1d:`texture`,texture_2d:`texture`,texture_2d_array:`texture`,texture_multisampled_2d:`cubeTexture`,texture_depth_2d:`depthTexture`,texture_depth_2d_array:`depthTexture`,texture_depth_multisampled_2d:`depthTexture`,texture_depth_cube:`depthTexture`,texture_depth_cube_array:`depthTexture`,texture_3d:`texture3D`,texture_cube:`cubeTexture`,texture_cube_array:`cubeTexture`,texture_storage_1d:`storageTexture`,texture_storage_2d:`storageTexture`,texture_storage_2d_array:`storageTexture`,texture_storage_3d:`storageTexture`},PO=e=>{e=e.trim();let t=e.match(jO);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=MO.exec(n))!==null;)r.push({name:i[1],type:i[2]});let a=[];for(let e=0;e<r.length;e++){let{name:t,type:n}=r[e],i=n;i.startsWith(`ptr`)?i=`pointer`:(i.startsWith(`texture`)&&(i=n.split(`<`)[0]),i=NO[i]),a.push(new oE(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1],l=NO[s]||s;return{type:l,inputs:a,name:c,inputsCode:n,blockCode:o,outputType:s}}else throw Error(`FunctionNode: Function is not a WGSL code.`)};var FO=class extends bE{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=PO(e);super(t,n,r),this.inputsCode=i,this.blockCode=a,this.outputType=o}getCode(e=this.name){let t=this.outputType===`void`?``:`-> `+this.outputType;return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}},IO=class extends yE{parseFunction(e){return new FO(e)}};const LO=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},RO={[sc.READ_ONLY]:`read`,[sc.WRITE_ONLY]:`write`,[sc.READ_WRITE]:`read_write`},zO={[Ze]:`repeat`,[Qe]:`clamp`,[$e]:`mirror`},BO={vertex:LO?LO.VERTEX:1,fragment:LO?LO.FRAGMENT:2,compute:LO?LO.COMPUTE:4},VO={instance:!0,swizzleAssign:!1,storageBuffer:!0},HO={"^^":`tsl_xor`},UO={float:`f32`,int:`i32`,uint:`u32`,bool:`bool`,color:`vec3<f32>`,vec2:`vec2<f32>`,ivec2:`vec2<i32>`,uvec2:`vec2<u32>`,bvec2:`vec2<bool>`,vec3:`vec3<f32>`,ivec3:`vec3<i32>`,uvec3:`vec3<u32>`,bvec3:`vec3<bool>`,vec4:`vec4<f32>`,ivec4:`vec4<i32>`,uvec4:`vec4<u32>`,bvec4:`vec4<bool>`,mat2:`mat2x2<f32>`,mat3:`mat3x3<f32>`,mat4:`mat4x4<f32>`},WO={},GO={tsl_xor:new Rx(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new Rx(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new Rx(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new Rx(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new Rx(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new Rx(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new Rx(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new Rx(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new Rx(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new Rx(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new Rx(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new Rx(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new Rx(`
251
+ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
252
+
253
+ let res = vec2f( iRes );
254
+
255
+ let uvScaled = coord * res;
256
+ let uvWrapping = ( ( uvScaled % res ) + res ) % res;
257
+
258
+ // https://www.shadertoy.com/view/WtyXRy
259
+
260
+ let uv = uvWrapping - 0.5;
261
+ let iuv = floor( uv );
262
+ let f = fract( uv );
263
+
264
+ let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
265
+ let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
266
+ let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
267
+ let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
268
+
269
+ return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
270
+
271
+ }
272
+ `)},KO={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(GO.pow_float=new Rx(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),GO.pow_vec2=new Rx(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[GO.pow_float]),GO.pow_vec3=new Rx(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[GO.pow_float]),GO.pow_vec4=new Rx(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[GO.pow_float]),KO.pow_float=`tsl_pow_float`,KO.pow_vec2=`tsl_pow_vec2`,KO.pow_vec3=`tsl_pow_vec3`,KO.pow_vec4=`tsl_pow_vec4`);let qO=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(qO+=`diagnostic( off, derivative_uniformity );
273
+ `);var JO=class extends iE{constructor(e,t){super(e,t,new IO),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==mn}_generateTextureSample(e,t,n,r,i=this.shaderStage){return i===`fragment`?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this._generateTextureSampleLevel(e,t,n,`0`,r)}_generateVideoSample(e,t,n=this.shaderStage){if(n===`fragment`)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2<f32>( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,i){return this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,i,r)}generateWrapFunction(e){let t=`tsl_coord_${zO[e.wrapS]}S_${zO[e.wrapT]}_${e.isData3DTexture?`3d`:`2d`}T`,n=WO[t];if(n===void 0){let r=[],i=e.isData3DTexture?`vec3f`:`vec2f`,a=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`,o=(e,t)=>{e===Ze?(r.push(GO.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===Qe?(r.push(GO.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===$e?(r.push(GO.mirrorWrapping_float),a+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(a+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};o(e.wrapS,`x`),a+=`,
274
+ `,o(e.wrapT,`y`),e.isData3DTexture&&(a+=`,
275
+ `,o(e.wrapR,`z`)),a+=`
276
+ );
277
+
278
+ }
279
+ `,WO[t]=n=new Rx(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){let r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let i=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,o,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(e),c=s>1;o=e.isData3DTexture?`vec3<u32>`:`vec2<u32>`,a=c||e.isVideoTexture||e.isStorageTexture?t:`${t}${n?`, u32( ${n} )`:``}`,i=new df(new Xf(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new df(new Xf(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new df(new Xf(`6u`,`u32`)))}return i.build(this)}generateFilteredTexture(e,t,n,r=`0u`){this._include(`biquadraticTexture`);let i=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${i}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,i=`0u`){let a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,i),s=e.isData3DTexture?`vec3`:`vec2`,c=`${s}<u32>( ${a}( ${n} ) * ${s}<f32>( ${o} ) )`;return this.generateTextureLoad(e,t,c,r,i)}generateTextureLoad(e,t,n,r,i=`0u`){let a;return e.isVideoTexture===!0?a=`textureLoad( ${t}, ${n} )`:r?a=`textureLoad( ${t}, ${n}, ${r}, u32( ${i} ) )`:(a=`textureLoad( ${t}, ${n}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=`.x`)),a}generateTextureStore(e,t,n,r,i){let a;return a=r?`textureStore( ${t}, ${n}, ${r}, ${i} )`:`textureStore( ${t}, ${n}, ${i} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!==`float`||!this.isAvailable(`float32Filterable`)&&e.isDataTexture===!0&&e.type===pt||this.isSampleCompare(e)===!1&&e.minFilter===et&&e.magFilter===et||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,i=this.shaderStage){let a=null;return a=e.isVideoTexture===!0?this._generateVideoSample(t,n,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,n,r,`0`,i):this._generateTextureSample(e,t,n,r,i),a}generateTextureGrad(e,t,n,r,i,a=this.shaderStage){if(a===`fragment`)return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,i,a=this.shaderStage){if(a===`fragment`)return e.isDepthTexture===!0&&e.isArrayTexture===!0?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${i}, ${r} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,i,a=this.shaderStage){let o=null;return o=e.isVideoTexture===!0?this._generateVideoSample(t,n,a):this._generateTextureSampleLevel(e,t,n,r,i),o}generateTextureBias(e,t,n,r,i,a=this.shaderStage){if(a===`fragment`)return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t===`vertex`)return`varyings.${e.name}`}else if(e.isNodeUniform===!0){let t=e.name,n=e.type;return n===`texture`||n===`cubeTexture`||n===`storageTexture`||n===`texture3D`?t:n===`buffer`||n===`storageBuffer`||n===`indirectStorageBuffer`?this.isCustomStruct(e)?t:t+`.value`:e.groupNode.name+`.`+t}return super.getPropertyName(e)}getOutputStructName(){return`output`}getFunctionOperator(e){let t=HO[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:sc.READ_ONLY}getStorageAccess(e,t){return RO[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){let i=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let o,s=e.groupNode,c=s.name,l=this.getBindGroupArray(c,n);if(t===`texture`||t===`cubeTexture`||t===`storageTexture`||t===`texture3D`){let r=null,a=this.getNodeAccess(e,n);if(t===`texture`||t===`storageTexture`?r=new yD(i.name,i.node,s,a):t===`cubeTexture`?r=new bD(i.name,i.node,s,a):t===`texture3D`&&(r=new xD(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.setVisibility(BO[n]),this.isUnfilterable(e.value)===!1&&r.store===!1){let e=new SO(`${i.name}_sampler`,i.node,s);e.setVisibility(BO[n]),l.push(e,r),o=[e,r]}else l.push(r),o=[r]}else if(t===`buffer`||t===`storageBuffer`||t===`indirectStorageBuffer`){let a=t===`buffer`?dD:TO,c=new a(e,s);c.setVisibility(BO[n]),l.push(c),o=c,i.name=r||`NodeBuffer_`+i.id}else{let e=this.uniformGroups[n]||(this.uniformGroups[n]={}),r=e[c];r===void 0&&(r=new gD(c,s),r.setVisibility(BO[n]),e[c]=r,l.push(r)),o=this.getNodeUniform(i,t),r.addUniform(o)}a.uniformGPU=o}return i}getBuiltin(e,t,n,r=this.shaderStage){let i=this.builtins[r]||(this.builtins[r]=new Map);return i.has(e)===!1&&i.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`vertex_index`,`vertexIndex`,`u32`,`attribute`):`vertexIndex`}buildFunctionCode(e){let t=e.layout,n=this.flowShaderNode(e),r=[];for(let e of t.inputs)r.push(e.name+` : `+this.getType(e.type));let i=`fn ${t.name}( ${r.join(`, `)} ) -> ${this.getType(t.type)} {
280
+ ${n.vars}
281
+ ${n.code}
282
+ `;return n.result&&(i+=`\treturn ${n.result};\n`),i+=`
283
+ }
284
+ `,i}getInstanceIndex(){return this.shaderStage===`vertex`?this.getBuiltin(`instance_index`,`instanceIndex`,`u32`,`attribute`):`instanceIndex`}getInvocationLocalIndex(){return this.getBuiltin(`local_invocation_index`,`invocationLocalIndex`,`u32`,`attribute`)}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`)}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_invocation_id`,`invocationSubgroupIndex`,`u32`,`attribute`)}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin(`subgroup_id`,`subgroupIndex`,`u32`,`attribute`)}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin(`front_facing`,`isFront`,`bool`)}getFragCoord(){return this.getBuiltin(`position`,`fragCoord`,`vec4<f32>`)+`.xy`}getFragDepth(){return`output.`+this.getBuiltin(`frag_depth`,`depth`,`f32`,`output`)}getClipDistance(){return`varyings.hw_clip_distances`}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){let n=this.directives[t]||(this.directives[t]=new Set);n.add(e)}getDirectives(e){let t=[],n=this.directives[e];if(n!==void 0)for(let e of n)t.push(`enable ${e};`);return t.join(`
285
+ `)}enableSubGroups(){this.enableDirective(`subgroups`)}enableSubgroupsF16(){this.enableDirective(`subgroups-f16`)}enableClipDistances(){this.enableDirective(`clip_distances`)}enableShaderF16(){this.enableDirective(`f16`)}enableDualSourceBlending(){this.enableDirective(`dual_source_blending`)}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin(`clip_distances`,`hw_clip_distances`,`array<f32, ${e} >`,`vertex`)}getBuiltins(e){let t=[],n=this.builtins[e];if(n!==void 0)for(let{name:e,property:r,type:i}of n.values())t.push(`@builtin( ${e} ) ${r} : ${i}`);return t.join(`,
286
+ `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!==`compute`)return;let t=[];for(let{name:e,scope:n,bufferType:r,bufferCount:i}of this.scopedArrays.values()){let a=this.getType(r);t.push(`var<${n}> ${e}: array< ${a}, ${i} >;`)}return t.join(`
287
+ `)}getAttributes(e){let t=[];if(e===`compute`&&(this.getBuiltin(`global_invocation_id`,`globalId`,`vec3<u32>`,`attribute`),this.getBuiltin(`workgroup_id`,`workgroupId`,`vec3<u32>`,`attribute`),this.getBuiltin(`local_invocation_id`,`localId`,`vec3<u32>`,`attribute`),this.getBuiltin(`num_workgroups`,`numWorkgroups`,`vec3<u32>`,`attribute`),this.renderer.hasFeature(`subgroups`)&&(this.enableDirective(`subgroups`,e),this.getBuiltin(`subgroup_size`,`subgroupSize`,`u32`,`attribute`))),e===`vertex`||e===`compute`){let e=this.getBuiltins(`attribute`);e&&t.push(e);let n=this.getAttributesArray();for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.name,a=this.getType(r.type);t.push(`@location( ${e} ) ${i} : ${a}`)}}return t.join(`,
288
+ `)}getStructMembers(e){let t=[];for(let n of e.members){let r=e.output?`@location( `+n.index+` ) `:``,i=this.getType(n.type);n.atomic&&(i=`atomic< `+i+` >`),t.push(`\t${r+n.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins(`output`)}`),t.join(`,
289
+ `)}getStructs(e){let t=``,n=this.structs[e];if(n.length>0){let e=[];for(let t of n){let n=`struct ${t.name} {\n`;n+=this.getStructMembers(t),n+=`
290
+ };`,e.push(n)}t=`
291
+ `+e.join(`
292
+
293
+ `)+`
294
+ `}return t}getVar(e,t,n=null){let r=`var ${t} : `;return n===null?r+=this.getType(e):r+=this.generateArrayDeclaration(e,n),r}getVars(e){let t=[],n=this.vars[e];if(n!==void 0)for(let e of n)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join(`
295
+ `)}\n`}getVaryings(e){let t=[];if(e===`vertex`&&this.getBuiltin(`position`,`Vertex`,`vec4<f32>`,`vertex`),e===`vertex`||e===`fragment`){let n=this.varyings,r=this.vars[e];for(let i=0;i<n.length;i++){let a=n[i];if(a.needsInterpolation){let e=`@location( ${i} )`;if(a.interpolationType){let t=a.interpolationSampling===null?` )`:`, ${a.interpolationSampling} )`;e+=` @interpolate( ${a.interpolationType}${t}`}else /^(int|uint|ivec|uvec)/.test(a.type)&&(e+=` @interpolate( ${this.renderer.backend.compatibilityMode?`flat, either`:`flat`} )`);t.push(`${e} ${a.name} : ${this.getType(a.type)}`)}else e===`vertex`&&r.includes(a)===!1&&r.push(a)}}let n=this.getBuiltins(e);n&&t.push(n);let r=t.join(`,
296
+ `);return e===`vertex`?this._getWGSLStruct(`VaryingsStruct`,` `+r):r}isCustomStruct(e){let t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,i=n.value&&n.value.array&&typeof n.value.itemSize==`number`&&n.value.array.length>n.value.itemSize;return r&&!i}getUniforms(e){let t=this.uniforms[e],n=[],r=[],i=[],a={};for(let i of t){let t=i.groupNode.name,o=this.bindingsIndexes[t];if(i.type===`texture`||i.type===`cubeTexture`||i.type===`storageTexture`||i.type===`texture3D`){let t=i.node.value;this.isUnfilterable(t)===!1&&i.node.isStorageTextureNode!==!0&&(this.isSampleCompare(t)?n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name}_sampler : sampler_comparison;`):n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name}_sampler : sampler;`));let r,a=``,{primarySamples:s}=this.renderer.backend.utils.getTextureSampleData(t);if(s>1&&(a=`_multisampled`),t.isCubeTexture===!0)r=`texture_cube<f32>`;else if(t.isDepthTexture===!0)r=this.renderer.backend.compatibilityMode&&t.compareFunction===null?`texture${a}_2d<f32>`:`texture_depth${a}_2d${t.isArrayTexture===!0?`_array`:``}`;else if(t.isArrayTexture===!0||t.isDataArrayTexture===!0||t.isCompressedArrayTexture===!0)r=`texture_2d_array<f32>`;else if(t.isVideoTexture===!0)r=`texture_external`;else if(t.isData3DTexture===!0)r=`texture_3d<f32>`;else if(i.node.isStorageTextureNode===!0){let n=AO(t),a=this.getStorageAccess(i.node,e);r=`texture_storage_2d<${n}, ${a}>`}else{let e=this.getComponentTypeFromTexture(t).charAt(0);r=`texture${a}_2d<${e}32>`}n.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${i.name} : ${r};`)}else if(i.type===`buffer`||i.type===`storageBuffer`||i.type===`indirectStorageBuffer`){let t=i.node,n=this.getType(t.getNodeType(this)),a=t.bufferCount,s=a>0&&i.type===`buffer`?`, `+a:``,c=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:`uniform`;if(this.isCustomStruct(i))r.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${c}> ${i.name} : ${n};`);else{let e=t.isAtomic?`atomic<${n}>`:`${n}`,a=`\tvalue : array< ${e}${s} >`;r.push(this._getWGSLStructBinding(i.name,a,c,o.binding++,o.group))}}else{let e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name,n=a[t]||(a[t]={index:o.binding++,id:o.group,snippets:[]});n.snippets.push(`\t${i.name} : ${e}`)}}for(let e in a){let t=a[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(`,
297
+ `),`uniform`,t.index,t.id))}let o=n.join(`
298
+ `);return o+=r.join(`
299
+ `),o+=i.join(`
300
+ `),o}buildCode(){let e=this.material===null?{compute:{}}:{fragment:{},vertex:{}};for(let t in this.sortBindingGroups(),e){this.shaderStage=t;let n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code
301
+
302
+ `;r+=this.flowCode[t];let i=this.flowNodes[t],a=i[i.length-1],o=a.outputNode,s=o!==void 0&&o.isOutputStructNode===!0;for(let e of i){let i=this.getFlowData(e),c=e.name;if(c&&(r.length>0&&(r+=`
303
+ `),r+=`\t// flow -> ${c}\n`),r+=`${i.code}\n\t`,e===a&&t!==`compute`){if(r+=`// result
304
+
305
+ `,t===`vertex`)r+=`varyings.Vertex = ${i.result};`;else if(t===`fragment`)if(s)n.returnType=o.getNodeType(this),n.structs+=`var<private> output : `+n.returnType+`;`,r+=`return ${i.result};`;else{let e=` @location(0) color: vec4<f32>`,t=this.getBuiltins(`output`);t&&(e+=`,
306
+ `+t),n.returnType=`OutputStruct`,n.structs+=this._getWGSLStruct(`OutputStruct`,e),n.structs+=`
307
+ var<private> output : OutputStruct;`,r+=`output.color = ${i.result};\n\n\treturn output;`}}}n.flow=r}this.shaderStage=null,this.material===null?this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(`, `)):(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+`_`+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return UO[e]||e}isAvailable(e){let t=VO[e];return t===void 0&&(e===`float32Filterable`?t=this.renderer.hasFeature(`float32-filterable`):e===`clipDistance`&&(t=this.renderer.hasFeature(`clip-distances`)),VO[e]=t),t}_getWGSLMethod(e){return GO[e]!==void 0&&this._include(e),KO[e]}_include(e){let t=GO[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
308
+ // directives
309
+ ${e.directives}
310
+
311
+ // structs
312
+ ${e.structs}
313
+
314
+ // uniforms
315
+ ${e.uniforms}
316
+
317
+ // varyings
318
+ ${e.varyings}
319
+ var<private> varyings : VaryingsStruct;
320
+
321
+ // codes
322
+ ${e.codes}
323
+
324
+ @vertex
325
+ fn main( ${e.attributes} ) -> VaryingsStruct {
326
+
327
+ // vars
328
+ ${e.vars}
329
+
330
+ // flow
331
+ ${e.flow}
332
+
333
+ return varyings;
334
+
335
+ }
336
+ `}_getWGSLFragmentCode(e){return`${this.getSignature()}
337
+ // global
338
+ ${qO}
339
+
340
+ // structs
341
+ ${e.structs}
342
+
343
+ // uniforms
344
+ ${e.uniforms}
345
+
346
+ // codes
347
+ ${e.codes}
348
+
349
+ @fragment
350
+ fn main( ${e.varyings} ) -> ${e.returnType} {
351
+
352
+ // vars
353
+ ${e.vars}
354
+
355
+ // flow
356
+ ${e.flow}
357
+
358
+ }
359
+ `}_getWGSLComputeCode(e,t){return`${this.getSignature()}
360
+ // directives
361
+ ${e.directives}
362
+
363
+ // system
364
+ var<private> instanceIndex : u32;
365
+
366
+ // locals
367
+ ${e.scopedArrays}
368
+
369
+ // structs
370
+ ${e.structs}
371
+
372
+ // uniforms
373
+ ${e.uniforms}
374
+
375
+ // codes
376
+ ${e.codes}
377
+
378
+ @compute @workgroup_size( ${t} )
379
+ fn main( ${e.attributes} ) {
380
+
381
+ // system
382
+ instanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});
383
+
384
+ // vars
385
+ ${e.vars}
386
+
387
+ // flow
388
+ ${e.flow}
389
+
390
+ }
391
+ `}_getWGSLStruct(e,t){return`
392
+ struct ${e} {
393
+ ${t}
394
+ };`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`,o=this._getWGSLStruct(a,t);return`${o}
395
+ @binding( ${r} ) @group( ${i} )
396
+ var<${n}> ${e} : ${a};`}},YO=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=L.Depth24PlusStencil8:e.depth&&(t=L.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return $D.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return $D.LineList;if(e.isLine)return $D.LineStrip;if(e.isMesh)return $D.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return L.BGRA8Unorm;if(e===mt)return L.RGBA16Float;throw Error(`Unsupported outputType`)}};const XO=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),ZO=new Map([[ha,[`float16`]]]),QO=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var $O=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?yO.Instance:yO.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?yO.Instance:yO.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=QO.get(r);else{let e=ZO.get(i)||XO.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},ek=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===sc.READ_WRITE||n.access===sc.WRITE_ONLY)?t.type=fO.Storage:t.type=fO.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=mO.NonFiltering):r.type=mO.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===sc.READ_WRITE?t.access=pO.ReadWrite:r===sc.WRITE_ONLY?t.access=pO.WriteOnly:t.access=pO.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=hO.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=hO.UnfilterableFloat:r.sampleType=hO.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=hO.SInt:e===ft?r.sampleType=hO.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=hO.Float:r.sampleType=hO.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=_O.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=_O.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=_O.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=vO.All,a;a=t.isSampledCubeTexture?_O.Cube:t.isSampledTexture3D?_O.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?_O.TwoDArray:_O.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},tk=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:lO.Add},n={srcFactor:i,dstFactor:a,operation:lO.Add}};if(i)switch(r){case oe:a(cO.One,cO.OneMinusSrcAlpha,cO.One,cO.OneMinusSrcAlpha);break;case se:a(cO.One,cO.One,cO.One,cO.One);break;case ce:a(cO.Zero,cO.OneMinusSrc,cO.Zero,cO.One);break;case le:a(cO.Zero,cO.Src,cO.Zero,cO.SrcAlpha);break}else switch(r){case oe:a(cO.SrcAlpha,cO.OneMinusSrcAlpha,cO.One,cO.OneMinusSrcAlpha);break;case se:a(cO.SrcAlpha,cO.One,cO.SrcAlpha,cO.One);break;case ce:a(cO.Zero,cO.OneMinusSrc,cO.Zero,cO.One);break;case le:a(cO.Zero,cO.Src,cO.Zero,cO.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=cO.Zero;break;case _e:t=cO.One;break;case ve:t=cO.Src;break;case ye:t=cO.OneMinusSrc;break;case be:t=cO.SrcAlpha;break;case xe:t=cO.OneMinusSrcAlpha;break;case we:t=cO.Dst;break;case Te:t=cO.OneMinusDst;break;case Se:t=cO.DstAlpha;break;case Ce:t=cO.OneMinusDstAlpha;break;case Ee:t=cO.SrcAlphaSaturated;break;case cte:t=cO.Constant;break;case lte:t=cO.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case En:t=eO.Never;break;case Nn:t=eO.Always;break;case Dn:t=eO.Less;break;case kn:t=eO.LessEqual;break;case On:t=eO.Equal;break;case Mn:t=eO.GreaterEqual;break;case An:t=eO.Greater;break;case jn:t=eO.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bn:t=dO.Keep;break;case yn:t=dO.Zero;break;case xn:t=dO.Replace;break;case Tn:t=dO.Invert;break;case Sn:t=dO.IncrementClamp;break;case Cn:t=dO.DecrementClamp;break;case wn:t=dO.IncrementWrap;break;case tee:t=dO.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=lO.Add;break;case fe:t=lO.Subtract;break;case pe:t=lO.ReverseSubtract;break;case me:t=lO.Min;break;case he:t=lO.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?aO.Uint16:aO.Uint32),n.side){case ne:r.frontFace=rO.CCW,r.cullMode=iO.Back;break;case re:r.frontFace=rO.CCW,r.cullMode=iO.Front;break;case ie:r.frontFace=rO.CCW,r.cullMode=iO.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?uO.All:uO.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=eO.Always;else{let n=e.depthFunc;switch(n){case De:t=eO.Never;break;case Oe:t=eO.Always;break;case ke:t=eO.Less;break;case Ae:t=eO.LessEqual;break;case je:t=eO.Equal;break;case Me:t=eO.GreaterEqual;break;case Ne:t=eO.Greater;break;case Pe:t=eO.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},nk=class extends YD{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return yr(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},rk=class extends jD{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new YO(this),this.attributeUtils=new $O(this),this.bindingUtils=new ek(this),this.pipelineUtils=new tk(this),this.textureUtils=new kO(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(bO),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(bO.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return Gn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:_O.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=_O.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:_O.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=_O.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=_O.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||nO.Load,storeOp:t.storeOp||tO.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:nO.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=nO.Clear):r.loadOp=nO.Load,r.storeOp=tO.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=nO.Clear):t.loadOp=nO.Load,t.storeOp=tO.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=nO.Clear):o.depthLoadOp=nO.Load,o.depthStoreOp=tO.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=nO.Clear):o.stencilLoadOp=nO.Load,o.stencilStoreOp=tO.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:_O.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||nO.Clear,depthStoreOp:i.depthStoreOp||tO.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=nO.Clear):t.depthLoadOp=nO.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=nO.Clear):t.stencilLoadOp=nO.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=nO.Clear,e.storeOp=tO.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?nO.Clear:nO.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?nO.Clear:nO.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=tO.Store),u&&(i.stencilLoadOp=n?nO.Clear:nO.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=tO.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=nO.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=tO.Store):(s.depthLoadOp=nO.Load,s.depthStoreOp=tO.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=nO.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=tO.Store):(s.stencilLoadOp=nO.Load,s.stencilStoreOp=tO.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?aO.Uint16:aO.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&yr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new nk(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new JO(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=nO.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=nO.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=nO.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},ik=class extends us{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},ak=class extends us{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},ok=class extends IE{constructor(){super(),this.addMaterial(sv,`MeshPhongMaterial`),this.addMaterial(Uy,`MeshStandardMaterial`),this.addMaterial(zee,`MeshPhysicalMaterial`),this.addMaterial(Uee,`MeshToonMaterial`),this.addMaterial(Z_,`MeshBasicMaterial`),this.addMaterial(av,`MeshLambertMaterial`),this.addMaterial(I_,`MeshNormalMaterial`),this.addMaterial(Kee,`MeshMatcapMaterial`),this.addMaterial(D_,`LineBasicMaterial`),this.addMaterial(k_,`LineDashedMaterial`),this.addMaterial(Xee,`PointsMaterial`),this.addMaterial(Ky,`SpriteMaterial`),this.addMaterial($ee,`ShadowMaterial`),this.addLight(LC,hs),this.addLight(sE,vs),this.addLight(dE,bs),this.addLight(fE,us),this.addLight(gE,ys),this.addLight(_E,ns),this.addLight(vE,Ss),this.addLight(pE,ik),this.addLight(hE,ak),this.addToneMapping(Ox,ze),this.addToneMapping(kx,Be),this.addToneMapping(Ax,Ve),this.addToneMapping(Mx,He),this.addToneMapping(Ix,Ue),this.addToneMapping(Lx,We)}},sk=class extends aD{constructor(e={}){let t;e.forceWebGL?t=QD:(t=rk,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new QD(e)));let n=new t(e);super(n,e),this.library=new ok,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},ck={};_(ck,{BRDF_GGX:()=>lk,BRDF_Lambert:()=>uk,BasicShadowFilter:()=>dk,Break:()=>fk,Const:()=>bj,Continue:()=>pk,DFGApprox:()=>mk,D_GGX:()=>hk,Discard:()=>gk,EPSILON:()=>_k,F_Schlick:()=>vk,Fn:()=>yk,INFINITY:()=>bk,If:()=>xk,Loop:()=>Ck,NodeAccess:()=>Dk,NodeShaderStage:()=>wk,NodeType:()=>Tk,NodeUpdateType:()=>Ek,PCFShadowFilter:()=>Ok,PCFSoftShadowFilter:()=>kk,PI:()=>Ak,PI2:()=>jk,Return:()=>Mk,Schlick_to_F0:()=>Nk,ScriptableNodeResources:()=>Pk,ShaderNode:()=>Fk,Switch:()=>Sk,TBNViewMatrix:()=>Ik,VSMShadowFilter:()=>Lk,V_GGX_SmithCorrelated:()=>Rk,Var:()=>_F,abs:()=>zk,acesFilmicToneMapping:()=>Bk,acos:()=>Vk,add:()=>Hk,addNodeElement:()=>Uk,agxToneMapping:()=>Wk,all:()=>Gk,alphaT:()=>Kk,and:()=>qk,anisotropy:()=>Jk,anisotropyB:()=>Yk,anisotropyT:()=>Xk,any:()=>Zk,append:()=>Qk,array:()=>$k,arrayBuffer:()=>eA,asin:()=>tA,assign:()=>nA,atan:()=>rA,atan2:()=>iA,atomicAdd:()=>aA,atomicAnd:()=>oA,atomicFunc:()=>sA,atomicLoad:()=>mA,atomicMax:()=>cA,atomicMin:()=>lA,atomicOr:()=>uA,atomicStore:()=>dA,atomicSub:()=>fA,atomicXor:()=>pA,attenuationColor:()=>hA,attenuationDistance:()=>gA,attribute:()=>_A,attributeArray:()=>vA,backgroundBlurriness:()=>yA,backgroundIntensity:()=>bA,backgroundRotation:()=>xA,batch:()=>SA,billboarding:()=>CA,bitAnd:()=>wA,bitNot:()=>TA,bitOr:()=>EA,bitXor:()=>DA,bitangentGeometry:()=>OA,bitangentLocal:()=>kA,bitangentView:()=>AA,bitangentWorld:()=>jA,bitcast:()=>MA,blendBurn:()=>NA,blendColor:()=>PA,blendDodge:()=>FA,blendOverlay:()=>IA,blendScreen:()=>LA,blur:()=>RA,bool:()=>zA,buffer:()=>BA,bufferAttribute:()=>VA,bumpMap:()=>HA,burn:()=>UA,bvec2:()=>WA,bvec3:()=>GA,bvec4:()=>KA,bypass:()=>qA,cache:()=>JA,call:()=>YA,cameraFar:()=>XA,cameraIndex:()=>ZA,cameraNear:()=>QA,cameraNormalMatrix:()=>$A,cameraPosition:()=>ej,cameraProjectionMatrix:()=>tj,cameraProjectionMatrixInverse:()=>nj,cameraViewMatrix:()=>rj,cameraWorldMatrix:()=>ij,cbrt:()=>aj,cdl:()=>oj,ceil:()=>sj,checker:()=>cj,cineonToneMapping:()=>lj,clamp:()=>uj,clearcoat:()=>dj,clearcoatRoughness:()=>fj,code:()=>pj,color:()=>mj,colorSpaceToWorking:()=>hj,colorToDirection:()=>gj,compute:()=>_j,computeSkinning:()=>vj,cond:()=>yj,context:()=>xj,convert:()=>Sj,convertColorSpace:()=>Cj,convertToTexture:()=>wj,cos:()=>Tj,cross:()=>Ej,cubeTexture:()=>Dj,dFdx:()=>Oj,dFdy:()=>kj,dashSize:()=>Aj,debug:()=>jj,decrement:()=>Mj,decrementBefore:()=>Nj,defaultBuildStages:()=>Pj,defaultShaderStages:()=>Fj,defined:()=>Ij,degrees:()=>Lj,deltaTime:()=>Rj,densityFog:()=>zj,densityFogFactor:()=>Bj,depth:()=>Vj,depthPass:()=>Hj,difference:()=>Uj,diffuseColor:()=>Wj,directPointLight:()=>Gj,directionToColor:()=>Kj,dispersion:()=>qj,distance:()=>Jj,div:()=>Yj,dodge:()=>Xj,dot:()=>Zj,drawIndex:()=>Qj,dynamicBufferAttribute:()=>$j,element:()=>eM,emissive:()=>tM,equal:()=>nM,equals:()=>rM,equirectUV:()=>iM,exp:()=>aM,exp2:()=>oM,expression:()=>sM,faceDirection:()=>cM,faceForward:()=>lM,faceforward:()=>uM,float:()=>dM,floor:()=>fM,fog:()=>pM,fract:()=>mM,frameGroup:()=>hM,frameId:()=>gM,frontFacing:()=>_M,fwidth:()=>vM,gain:()=>yM,gapSize:()=>bM,getConstNodeType:()=>xM,getCurrentStack:()=>SM,getDirection:()=>CM,getDistanceAttenuation:()=>wM,getGeometryRoughness:()=>TM,getNormalFromDepth:()=>EM,getParallaxCorrectNormal:()=>DM,getRoughness:()=>OM,getScreenPosition:()=>kM,getShIrradianceAt:()=>AM,getShadowMaterial:()=>One,getShadowRenderObjectFunction:()=>kne,getTextureIndex:()=>Ene,getViewPosition:()=>Dne,globalId:()=>xre,glsl:()=>Ane,glslFn:()=>jne,grayscale:()=>Mne,greaterThan:()=>Nne,greaterThanEqual:()=>Pne,hash:()=>Fne,highpModelNormalViewMatrix:()=>Ine,highpModelViewMatrix:()=>Lne,hue:()=>Rne,increment:()=>zne,incrementBefore:()=>Bne,instance:()=>Vne,instanceIndex:()=>Hne,instancedArray:()=>Une,instancedBufferAttribute:()=>Wne,instancedDynamicBufferAttribute:()=>Gne,instancedMesh:()=>Kne,int:()=>qne,inverseSqrt:()=>Jne,inversesqrt:()=>Yne,invocationLocalIndex:()=>Xne,invocationSubgroupIndex:()=>Zne,ior:()=>Qne,iridescence:()=>$ne,iridescenceIOR:()=>ere,iridescenceThickness:()=>tre,ivec2:()=>nre,ivec3:()=>rre,ivec4:()=>ire,js:()=>are,label:()=>ore,length:()=>sre,lengthSq:()=>cre,lessThan:()=>lre,lessThanEqual:()=>ure,lightPosition:()=>dre,lightProjectionUV:()=>nN,lightShadowMatrix:()=>fre,lightTargetDirection:()=>pre,lightTargetPosition:()=>mre,lightViewPosition:()=>hre,lightingContext:()=>gre,lights:()=>_re,linearDepth:()=>vre,linearToneMapping:()=>yre,localId:()=>bre,log:()=>Sre,log2:()=>Cre,logarithmicDepthToViewZ:()=>wre,loop:()=>Tre,luminance:()=>Ere,mat2:()=>Ore,mat3:()=>kre,mat4:()=>Are,matcapUV:()=>jre,materialAO:()=>Mre,materialAlphaTest:()=>Nre,materialAnisotropy:()=>Pre,materialAnisotropyVector:()=>Fre,materialAttenuationColor:()=>Ire,materialAttenuationDistance:()=>Lre,materialClearcoat:()=>Rre,materialClearcoatNormal:()=>zre,materialClearcoatRoughness:()=>Bre,materialColor:()=>Vre,materialDispersion:()=>Hre,materialEmissive:()=>Ure,materialIOR:()=>Wre,materialIridescence:()=>Gre,materialIridescenceIOR:()=>Kre,materialIridescenceThickness:()=>qre,materialLightMap:()=>Jre,materialLineDashOffset:()=>Yre,materialLineDashSize:()=>Xre,materialLineGapSize:()=>Zre,materialLineScale:()=>Qre,materialLineWidth:()=>$re,materialMetalness:()=>eie,materialNormal:()=>tie,materialOpacity:()=>nie,materialPointSize:()=>rie,materialReference:()=>iie,materialReflectivity:()=>aie,materialRefractionRatio:()=>oie,materialRotation:()=>sie,materialRoughness:()=>cie,materialSheen:()=>lie,materialSheenRoughness:()=>uie,materialShininess:()=>die,materialSpecular:()=>fie,materialSpecularColor:()=>pie,materialSpecularIntensity:()=>mie,materialSpecularStrength:()=>hie,materialThickness:()=>gie,materialTransmission:()=>_ie,max:()=>jM,maxMipLevel:()=>vie,mediumpModelViewMatrix:()=>Dre,metalness:()=>yie,min:()=>bie,mix:()=>MM,mixElement:()=>xie,mod:()=>Sie,modInt:()=>Cie,modelDirection:()=>wie,modelNormalMatrix:()=>Tie,modelPosition:()=>Eie,modelRadius:()=>Die,modelScale:()=>Oie,modelViewMatrix:()=>kie,modelViewPosition:()=>Aie,modelViewProjection:()=>jie,modelWorldMatrix:()=>Mie,modelWorldMatrixInverse:()=>Nie,morphReference:()=>Pie,mrt:()=>Fie,mul:()=>NM,mx_aastep:()=>Iie,mx_cell_noise_float:()=>Lie,mx_contrast:()=>Rie,mx_fractal_noise_float:()=>zie,mx_fractal_noise_vec2:()=>Bie,mx_fractal_noise_vec3:()=>Vie,mx_fractal_noise_vec4:()=>Hie,mx_hsvtorgb:()=>Uie,mx_noise_float:()=>Wie,mx_noise_vec3:()=>Gie,mx_noise_vec4:()=>Kie,mx_ramplr:()=>qie,mx_ramptb:()=>Jie,mx_rgbtohsv:()=>Yie,mx_safepower:()=>Xie,mx_splitlr:()=>Zie,mx_splittb:()=>Qie,mx_srgb_texture_to_lin_rec709:()=>$ie,mx_transform_uv:()=>eae,mx_worley_noise_float:()=>tae,mx_worley_noise_vec2:()=>nae,mx_worley_noise_vec3:()=>rae,namespace:()=>iae,negate:()=>aae,neutralToneMapping:()=>oae,nodeArray:()=>sae,nodeImmutable:()=>cae,nodeObject:()=>lae,nodeObjects:()=>uae,nodeProxy:()=>dae,normalFlat:()=>fae,normalGeometry:()=>pae,normalLocal:()=>mae,normalMap:()=>hae,normalView:()=>gae,normalWorld:()=>_ae,normalize:()=>vae,not:()=>yae,notEqual:()=>bae,numWorkgroups:()=>xae,objectDirection:()=>Sae,objectGroup:()=>Cae,objectPosition:()=>wae,objectRadius:()=>Tae,objectScale:()=>Eae,objectViewPosition:()=>Dae,objectWorldMatrix:()=>Oae,oneMinus:()=>kae,or:()=>Aae,orthographicDepthToViewZ:()=>jae,oscSawtooth:()=>Mae,oscSine:()=>Nae,oscSquare:()=>Pae,oscTriangle:()=>Fae,output:()=>Iae,outputStruct:()=>Lae,overlay:()=>Rae,overloadingFn:()=>zae,parabola:()=>Bae,parallaxDirection:()=>Vae,parallaxUV:()=>Hae,parameter:()=>Uae,pass:()=>Wae,passTexture:()=>Gae,pcurve:()=>Kae,perspectiveDepthToViewZ:()=>qae,pmremTexture:()=>Jae,pointShadow:()=>BN,pointUV:()=>PM,pointWidth:()=>FM,positionGeometry:()=>IM,positionLocal:()=>LM,positionPrevious:()=>RM,positionView:()=>zM,positionViewDirection:()=>BM,positionWorld:()=>VM,positionWorldDirection:()=>HM,posterize:()=>UM,pow:()=>WM,pow2:()=>GM,pow3:()=>KM,pow4:()=>qM,premult:()=>JM,property:()=>YM,radians:()=>XM,rand:()=>ZM,range:()=>QM,rangeFog:()=>$M,rangeFogFactor:()=>eN,reciprocal:()=>tN,reference:()=>rN,referenceBuffer:()=>iN,reflect:()=>aN,reflectVector:()=>oN,reflectView:()=>sN,reflector:()=>cN,refract:()=>lN,refractVector:()=>uN,refractView:()=>dN,reinhardToneMapping:()=>fN,remainder:()=>pN,remap:()=>mN,remapClamp:()=>hN,renderGroup:()=>gN,renderOutput:()=>_N,rendererReference:()=>vN,rotate:()=>yN,rotateUV:()=>bN,roughness:()=>xN,round:()=>SN,rtt:()=>CN,sRGBTransferEOTF:()=>wN,sRGBTransferOETF:()=>TN,sampler:()=>EN,samplerComparison:()=>DN,saturate:()=>ON,saturation:()=>kN,screen:()=>AN,screenCoordinate:()=>jN,screenSize:()=>MN,screenUV:()=>NN,scriptable:()=>PN,scriptableValue:()=>FN,select:()=>IN,setCurrentStack:()=>LN,shaderStages:()=>RN,shadow:()=>zN,shadowPositionWorld:()=>VN,shapeCircle:()=>UN,sharedUniformGroup:()=>HN,sheen:()=>WN,sheenRoughness:()=>GN,shiftLeft:()=>KN,shiftRight:()=>qN,shininess:()=>JN,sign:()=>YN,sin:()=>XN,sinc:()=>ZN,skinning:()=>QN,smoothstep:()=>$N,smoothstepElement:()=>eP,specularColor:()=>tP,specularF90:()=>nP,spherizeUV:()=>rP,split:()=>iP,spritesheetUV:()=>aP,sqrt:()=>oP,stack:()=>sP,step:()=>cP,storage:()=>lP,storageBarrier:()=>uP,storageObject:()=>dP,storageTexture:()=>fP,string:()=>pP,struct:()=>mP,sub:()=>hP,subgroupIndex:()=>gP,subgroupSize:()=>_P,tan:()=>vP,tangentGeometry:()=>yP,tangentLocal:()=>bP,tangentView:()=>xP,tangentWorld:()=>SP,temp:()=>CP,texture:()=>wP,texture3D:()=>TP,textureBarrier:()=>EP,textureBicubic:()=>DP,textureCubeUV:()=>OP,textureLoad:()=>kP,textureSize:()=>AP,textureStore:()=>jP,thickness:()=>MP,time:()=>NP,timerDelta:()=>PP,timerGlobal:()=>FP,timerLocal:()=>IP,toneMapping:()=>LP,toneMappingExposure:()=>RP,toonOutlinePass:()=>zP,transformDirection:()=>BP,transformNormal:()=>VP,transformNormalToView:()=>HP,transformedBentNormalView:()=>UP,transformedBitangentView:()=>WP,transformedBitangentWorld:()=>GP,transformedClearcoatNormalView:()=>KP,transformedNormalView:()=>qP,transformedNormalWorld:()=>JP,transformedTangentView:()=>YP,transformedTangentWorld:()=>XP,transmission:()=>ZP,transpose:()=>QP,triNoise3D:()=>$P,triplanarTexture:()=>eF,triplanarTextures:()=>tF,trunc:()=>nF,tslFn:()=>rF,uint:()=>iF,uniform:()=>aF,uniformArray:()=>sF,uniformCubeTexture:()=>oF,uniformGroup:()=>cF,uniformTexture:()=>lF,uniforms:()=>uF,unpremult:()=>dF,userData:()=>fF,uv:()=>pF,uvec2:()=>mF,uvec3:()=>hF,uvec4:()=>gF,varying:()=>vF,varyingProperty:()=>yF,vec2:()=>bF,vec3:()=>xF,vec4:()=>SF,vectorComponents:()=>CF,velocity:()=>wF,vertexColor:()=>TF,vertexIndex:()=>EF,vibrance:()=>DF,viewZToLogarithmicDepth:()=>OF,viewZToOrthographicDepth:()=>kF,viewZToPerspectiveDepth:()=>AF,viewport:()=>jF,viewportBottomLeft:()=>MF,viewportCoordinate:()=>NF,viewportDepthTexture:()=>PF,viewportLinearDepth:()=>FF,viewportMipTexture:()=>IF,viewportResolution:()=>LF,viewportSafeUV:()=>RF,viewportSharedTexture:()=>zF,viewportSize:()=>BF,viewportTexture:()=>VF,viewportTopLeft:()=>HF,viewportUV:()=>UF,wgsl:()=>WF,wgslFn:()=>GF,workgroupArray:()=>KF,workgroupBarrier:()=>qF,workgroupId:()=>JF,workingToColorSpace:()=>YF,xor:()=>XF});const lk=I.BRDF_GGX,uk=I.BRDF_Lambert,dk=I.BasicShadowFilter,fk=I.Break,pk=I.Continue,mk=I.DFGApprox,hk=I.D_GGX,gk=I.Discard,_k=I.EPSILON,vk=I.F_Schlick,yk=I.Fn,bk=I.INFINITY,xk=I.If,Sk=I.Switch,Ck=I.Loop,wk=I.NodeShaderStage,Tk=I.NodeType,Ek=I.NodeUpdateType,Dk=I.NodeAccess,Ok=I.PCFShadowFilter,kk=I.PCFSoftShadowFilter,Ak=I.PI,jk=I.PI2,Mk=I.Return,Nk=I.Schlick_to_F0,Pk=I.ScriptableNodeResources,Fk=I.ShaderNode,Ik=I.TBNViewMatrix,Lk=I.VSMShadowFilter,Rk=I.V_GGX_SmithCorrelated,zk=I.abs,Bk=I.acesFilmicToneMapping,Vk=I.acos,Hk=I.add,Uk=I.addNodeElement,Wk=I.agxToneMapping,Gk=I.all,Kk=I.alphaT,qk=I.and,Jk=I.anisotropy,Yk=I.anisotropyB,Xk=I.anisotropyT,Zk=I.any,Qk=I.append,$k=I.array,eA=I.arrayBuffer,tA=I.asin,nA=I.assign,rA=I.atan,iA=I.atan2,aA=I.atomicAdd,oA=I.atomicAnd,sA=I.atomicFunc,cA=I.atomicMax,lA=I.atomicMin,uA=I.atomicOr,dA=I.atomicStore,fA=I.atomicSub,pA=I.atomicXor,mA=I.atomicLoad,hA=I.attenuationColor,gA=I.attenuationDistance,_A=I.attribute,vA=I.attributeArray,yA=I.backgroundBlurriness,bA=I.backgroundIntensity,xA=I.backgroundRotation,SA=I.batch,CA=I.billboarding,wA=I.bitAnd,TA=I.bitNot,EA=I.bitOr,DA=I.bitXor,OA=I.bitangentGeometry,kA=I.bitangentLocal,AA=I.bitangentView,jA=I.bitangentWorld,MA=I.bitcast,NA=I.blendBurn,PA=I.blendColor,FA=I.blendDodge,IA=I.blendOverlay,LA=I.blendScreen,RA=I.blur,zA=I.bool,BA=I.buffer,VA=I.bufferAttribute,HA=I.bumpMap,UA=I.burn,WA=I.bvec2,GA=I.bvec3,KA=I.bvec4,qA=I.bypass,JA=I.cache,YA=I.call,XA=I.cameraFar,ZA=I.cameraIndex,QA=I.cameraNear,$A=I.cameraNormalMatrix,ej=I.cameraPosition,tj=I.cameraProjectionMatrix,nj=I.cameraProjectionMatrixInverse,rj=I.cameraViewMatrix,ij=I.cameraWorldMatrix,aj=I.cbrt,oj=I.cdl,sj=I.ceil,cj=I.checker,lj=I.cineonToneMapping,uj=I.clamp,dj=I.clearcoat,fj=I.clearcoatRoughness,pj=I.code,mj=I.color,hj=I.colorSpaceToWorking,gj=I.colorToDirection,_j=I.compute,vj=I.computeSkinning,yj=I.cond,bj=I.Const,xj=I.context,Sj=I.convert,Cj=I.convertColorSpace,wj=I.convertToTexture,Tj=I.cos,Ej=I.cross,Dj=I.cubeTexture,Oj=I.dFdx,kj=I.dFdy,Aj=I.dashSize,jj=I.debug,Mj=I.decrement,Nj=I.decrementBefore,Pj=I.defaultBuildStages,Fj=I.defaultShaderStages,Ij=I.defined,Lj=I.degrees,Rj=I.deltaTime,zj=I.densityFog,Bj=I.densityFogFactor,Vj=I.depth,Hj=I.depthPass,Uj=I.difference,Wj=I.diffuseColor,Gj=I.directPointLight,Kj=I.directionToColor,qj=I.dispersion,Jj=I.distance,Yj=I.div,Xj=I.dodge,Zj=I.dot,Qj=I.drawIndex,$j=I.dynamicBufferAttribute,eM=I.element,tM=I.emissive,nM=I.equal,rM=I.equals,iM=I.equirectUV,aM=I.exp,oM=I.exp2,sM=I.expression,cM=I.faceDirection,lM=I.faceForward,uM=I.faceforward,dM=I.float,fM=I.floor,pM=I.fog,mM=I.fract,hM=I.frameGroup,gM=I.frameId,_M=I.frontFacing,vM=I.fwidth,yM=I.gain,bM=I.gapSize,xM=I.getConstNodeType,SM=I.getCurrentStack,CM=I.getDirection,wM=I.getDistanceAttenuation,TM=I.getGeometryRoughness,EM=I.getNormalFromDepth,DM=I.getParallaxCorrectNormal,OM=I.getRoughness,kM=I.getScreenPosition,AM=I.getShIrradianceAt,Ene=I.getTextureIndex,Dne=I.getViewPosition,One=I.getShadowMaterial,kne=I.getShadowRenderObjectFunction,Ane=I.glsl,jne=I.glslFn,Mne=I.grayscale,Nne=I.greaterThan,Pne=I.greaterThanEqual,Fne=I.hash,Ine=I.highpModelNormalViewMatrix,Lne=I.highpModelViewMatrix,Rne=I.hue,zne=I.increment,Bne=I.incrementBefore,Vne=I.instance,Hne=I.instanceIndex,Une=I.instancedArray,Wne=I.instancedBufferAttribute,Gne=I.instancedDynamicBufferAttribute,Kne=I.instancedMesh,qne=I.int,Jne=I.inverseSqrt,Yne=I.inversesqrt,Xne=I.invocationLocalIndex,Zne=I.invocationSubgroupIndex,Qne=I.ior,$ne=I.iridescence,ere=I.iridescenceIOR,tre=I.iridescenceThickness,nre=I.ivec2,rre=I.ivec3,ire=I.ivec4,are=I.js,ore=I.label,sre=I.length,cre=I.lengthSq,lre=I.lessThan,ure=I.lessThanEqual,dre=I.lightPosition,fre=I.lightShadowMatrix,pre=I.lightTargetDirection,mre=I.lightTargetPosition,hre=I.lightViewPosition,gre=I.lightingContext,_re=I.lights,vre=I.linearDepth,yre=I.linearToneMapping,bre=I.localId,xre=I.globalId,Sre=I.log,Cre=I.log2,wre=I.logarithmicDepthToViewZ,Tre=I.loop,Ere=I.luminance,Dre=I.mediumpModelViewMatrix,Ore=I.mat2,kre=I.mat3,Are=I.mat4,jre=I.matcapUV,Mre=I.materialAO,Nre=I.materialAlphaTest,Pre=I.materialAnisotropy,Fre=I.materialAnisotropyVector,Ire=I.materialAttenuationColor,Lre=I.materialAttenuationDistance,Rre=I.materialClearcoat,zre=I.materialClearcoatNormal,Bre=I.materialClearcoatRoughness,Vre=I.materialColor,Hre=I.materialDispersion,Ure=I.materialEmissive,Wre=I.materialIOR,Gre=I.materialIridescence,Kre=I.materialIridescenceIOR,qre=I.materialIridescenceThickness,Jre=I.materialLightMap,Yre=I.materialLineDashOffset,Xre=I.materialLineDashSize,Zre=I.materialLineGapSize,Qre=I.materialLineScale,$re=I.materialLineWidth,eie=I.materialMetalness,tie=I.materialNormal,nie=I.materialOpacity,rie=I.materialPointSize,iie=I.materialReference,aie=I.materialReflectivity,oie=I.materialRefractionRatio,sie=I.materialRotation,cie=I.materialRoughness,lie=I.materialSheen,uie=I.materialSheenRoughness,die=I.materialShininess,fie=I.materialSpecular,pie=I.materialSpecularColor,mie=I.materialSpecularIntensity,hie=I.materialSpecularStrength,gie=I.materialThickness,_ie=I.materialTransmission,jM=I.max,vie=I.maxMipLevel,yie=I.metalness,bie=I.min,MM=I.mix,xie=I.mixElement,Sie=I.mod,Cie=I.modInt,wie=I.modelDirection,Tie=I.modelNormalMatrix,Eie=I.modelPosition,Die=I.modelRadius,Oie=I.modelScale,kie=I.modelViewMatrix,Aie=I.modelViewPosition,jie=I.modelViewProjection,Mie=I.modelWorldMatrix,Nie=I.modelWorldMatrixInverse,Pie=I.morphReference,Fie=I.mrt,NM=I.mul,Iie=I.mx_aastep,Lie=I.mx_cell_noise_float,Rie=I.mx_contrast,zie=I.mx_fractal_noise_float,Bie=I.mx_fractal_noise_vec2,Vie=I.mx_fractal_noise_vec3,Hie=I.mx_fractal_noise_vec4,Uie=I.mx_hsvtorgb,Wie=I.mx_noise_float,Gie=I.mx_noise_vec3,Kie=I.mx_noise_vec4,qie=I.mx_ramplr,Jie=I.mx_ramptb,Yie=I.mx_rgbtohsv,Xie=I.mx_safepower,Zie=I.mx_splitlr,Qie=I.mx_splittb,$ie=I.mx_srgb_texture_to_lin_rec709,eae=I.mx_transform_uv,tae=I.mx_worley_noise_float,nae=I.mx_worley_noise_vec2,rae=I.mx_worley_noise_vec3,iae=I.namespace,aae=I.negate,oae=I.neutralToneMapping,sae=I.nodeArray,cae=I.nodeImmutable,lae=I.nodeObject,uae=I.nodeObjects,dae=I.nodeProxy,fae=I.normalFlat,pae=I.normalGeometry,mae=I.normalLocal,hae=I.normalMap,gae=I.normalView,_ae=I.normalWorld,vae=I.normalize,yae=I.not,bae=I.notEqual,xae=I.numWorkgroups,Sae=I.objectDirection,Cae=I.objectGroup,wae=I.objectPosition,Tae=I.objectRadius,Eae=I.objectScale,Dae=I.objectViewPosition,Oae=I.objectWorldMatrix,kae=I.oneMinus,Aae=I.or,jae=I.orthographicDepthToViewZ,Mae=I.oscSawtooth,Nae=I.oscSine,Pae=I.oscSquare,Fae=I.oscTriangle,Iae=I.output,Lae=I.outputStruct,Rae=I.overlay,zae=I.overloadingFn,Bae=I.parabola,Vae=I.parallaxDirection,Hae=I.parallaxUV,Uae=I.parameter,Wae=I.pass,Gae=I.passTexture,Kae=I.pcurve,qae=I.perspectiveDepthToViewZ,Jae=I.pmremTexture,PM=I.pointUV,FM=I.pointWidth,IM=I.positionGeometry,LM=I.positionLocal,RM=I.positionPrevious,zM=I.positionView,BM=I.positionViewDirection,VM=I.positionWorld,HM=I.positionWorldDirection,UM=I.posterize,WM=I.pow,GM=I.pow2,KM=I.pow3,qM=I.pow4,JM=I.premult,YM=I.property,XM=I.radians,ZM=I.rand,QM=I.range,$M=I.rangeFog,eN=I.rangeFogFactor,tN=I.reciprocal,nN=I.lightProjectionUV,rN=I.reference,iN=I.referenceBuffer,aN=I.reflect,oN=I.reflectVector,sN=I.reflectView,cN=I.reflector,lN=I.refract,uN=I.refractVector,dN=I.refractView,fN=I.reinhardToneMapping,pN=I.remainder,mN=I.remap,hN=I.remapClamp,gN=I.renderGroup,_N=I.renderOutput,vN=I.rendererReference,yN=I.rotate,bN=I.rotateUV,xN=I.roughness,SN=I.round,CN=I.rtt,wN=I.sRGBTransferEOTF,TN=I.sRGBTransferOETF,EN=I.sampler,DN=I.samplerComparison,ON=I.saturate,kN=I.saturation,AN=I.screen,jN=I.screenCoordinate,MN=I.screenSize,NN=I.screenUV,PN=I.scriptable,FN=I.scriptableValue,IN=I.select,LN=I.setCurrentStack,RN=I.shaderStages,zN=I.shadow,BN=I.pointShadow,VN=I.shadowPositionWorld,HN=I.sharedUniformGroup,UN=I.shapeCircle,WN=I.sheen,GN=I.sheenRoughness,KN=I.shiftLeft,qN=I.shiftRight,JN=I.shininess,YN=I.sign,XN=I.sin,ZN=I.sinc,QN=I.skinning,$N=I.smoothstep,eP=I.smoothstepElement,tP=I.specularColor,nP=I.specularF90,rP=I.spherizeUV,iP=I.split,aP=I.spritesheetUV,oP=I.sqrt,sP=I.stack,cP=I.step,lP=I.storage,uP=I.storageBarrier,dP=I.storageObject,fP=I.storageTexture,pP=I.string,mP=I.struct,hP=I.sub,gP=I.subgroupIndex,_P=I.subgroupSize,vP=I.tan,yP=I.tangentGeometry,bP=I.tangentLocal,xP=I.tangentView,SP=I.tangentWorld,CP=I.temp,wP=I.texture,TP=I.texture3D,EP=I.textureBarrier,DP=I.textureBicubic,OP=I.textureCubeUV,kP=I.textureLoad,AP=I.textureSize,jP=I.textureStore,MP=I.thickness,NP=I.time,PP=I.timerDelta,FP=I.timerGlobal,IP=I.timerLocal,LP=I.toneMapping,RP=I.toneMappingExposure,zP=I.toonOutlinePass,BP=I.transformDirection,VP=I.transformNormal,HP=I.transformNormalToView,UP=I.transformedBentNormalView,WP=I.transformedBitangentView,GP=I.transformedBitangentWorld,KP=I.transformedClearcoatNormalView,qP=I.transformedNormalView,JP=I.transformedNormalWorld,YP=I.transformedTangentView,XP=I.transformedTangentWorld,ZP=I.transmission,QP=I.transpose,$P=I.triNoise3D,eF=I.triplanarTexture,tF=I.triplanarTextures,nF=I.trunc,rF=I.tslFn,iF=I.uint,aF=I.uniform,oF=I.uniformCubeTexture,sF=I.uniformArray,cF=I.uniformGroup,lF=I.uniformTexture,uF=I.uniforms,dF=I.unpremult,fF=I.userData,pF=I.uv,mF=I.uvec2,hF=I.uvec3,gF=I.uvec4,_F=I.Var,vF=I.varying,yF=I.varyingProperty,bF=I.vec2,xF=I.vec3,SF=I.vec4,CF=I.vectorComponents,wF=I.velocity,TF=I.vertexColor,EF=I.vertexIndex,DF=I.vibrance,OF=I.viewZToLogarithmicDepth,kF=I.viewZToOrthographicDepth,AF=I.viewZToPerspectiveDepth,jF=I.viewport,MF=I.viewportBottomLeft,NF=I.viewportCoordinate,PF=I.viewportDepthTexture,FF=I.viewportLinearDepth,IF=I.viewportMipTexture,LF=I.viewportResolution,RF=I.viewportSafeUV,zF=I.viewportSharedTexture,BF=I.viewportSize,VF=I.viewportTexture,HF=I.viewportTopLeft,UF=I.viewportUV,WF=I.wgsl,GF=I.wgslFn,KF=I.workgroupArray,qF=I.workgroupBarrier,JF=I.workgroupId,YF=I.workingToColorSpace,XF=I.xor;function ZF(e,t,n=1){let r=e.rgb,i=t.rgb,a=NM(r,i),o=NM(t.a,n),s=MM(r,a,o),c=jM(e.a,NM(t.a,n));return SF(s,c)}function QF(e,t,n=1){let r=NM(t.a,n),i=Hk(r,NM(e.a,hP(1,r))),a=Hk(NM(t.rgb,r),NM(e.rgb,NM(e.a,hP(1,r))));return SF(a,i)}const $F={normal:QF,multiply:ZF};function eI(e,t,n=`normal`,r=1){let i=$F[n]||$F.normal;return i(e,t,r)}function Yae(e,t){let n=NM(e.a,t.a);return SF(e.rgb,n)}function tI(e,t){let n=hP(1,t.a),r=NM(e.a,n);return SF(e.rgb,r)}function nI(e,t){let n=xF(.2126,.7152,.0722),r=Zj(t.rgb,n),i=NM(e.a,r);return SF(e.rgb,i)}function rI(e,t){let n=xF(.2126,.7152,.0722),r=Zj(t.rgb,n),i=hP(1,r),a=NM(e.a,i);return SF(e.rgb,a)}const iI={alpha:Yae,alphaInverted:tI,luminance:nI,luminanceInverted:rI};function aI(e,t,n=`alpha`){let r=iI[n]||iI.alpha;return r(e,t)}const oI={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let sI=null,cI=!1;const lI=()=>{try{if(oI!==void 0){let{MODE:e,DEV:t}=oI;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function uI(){let e,t,n,r,i,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,s=null,c=null,l=!1,u=!1,d=null,f=!1,p=!0,m=0,h=0,g=0,_=0,v=8,y=.5,b=.5,x=!1,S=!1,ee=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},te=(n,i)=>{if(n===m&&i===h)return;let o=performance.now();if(o-g<v)return;m=n,h=i,g=o,e.setSize(n,i,!1);let s=n/i,c=2,l=c*s;t.left=-l/2,t.right=l/2,t.top=c/2,t.bottom=-c/2,t.updateProjectionMatrix(),r.scale.set(l,c,1),a.rootId&&ie(),ge().catch(console.warn)},ne=n=>{if(!e||!t||!r)return;let i=n[0];if(!i)return;let{width:a,height:o}=i.contentRect,s=Math.round(a),c=Math.round(o);te(s,c)},re=e=>{let t=e[0];t&&(f=t.isIntersecting,f&&p?_e():ve())},ie=()=>{if(!a.rootId||!i||S)return;let e=a.nodes.get(a.rootId);if(e){S=!0;try{let e=le(a.rootId);e&&i&&(i.fragmentNode=e,i.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{S=!1}f&&ge()}},ae=e=>{let t=[];return a.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},oe=e=>{for(let[t,n]of a.nodes.entries())if(n.metadata.id===e)return t;return null},se=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=oe(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=le(s,c),u=t.metadata.mask.type||`alpha`;return aI(e,l,u)},ce=e=>{var t,n;let r=a.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of a.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},le=(e,t=new Set)=>{let n=a.nodes.get(e);if(!n)return SF(0,0,0,0);let r=e=>{n.cleanupCallbacks.push(e)},i=e=>{n.beforeRenderCallbacks.push(e)},o=e=>{n.afterRenderCallbacks.push(e)},s=ae(e);if(s.length===0){let a=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:void 0,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:sI});return se(a,n,e,t)}else{let a=[...s].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),c=n.parentId===null;if(c){let s;for(let e of a){if(e.metadata.opacity===0&&!ce(e.id))continue;let n=le(e.id,t),r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:eI(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:sI});return se(c,n,e,t)}else{let s;for(let e of a){let n=le(e.id,t);if(e.metadata.opacity===0&&!ce(e.id))continue;let r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:eI(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:sI});return se(c,n,e,t)}}},ue=(e,t,n,r,o={})=>{let s=0;if(n!==null){let e=Array.from(a.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(s=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity===void 0?1:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?s:r?.renderOrder},uniforms:o,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(e,c),n===null&&(a.rootId=e),i&&l&&ie()},de=(e,t,n)=>{let r=a.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,f&&ge()},fe=(e,t)=>{var n,r,o,s,c,u,d,p;let m=a.nodes.get(e);if(!m)return;let h=!1;t.blendMode!==void 0&&m.metadata.blendMode!==t.blendMode&&(m.metadata.blendMode=t.blendMode,h=!0),t.opacity!==void 0&&m.metadata.opacity!==t.opacity&&(m.metadata.opacity=t.opacity,h=!0),t.renderOrder!==void 0&&m.metadata.renderOrder!==t.renderOrder&&(m.metadata.renderOrder=t.renderOrder,h=!0),t.id!==void 0&&m.metadata.id!==t.id&&(m.metadata.id=t.id,h=!0),t.mask!==void 0&&((n=c=m.metadata.mask)?.source!==(r=u=t.mask)?.source||(o=d=m.metadata.mask)?.type!==(s=p=t.mask)?.type)&&(m.metadata.mask=t.mask,h=!0),h&&i&&l?ie():f&&ge()},pe=e=>{if(!a.nodes.has(e))return;let t=a.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=ae(e);for(let e of n)pe(e.id);a.rootId===e&&(a.rootId=null),a.nodes.delete(e),i&&l&&ie()},me=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},he=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},ge=async()=>{if(!l||!e||!n||!t||!i)return;let r=performance.now(),a=_>0?(r-_)/1e3:.016,o=Math.min(a,.1);_=r,me(o);try{if(S)return;e instanceof sk?await e.renderAsync(n,t).then(()=>{l&&he(o)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(e.render(n,t),he(o))}catch(e){console.error(`Render frame error:`,e)}},_e=()=>{if(o||!p||!f)return;let e=()=>{o=requestAnimationFrame(e),ge()};e()},ve=()=>{o&&(cancelAnimationFrame(o),o=null)},ye=e=>{if(!sI)return;let t,n;if(`touches`in e){if(e.touches.length===0)return;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;let r=sI.getBoundingClientRect();y=Math.max(0,Math.min(1,(t-r.left)/r.width)),b=Math.max(0,Math.min(1,(n-r.top)/r.height))},be=async({canvas:o})=>{if(l||u)return;u=!0,d=new AbortController;let m=d;try{if(sI=o,n=new io,n.background=null,t=new gs(-1,1,1,-1,.1,10),t.position.z=1,t.lookAt(0,0,0),o.addEventListener(`mousemove`,ye),o.addEventListener(`touchmove`,ye),o.addEventListener(`mousedown`,()=>{x=!0,ge()}),o.addEventListener(`touchstart`,()=>{x=!0,ge()}),window.addEventListener(`mouseup`,()=>{x=!1,ge()}),window.addEventListener(`touchend`,()=>{x=!1,ge()}),m.signal.aborted)return;try{if(e=new sk({canvas:o,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await e.init(),m.signal.aborted){e.dispose();return}}catch(e){if(m.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(m.signal.aborted){e&&e.dispose();return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=hn,i=new Z_({transparent:!0}),a.nodes.size===0?i.fragmentNode=SF(0,0,0,0):ie();let u=new Do(2,2);r=new Ia(u,i),n.add(r),s=new ResizeObserver(ne),s.observe(o),c=new IntersectionObserver(re,{threshold:0}),c.observe(o),p=!ee();let{width:d,height:h}=o.getBoundingClientRect();te(Math.round(d),Math.round(h)),await ge(),p&&f&&_e(),m.signal.aborted||(l=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{u=!1,d===m&&(d=null)}},xe=()=>{!lI()||cI||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),cI=!0)},Se=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),sI&&(sI.removeEventListener(`mousemove`,ye),sI.removeEventListener(`touchmove`,ye),sI.removeEventListener(`mousedown`,()=>{x=!0}),sI.removeEventListener(`touchstart`,()=>{x=!0})),window&&(window.removeEventListener(`mouseup`,()=>{x=!1}),window.removeEventListener(`touchend`,()=>{x=!1})),ve(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),r&&(n&&n.remove(r),r.geometry&&r.geometry.dispose(),r.material instanceof aa&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}sI=null,e=null,t=null,n=null,r=null,i=null,l=!1,u=!1,d=null,m=0,h=0,f=!1,p=!0,y=.5,b=.5,x=!1};return{initialize:be,cleanup:Se,registerNode:ue,removeNode:pe,updateUniformValue:de,updateNodeMetadata:fe,showLicenseWarning:xe}}const{uniform:dI}=ck;function fI(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:dI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:pI,fract:mI,sin:hI,dot:gI}=ck,_I=e=>mI(hI(gI(e,pI(12.12345,78.12345))).mul(40000.12345)),Xae=(e=.03)=>t=>_I(t).mul(e).mul(.10012345),{vec2:vI}=ck,Zae=(e=vI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=ck,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},Qae=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=ck,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},$ae=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=ck,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))};var yI=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),bI,xI;function SI(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function CI(e){return wI(e)===`string`}function wI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function TI(e,{precision:t,unit:n}){return EI(e)?`none`:OI(e,t)+(n??``)}function EI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function DI(e){return EI(e)?0:e}function OI(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const kI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function AI(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*kI[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function jI(e){return e[e.length-1]}function MI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function NI(e,t,n){return(n-e)/(t-e)}function PI(e,t,n){return MI(t[0],t[1],NI(e[0],e[1],n))}function FI(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function II(e,t,n){return Math.max(Math.min(n,t),e)}function LI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function RI(e,t){return LI(Math.abs(e)**t,e)}function zI(e,t){return t===0?0:e/t}function BI(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var VI=Object.freeze({__proto__:null,bisectLeft:BI,clamp:II,copySign:LI,interpolate:MI,interpolateInv:NI,isNone:EI,isString:CI,last:jI,mapRange:PI,multiplyMatrices:SI,parseCoordGrammar:FI,parseFunction:AI,serializeNumber:TI,skipNone:DI,spow:RI,toPrecision:OI,type:wI,zdiv:zI}),HI=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const UI=new HI;var WI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((bI=globalThis)==null||(bI=bI.process)==null||(bI=bI.env)==null||(bI=bI.NODE_ENV)==null?void 0:bI.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const GI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function KI(e){return Array.isArray(e)?e:GI[e]}function qI(e,t,n,r={}){if(e=KI(e),t=KI(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(UI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===GI.D65&&i.W2===GI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===GI.D50&&i.W2===GI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),UI.run(`chromatic-adaptation-end`,i),i.M)return SI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const JI=new Set([`<number>`,`<percentage>`,`<angle>`]);function YI(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>JI.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=PI(u,d,r[a])),l});return i}function XI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(UI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=AI(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of $I.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=YI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&WI.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&WI.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in $I.registry?e:n;if(u in $I.registry){var s;let e=(s=$I.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of $I.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||jI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=YI(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of $I.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function ZI(e){if(Array.isArray(e))return e.map(ZI);if(!e)throw TypeError(`Empty color reference`);CI(e)&&(e=XI(e));let t=e.space||e.spaceId;return t instanceof $I||(e.space=$I.get(t)),e.alpha===void 0&&(e.alpha=1),e}const QI=75e-6;var $I=(xI=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=KI(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:eL(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),UI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=QI}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=tL(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=tL(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=ZI(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=ZI(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=wI(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=wI(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=wI(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},yI.defineProperty(xI,`registry`,{}),yI.defineProperty(xI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),xI);function eL(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function tL(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=FI(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=PI(i,a,e)),e=TI(e,{precision:t,unit:o}),e})}return e}var nL=new $I({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),rL=class extends $I{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=nL,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=SI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=qI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=qI(this.base.white,this.white,t),SI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function iL(e,t){return e=ZI(e),!t||e.space.equals(t)?e.coords.slice():(t=$I.get(t),t.from(e))}function aL(e,t){e=ZI(e);let{space:n,index:r}=$I.resolveCoord(t,e.space),i=iL(e,n);return i[r]}function oL(e,t,n){return e=ZI(e),t=$I.get(t),e.coords=t.to(e.space,n),e}oL.returns=`color`;function sL(e,t,n){if(e=ZI(e),arguments.length===2&&wI(arguments[1])===`object`){let t=arguments[1];for(let n in t)sL(e,n,t[n])}else{typeof n==`function`&&(n=n(aL(e,t)));let{space:r,index:i}=$I.resolveCoord(t,e.space),a=iL(e,r);a[i]=n,oL(e,r,a)}return e}sL.returns=`color`;var cL=new $I({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:nL,fromBase:e=>qI(nL.white,`D50`,e),toBase:e=>qI(`D50`,nL.white,e)});const lL=216/24389,uL=24/116,dL=24389/27;let fL=GI.D50;var pL=new $I({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:fL,base:cL,fromBase(e){let t=e.map((e,t)=>e/fL[t]),n=t.map(e=>e>lL?Math.cbrt(e):(dL*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>uL?t[0]**3:(116*t[0]-16)/dL,e[0]>8?((e[0]+16)/116)**3:e[0]/dL,t[2]>uL?t[2]**3:(116*t[2]-16)/dL];return n.map((e,t)=>e*fL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function mL(e){return(e%360+360)%360}function hL(e,t){if(e===`raw`)return t;let[n,r]=t.map(mL),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var gL=new $I({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:pL,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),mL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const _L=25**7,vL=Math.PI,yL=180/vL,bL=vL/180;function xL(e){let t=e*e,n=t*t*t*e;return n}function SL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=ZI([e,t]);let[a,o,s]=pL.from(e),c=gL.from(pL,[a,o,s])[1],[l,u,d]=pL.from(t),f=gL.from(pL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=xL(p),h=.5*(1-Math.sqrt(m/(m+_L))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*vL),x<0&&(x+=2*vL),b*=yL,x*=yL;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:WI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*bL/2),oe=(a+l)/2,se=(v+y)/2,ce=xL(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*bL),pe+=.24*Math.cos(2*le*bL),pe+=.32*Math.cos((3*le+6)*bL),pe-=.2*Math.cos((4*le-63)*bL);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+_L)),_e=-1*Math.sin(2*he*bL)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const CL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],wL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],TL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],EL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var DL=new $I({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:nL,fromBase(e){let t=SI(CL,e),n=t.map(e=>Math.cbrt(e));return SI(TL,n)},toBase(e){let t=SI(EL,e),n=t.map(e=>e**3);return SI(wL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function OL(e,t){[e,t]=ZI([e,t]);let[n,r,i]=DL.from(e),[a,o,s]=DL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const kL=75e-6;function AL(e,t,{epsilon:n=kL}={}){e=ZI(e),t||=e.space,t=$I.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function jL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function ML(e,t,n=`lab`){n=$I.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function NL(e,t){return ML(e,t,`lab`)}const PL=Math.PI,FL=PL/180;function IL(e,t,{l:n=2,c:r=1}={}){[e,t]=ZI([e,t]);let[i,a,o]=pL.from(e),[,s,c]=gL.from(pL,[i,a,o]),[l,u,d]=pL.from(t),f=gL.from(pL,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*FL)):.36+Math.abs(.4*Math.cos((c+35)*FL));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const LL=203;var RL=new $I({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:nL,fromBase(e){return e.map(e=>Math.max(e*LL,0))},toBase(e){return e.map(e=>Math.max(e/LL,0))}});const zL=1.15,BL=.66,VL=2610/2**14,HL=2**14/2610,UL=3424/2**12,WL=2413/2**7,GL=2392/2**7,KL=1.7*2523/2**5,qL=2**5/(1.7*2523),JL=-.56,YL=16295499532821565e-27,XL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],ZL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],QL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],$L=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var eR=new $I({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:RL,fromBase(e){let[t,n,r]=e,i=zL*t-(zL-1)*r,a=BL*n-(BL-1)*t,o=SI(XL,[i,a,r]),s=o.map(function(e){let t=UL+WL*(e/1e4)**VL,n=1+GL*(e/1e4)**VL;return(t/n)**KL}),[c,l,u]=SI(QL,s),d=(1+JL)*c/(1+JL*c)-YL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+YL)/(1+JL-JL*(t+YL)),a=SI($L,[i,n,r]),o=a.map(function(e){let t=UL-e**qL,n=GL*e**qL-WL,r=1e4*(t/n)**HL;return r}),[s,c,l]=SI(ZL,o),u=(s+(zL-1)*l)/zL,d=(c+(BL-1)*u)/BL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),tR=new $I({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:eR,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),mL(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function nR(e,t){[e,t]=ZI([e,t]);let[n,r,i]=tR.from(e),[a,o,s]=tR.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const rR=3424/4096,iR=2413/128,aR=2392/128,oR=2610/16384,sR=2523/32,cR=16384/2610,lR=32/2523,uR=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],dR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],fR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],pR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var mR=new $I({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:RL,fromBase(e){let t=SI(uR,e);return hR(t)},toBase(e){let t=gR(e);return SI(pR,t)}});function hR(e){let t=e.map(function(e){let t=rR+iR*(e/1e4)**oR,n=1+aR*(e/1e4)**oR;return(t/n)**sR});return SI(dR,t)}function gR(e){let t=SI(fR,e),n=t.map(function(e){let t=Math.max(e**lR-rR,0),n=iR-aR*e**lR;return 1e4*(t/n)**cR});return n}function _R(e,t){[e,t]=ZI([e,t]);let[n,r,i]=mR.from(e),[a,o,s]=mR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const vR=GI.D65,yR=.42,bR=1/yR,xR=2*Math.PI,SR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],CR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],wR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],TR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},ER={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},DR=180/Math.PI,OR=Math.PI/180;function kR(e,t){let n=e.map(e=>{let n=RI(t*Math.abs(e)*.01,yR);return 400*LI(n,e)/(n+27.13)});return n}function AR(e,t){let n=100/t*27.13**bR;return e.map(e=>{let t=Math.abs(e);return LI(n*RI(t/(400-t),bR),e)})}function jR(e){let t=mL(e);t<=ER.h[0]&&(t+=360);let n=BI(ER.h,t)-1,[r,i]=ER.h.slice(n,n+2),[a,o]=ER.e.slice(n,n+2),s=ER.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function MR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=ER.h.slice(n,n+2),[a,o]=ER.e.slice(n,n+2);return mL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function NR(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=SI(SR,o);r=TR[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>MI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=kR(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const PR=NR(vR,64/Math.PI*.2,20,`average`,!1);function FR(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?MR(e.H)*OR:mL(e.h)*OR;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=RI(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=RI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*RI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*zI(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=AR(SI(wR,[d,p,m]).map(e=>e*1/1403),t.fl);return SI(CR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function IR(e,t){let n=e.map(e=>e*100),r=kR(SI(SR,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%xR+xR)%xR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*zI(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=RI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=RI(u/t.aW,.5*t.c*t.z),f=100*RI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=mL(o*DR),_=jR(g),v=50*RI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var LR=new $I({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:nL,fromBase(e){let t=IR(e,PR);return[t.J,t.M,t.h]},toBase(e){return FR({J:e[0],M:e[1],h:e[2]},PR)}});const RR=GI.D65,zR=216/24389,BR=24389/27;function VR(e){let t=e>zR?Math.cbrt(e):(BR*e+16)/116;return 116*t-16}function HR(e){return e>8?((e+16)/116)**3:e/BR}function UR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=HR(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=FR({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return FR({J:o,C:r,h:n},t)}function WR(e,t){let n=VR(e[1]);if(n===0)return[0,0,0];let r=IR(e,GR);return[mL(r.h),r.C,n]}const GR=NR(RR,200/Math.PI*HR(50),HR(50)*100,`average`,!1);var KR=new $I({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:nL,fromBase(e){return WR(e)},toBase(e){return UR(e,GR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const qR=Math.PI/180,JR=[1,.007,.0228];function YR(e){e[1]<0&&(e=KR.fromBase(KR.toBase(e)));let t=Math.log(Math.max(1+JR[2]*e[1]*GR.flRoot,1))/JR[2],n=e[0]*qR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function XR(e,t){[e,t]=ZI([e,t]);let[n,r,i]=YR(KR.from(e)),[a,o,s]=YR(KR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var ZR={deltaE76:NL,deltaECMC:IL,deltaE2000:SL,deltaEJz:nR,deltaEITP:_R,deltaEOK:OL,deltaEHCT:XR};function QR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const $R={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function ez(e,{method:t=WI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=ZI(e),CI(arguments[1])?n=arguments[1]:n||=e.space,n=$I.get(n),AL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=nz(e,{space:n});else{if(t!==`clip`&&!AL(e,n)){Object.prototype.hasOwnProperty.call($R,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=$R[t]);let s=SL;if(r!==``){for(let e in ZR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=ZR[e];break}}let c=ez(rz(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=$I.resolveCoord(a.channel),n=aL(rz(e,t.space),t.id);if(EI(n)&&(n=0),n>=a.max)return rz({space:`xyz-d65`,coords:GI.D65},e.space);if(n<=a.min)return rz({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=$I.resolveCoord(t),c=r.space,l=r.id,u=rz(e,c);u.coords.forEach((e,t)=>{EI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=QR(i),m=f,h=aL(u,l);for(;h-m>p;){let e=jL(u);e=ez(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=aL(u,l):h=aL(u,l),sL(u,l,(m+h)/2)}o=rz(u,n)}else o=c}else o=rz(e,n);if(t===`clip`||!AL(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=rz(o,e.space)),e.coords=o.coords,e}ez.returns=`color`;const tz={WHITE:{space:DL,coords:[1,0,0]},BLACK:{space:DL,coords:[0,0,0]}};function nz(e,{space:t}={}){let n=.02,r=1e-4;e=ZI(e),t||=e.space,t=$I.get(t);let i=$I.get(`oklch`);if(t.isUnbounded)return rz(e,t);let a=rz(e,i),o=a.coords[0];if(o>=1){let n=rz(tz.WHITE,t);return n.alpha=e.alpha,rz(n,t)}if(o<=0){let n=rz(tz.BLACK,t);return n.alpha=e.alpha,rz(n,t)}if(AL(a,t,{epsilon:0}))return rz(a,t);function s(e){let n=rz(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return II(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=jL(a),f=s(d),p=OL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&AL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=OL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function rz(e,t,{inGamut:n}={}){e=ZI(e),t=$I.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=ez(i,n===!0?void 0:n)),i}rz.returns=`color`;function iz(e,{precision:t=WI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=ZI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??$I.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!AL(e)&&(s=ez(jL(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>TI(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=TI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const az=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],oz=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var sz=new rL({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:az,fromXYZ_M:oz});const cz=1.09929682680944,lz=.018053968510807;var uz=new rL({id:`rec2020`,name:`REC.2020`,base:sz,toBase(e){return e.map(function(e){return e<lz*4.5?e/4.5:((e+cz-1)/cz)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=lz?cz*e**.45-(cz-1):4.5*e})}});const dz=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var pz=new rL({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:dz,fromXYZ_M:fz});const mz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],hz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var gz=new rL({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:mz,fromXYZ_M:hz}),_z={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let vz=[,,,].fill(`<percentage> | <number>[0, 255]`),yz=[,,,].fill(`<number>[0, 255]`);var bz=new rL({id:`srgb`,name:`sRGB`,base:gz,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:vz},rgb_number:{name:`rgb`,commas:!0,coords:yz,noAlpha:!0},color:{},rgba:{coords:vz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:yz},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=_z.black,t.alpha=0):t.coords=_z[e],t.coords)return t}}}}),xz=new rL({id:`p3`,cssId:`display-p3`,name:`P3`,base:pz,fromBase:bz.fromBase,toBase:bz.toBase});WI.display_space=bz;let Sz;if(typeof CSS<`u`&&CSS.supports)for(let e of[pL,uz,xz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=iz(n);if(CSS.supports(`color`,r)){WI.display_space=e;break}}function Cz(e,{space:t=WI.display_space,...n}={}){let r=iz(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!WI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(EI)||EI(e.alpha);if(a&&!(Sz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=jL(e),i.coords=i.coords.map(DI),i.alpha=DI(i.alpha),r=iz(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=rz(i,t),r=new String(iz(i,n)),r.color=i}return r}function wz(e,t){return e=ZI(e),t=ZI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function Tz(e){return aL(e,[nL,`y`])}function Ez(e,t){sL(e,[nL,`y`],t)}function Dz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return Tz(this)},set(e){Ez(this,e)}})}var Oz=Object.freeze({__proto__:null,getLuminance:Tz,register:Dz,setLuminance:Ez});function kz(e,t){e=ZI(e),t=ZI(t);let n=Math.max(Tz(e),0),r=Math.max(Tz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const Az=.56,jz=.57,Mz=.62,Nz=.65,Pz=.022,Fz=1.414,Iz=.1,Lz=5e-4,Rz=1.14,zz=.027,Bz=1.14;function Vz(e){return e>=Pz?e:e+(Pz-e)**Fz}function Hz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Uz(e,t){t=ZI(t),e=ZI(e);let n,r,i,a,o,s;t=rz(t,`srgb`),[a,o,s]=t.coords;let c=Hz(a)*.2126729+Hz(o)*.7151522+Hz(s)*.072175;e=rz(e,`srgb`),[a,o,s]=e.coords;let l=Hz(a)*.2126729+Hz(o)*.7151522+Hz(s)*.072175,u=Vz(c),d=Vz(l),f=d>u;return Math.abs(d-u)<Lz?r=0:f?(n=d**Az-u**jz,r=n*Rz):(n=d**Nz-u**Mz,r=n*Bz),i=Math.abs(r)<Iz?0:r>0?r-zz:r+zz,i*100}function Wz(e,t){e=ZI(e),t=ZI(t);let n=Math.max(Tz(e),0),r=Math.max(Tz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Gz=5e4;function Kz(e,t){e=ZI(e),t=ZI(t);let n=Math.max(Tz(e),0),r=Math.max(Tz(t),0);return r>n&&([n,r]=[r,n]),r===0?Gz:(n-r)/r}function qz(e,t){e=ZI(e),t=ZI(t);let n=aL(e,[pL,`l`]),r=aL(t,[pL,`l`]);return Math.abs(n-r)}const Jz=216/24389,Yz=24/116,Xz=24389/27;let Zz=GI.D65;var Qz=new $I({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Zz,base:nL,fromBase(e){let t=e.map((e,t)=>e/Zz[t]),n=t.map(e=>e>Jz?Math.cbrt(e):(Xz*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>Yz?t[0]**3:(116*t[0]-16)/Xz,e[0]>8?((e[0]+16)/116)**3:e[0]/Xz,t[2]>Yz?t[2]**3:(116*t[2]-16)/Xz];return n.map((e,t)=>e*Zz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const $z=5**.5*.5+.5;function eB(e,t){e=ZI(e),t=ZI(t);let n=aL(e,[Qz,`l`]),r=aL(t,[Qz,`l`]),i=Math.abs(n**+$z-r**+$z),a=i**(1/$z)*Math.SQRT2-40;return a<7.5?0:a}var tB=Object.freeze({__proto__:null,contrastAPCA:Uz,contrastDeltaPhi:eB,contrastLstar:qz,contrastMichelson:Wz,contrastWCAG21:kz,contrastWeber:Kz});function nB(e,t,n={}){CI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(tB).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=ZI(e),t=ZI(t),tB)if(`contrast`+r.toLowerCase()===n.toLowerCase())return tB[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function rB(e){let[t,n,r]=iL(e,nL),i=t+15*n+3*r;return[4*t/i,9*n/i]}function iB(e){let[t,n,r]=iL(e,nL),i=t+n+r;return[t/i,n/i]}function aB(e){Object.defineProperty(e.prototype,`uv`,{get(){return rB(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return iB(this)}})}var oB=Object.freeze({__proto__:null,register:aB,uv:rB,xy:iB});function sB(e,t,n={}){CI(n)&&(n={method:n});let{method:r=WI.deltaE,...i}=n;for(let n in ZR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return ZR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function cB(e,t=.25){let n=$I.get(`oklch`,`lch`),r=[n,`l`];return sL(e,r,e=>e*(1+t))}function lB(e,t=.25){let n=$I.get(`oklch`,`lch`),r=[n,`l`];return sL(e,r,e=>e*(1-t))}var uB=Object.freeze({__proto__:null,darken:lB,lighten:cB});function dB(e,t,n=.5,r={}){[e,t]=[ZI(e),ZI(t)],wI(n)===`object`&&([n,r]=[.5,n]);let i=pB(e,t,r);return i(n)}function fB(e,t,n={}){let r;mB(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[ZI(e),ZI(t)],r=pB(e,t,c));let l=sB(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=sB(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,sB(o,n.color),sB(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function pB(e,t,n={}){if(mB(e)){let[n,r]=[e,t];return pB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=ZI(e),t=ZI(t),e=jL(e),t=jL(t);let s={colors:[e,t],options:n};if(r=r?$I.get(r):$I.registry[WI.interpolationSpace]||e.space,i=i?$I.get(i):r,e=rz(e,r),t=rz(t,r),e=ez(e),t=ez(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[aL(e,a),aL(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=hL(i,[o,s]),sL(e,a,o),sL(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return MI(e,i,n)}),c=MI(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=rz(l,i)),l},{rangeArgs:s})}function mB(e){return wI(e)===`function`&&!!e.rangeArgs}WI.interpolationSpace=`lab`;function hB(e){e.defineFunction(`mix`,dB,{returns:`color`}),e.defineFunction(`range`,pB,{returns:`function<color>`}),e.defineFunction(`steps`,fB,{returns:`array<color>`})}var gB=Object.freeze({__proto__:null,isRange:mB,mix:dB,range:pB,register:hB,steps:fB}),_B=new $I({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:bz,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),vB=new $I({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:_B,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),yB=new $I({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:vB,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const bB=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],xB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var SB=new rL({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:bB,fromXYZ_M:xB}),CB=new rL({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:SB,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const wB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],TB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var EB=new rL({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:cL,toXYZ_M:wB,fromXYZ_M:TB});const DB=1/512,OB=16/512;var kB=new rL({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:EB,toBase(e){return e.map(e=>e<OB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=DB?e**(1/1.8):16*e)}}),AB=new $I({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:DL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),mL(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let jB=GI.D65;const MB=216/24389,NB=24389/27,[PB,FB]=rB({space:nL,coords:jB});var IB=new $I({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:jB,base:nL,fromBase(e){let t=[DI(e[0]),DI(e[1]),DI(e[2])],n=t[1],[r,i]=rB({space:nL,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=MB?NB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-PB),13*a*(i-FB)]},toBase(e){let[t,n,r]=e;if(t===0||EI(t))return[0,0,0];n=DI(n),r=DI(r);let i=n/(13*t)+PB,a=r/(13*t)+FB,o=t<=8?t/NB:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),LB=new $I({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:IB,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),mL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const RB=216/24389,zB=24389/27,BB=hz[0][0],VB=hz[0][1],HB=hz[0][2],UB=hz[1][0],WB=hz[1][1],GB=hz[1][2],KB=hz[2][0],qB=hz[2][1],JB=hz[2][2];function YB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function XB(e){let t=(e+16)**3/1560896,n=t>RB?t:e/zB,r=n*(284517*BB-94839*HB),i=n*(838422*HB+769860*VB+731718*BB),a=n*(632260*HB-126452*VB),o=n*(284517*UB-94839*GB),s=n*(838422*GB+769860*WB+731718*UB),c=n*(632260*GB-126452*WB),l=n*(284517*KB-94839*JB),u=n*(838422*JB+769860*qB+731718*KB),d=n*(632260*JB-126452*qB);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function ZB(e,t){let n=t/360*Math.PI*2,r=YB(e.r0s,e.r0i,n),i=YB(e.r1s,e.r1i,n),a=YB(e.g0s,e.g0i,n),o=YB(e.g1s,e.g1i,n),s=YB(e.b0s,e.b0i,n),c=YB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var QB=new $I({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:LB,gamutSpace:bz,fromBase(e){let[t,n,r]=[DI(e[0]),DI(e[1]),DI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=XB(t),a=ZB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[DI(e[0]),DI(e[1]),DI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=XB(r),a=ZB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});hz[0][0],hz[0][1],hz[0][2],hz[1][0],hz[1][1],hz[1][2],hz[2][0],hz[2][1],hz[2][2];function $B(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function eV(e){let t=$B(e.r0s,e.r0i),n=$B(e.r1s,e.r1i),r=$B(e.g0s,e.g0i),i=$B(e.g1s,e.g1i),a=$B(e.b0s,e.b0i),o=$B(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var tV=new $I({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:LB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[DI(e[0]),DI(e[1]),DI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=XB(t),r=eV(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[DI(e[0]),DI(e[1]),DI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=XB(r),t=eV(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const nV=203,rV=2610/2**14,iV=2**14/2610,aV=2523/2**5,oV=2**5/2523,sV=3424/2**12,cV=2413/2**7,lV=2392/2**7;var uV=new rL({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:sz,toBase(e){return e.map(function(e){let t=(Math.max(e**oV-sV,0)/(cV-lV*e**oV))**iV;return t*1e4/nV})},fromBase(e){return e.map(function(e){let t=Math.max(e*nV/1e4,0),n=sV+cV*t**rV,r=1+lV*t**rV;return(n/r)**aV})}});const dV=.17883277,fV=.28466892,pV=.55991073,mV=3.7743;var hV=new rL({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:sz,toBase(e){return e.map(function(e){return e<=.5?e**2/3*mV:(Math.exp((e-pV)/dV)+fV)/12*mV})},fromBase(e){return e.map(function(e){return e/=mV,e<=1/12?Math.sqrt(3*e):dV*Math.log(12*e-fV)+pV})}});const gV={};UI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=vV(e.W1,e.W2,e.options.method))}),UI.add(`chromatic-adaptation-end`,e=>{e.M||=vV(e.W1,e.W2,e.options.method)});function _V({id:e,toCone_M:t,fromCone_M:n}){gV[e]=arguments[0]}function vV(e,t,n=`Bradford`){let r=gV[n],[i,a,o]=SI(r.toCone_M,e),[s,c,l]=SI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=SI(u,r.toCone_M),f=SI(r.fromCone_M,d);return f}_V({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),_V({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),_V({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),_V({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(GI,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),GI.ACES=[.32168/.33767,1,.34065/.33767];const yV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],bV=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var xV=new rL({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:GI.ACES,toXYZ_M:yV,fromXYZ_M:bV});const SV=2**-16,CV=-.35828683,wV=(Math.log2(65504)+9.72)/17.52;var TV=new rL({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[CV,wV],name:`Red`},g:{range:[CV,wV],name:`Green`},b:{range:[CV,wV],name:`Blue`}},referred:`scene`,base:xV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-SV)*2:e<wV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(SV)+9.72)/17.52:e<SV?(Math.log2(SV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),EV=Object.freeze({__proto__:null,A98RGB:CB,A98RGB_Linear:SB,ACEScc:TV,ACEScg:xV,CAM16_JMh:LR,HCT:KR,HPLuv:tV,HSL:_B,HSLuv:QB,HSV:vB,HWB:yB,ICTCP:mR,JzCzHz:tR,Jzazbz:eR,LCH:gL,LCHuv:LB,Lab:pL,Lab_D65:Qz,Luv:IB,OKLCH:AB,OKLab:DL,P3:xz,P3_Linear:pz,ProPhoto:kB,ProPhoto_Linear:EB,REC_2020:uz,REC_2020_Linear:sz,REC_2100_HLG:hV,REC_2100_PQ:uV,XYZ_ABS_D65:RL,XYZ_D50:cL,XYZ_D65:nL,sRGB:bz,sRGB_Linear:gz}),DV=class e{constructor(...e){let t;e.length===1&&(t=ZI(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:$I.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=Cz(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};DV.defineFunctions({get:aL,getAll:iL,set:sL,setAll:oL,to:rz,equals:wz,inGamut:AL,toGamut:ez,distance:ML,toString:iz}),Object.assign(DV,{util:VI,hooks:UI,WHITES:GI,Space:$I,spaces:$I.registry,parse:XI,defaults:WI});for(let e of Object.keys(EV))$I.register(EV[e]);for(let e in $I.registry)OV(e,$I.registry[e]);UI.add(`colorspace-init-end`,e=>{var t,n;OV(e.id,e),(t=n=e.aliases)?.forEach(t=>{OV(t,e)})});function OV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(DV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return $I.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=$I.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=$I.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}DV.extend(ZR),DV.extend({deltaE:sB}),Object.assign(DV,{deltaEMethods:ZR}),DV.extend(uB),DV.extend({contrast:nB}),DV.extend(oB),DV.extend(Oz),DV.extend(gB),DV.extend(tB);const{vec2:kV,vec4:AV}=ck,jV=e=>{let t=new DV(e);return AV(...t.to(`p3-linear`).coords,t.alpha).value},MV=e=>{let t=.5,n=.5;if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=e.x,n=e.y):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return kV(t,1-n).value},{vec2:NV,viewportSize:PV}=ck,FV=(e=NV(0))=>{let t=PV,n=t.x.div(t.y),r=e.x.mul(n);return NV(r,e.y)},IV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:jV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:jV,description:`The background color`},radius:{type:Number,default:1,description:`The radius of the circle`},softness:{type:Number,default:0,description:`Edge softness (0 = sharp, 1 = soft)`},center:{type:Object,default:{x:.5,y:.5},transform:MV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=ck,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=FV(o()),l=FV(s),u=r(c.sub(l)),d=e.softness.uniform,f=e.radius.uniform.mul(.25),p=a(f,f.sub(d),u);return n(i(e.backgroundColor.uniform,e.color.uniform,p),1)}};var LV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${IV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(IV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,IV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),RV=LV;const zV=new WeakMap,BV={name:`glassTiles`,props:{intensity:{type:Number,default:1,description:`The intensity of the glass tiles effect`},tileCount:{type:Number,default:100,description:`Number of tiles across the shortest dimension`}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,uv:f,uniform:p}=ck;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=zV.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),zV.set(r,_)),n(()=>{let e=zV.get(r);e&&(e.disconnect(),zV.delete(r))});let v=f(),y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var VV=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,opacity:1,...Object.entries(BV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${BV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(BV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(BV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(BV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,BV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),HV=VV;const UV={VERTEX:`vertex`,FRAGMENT:`fragment`},WV={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},GV=[`fragment`,`vertex`],eoe=[...GV,`compute`],KV=[`x`,`y`,`z`,`w`],qV=`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`.split(`.`);let JV=1234567;const YV=Math.PI/180,XV=180/Math.PI;function ZV(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=qV[e&255]+qV[e>>8&255]+qV[e>>16&255]+qV[e>>24&255]+`-`+qV[t&255]+qV[t>>8&255]+`-`+qV[t>>16&15|64]+qV[t>>24&255]+`-`+qV[n&63|128]+qV[n>>8&255]+`-`+qV[n>>16&255]+qV[n>>24&255]+qV[r&255]+qV[r>>8&255]+qV[r>>16&255]+qV[r>>24&255];return i.toLowerCase()}function QV(e,t,n){return Math.max(t,Math.min(n,e))}function $V(e,t){return(e%t+t)%t}function eH(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function tH(e,t,n){return e===t?0:(n-e)/(t-e)}function nH(e,t,n){return(1-n)*e+n*t}function rH(e,t,n,r){return nH(e,t,1-Math.exp(-n*r))}function iH(e,t=1){return t-Math.abs($V(e,t*2)-t)}function aH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function oH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function sH(e,t){return e+Math.floor(Math.random()*(t-e+1))}function cH(e,t){return e+Math.random()*(t-e)}function lH(e){return e*(.5-Math.random())}function uH(e){e!==void 0&&(JV=e);let t=JV+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function dH(e){return e*YV}function fH(e){return e*XV}function pH(e){return(e&e-1)==0&&e!==0}function mH(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function hH(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function gH(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function _H(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function vH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const yH={DEG2RAD:YV,RAD2DEG:XV,generateUUID:ZV,clamp:QV,euclideanModulo:$V,mapLinear:eH,inverseLerp:tH,lerp:nH,damp:rH,pingpong:iH,smoothstep:aH,smootherstep:oH,randInt:sH,randFloat:cH,randFloatSpread:lH,seededRandom:uH,degToRad:dH,radToDeg:fH,isPowerOfTwo:pH,ceilPowerOfTwo:mH,floorPowerOfTwo:hH,setQuaternionFromProperEuler:gH,normalize:vH,denormalize:_H},bH=0,xH=1015,SH=``,CH=`srgb`,wH=`srgb-linear`,TH=`linear`,EH=`srgb`,DH=35044,OH=2e3,kH=2001;var AH=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,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){let 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,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(jH.makeScale(e,t)),this}rotate(e){return this.premultiply(jH.makeRotation(-e)),this}translate(e,t){return this.premultiply(jH.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){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const jH=new AH,MH={};function NH(e){e in MH||(MH[e]=!0,console.warn(e))}const PH=new AH().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),FH=new AH().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function IH(){let e={enabled:!0,workingColorSpace:wH,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===EH&&(e.r=RH(e.r),e.g=RH(e.g),e.b=RH(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===EH&&(e.r=zH(e.r),e.g=zH(e.g),e.b=zH(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===SH?TH:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return NH(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return NH(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[wH]:{primaries:t,whitePoint:r,transfer:TH,toXYZ:PH,fromXYZ:FH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:CH},outputColorSpaceConfig:{drawingBufferColorSpace:CH}},[CH]:{primaries:t,whitePoint:r,transfer:EH,toXYZ:PH,fromXYZ:FH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:CH}}}),e}const LH=IH();function RH(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function zH(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const BH={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},VH={h:0,s:0,l:0},HH={h:0,s:0,l:0};function UH(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var WH=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=CH){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,LH.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=LH.workingColorSpace){return this.r=e,this.g=t,this.b=n,LH.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=LH.workingColorSpace){if(e=$V(e,1),t=QV(t,0,1),n=QV(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=UH(i,r,e+1/3),this.g=UH(i,r,e),this.b=UH(i,r,e-1/3)}return LH.colorSpaceToWorking(this,r),this}setStyle(e,t=CH){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,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=CH){let n=BH[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),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=RH(e.r),this.g=RH(e.g),this.b=RH(e.b),this}copyLinearToSRGB(e){return this.r=zH(e.r),this.g=zH(e.g),this.b=zH(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=CH){return LH.workingToColorSpace(GH.copy(this),e),Math.round(QV(GH.r*255,0,255))*65536+Math.round(QV(GH.g*255,0,255))*256+Math.round(QV(GH.b*255,0,255))}getHexString(e=CH){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=LH.workingColorSpace){LH.workingToColorSpace(GH.copy(this),t);let n=GH.r,r=GH.g,i=GH.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=LH.workingColorSpace){return LH.workingToColorSpace(GH.copy(this),t),e.r=GH.r,e.g=GH.g,e.b=GH.b,e}getStyle(e=CH){LH.workingToColorSpace(GH.copy(this),e);let t=GH.r,n=GH.g,r=GH.b;return e===CH?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(VH),this.setHSL(VH.h+e,VH.s+t,VH.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(VH),e.getHSL(HH);let n=nH(VH.h,HH.h,t),r=nH(VH.s,HH.s,t),i=nH(VH.l,HH.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[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 GH=new WH;WH.NAMES=BH;var KH=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},qH=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,n,r){return this._x=e,this._y=t,this._z=n,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){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(QV(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*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=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},JH=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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 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 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(XH.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(XH.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-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){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=QV(this.x,e.x,t.x),this.y=QV(this.y,e.y,t.y),this.z=QV(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=QV(this.x,e,t),this.y=QV(this.y,e,t),this.z=QV(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(QV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return YH.copy(this).projectOnVector(e),this.sub(YH)}reflect(e){return this.sub(YH.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(QV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const YH=new JH,XH=new qH;var ZH=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/QH.setFromMatrixColumn(e,0).length(),i=1/QH.setFromMatrixColumn(e,1).length(),a=1/QH.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}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(eU,e,tU)}lookAt(e,t,n){let r=this.elements;return iU.subVectors(e,t),iU.lengthSq()===0&&(iU.z=1),iU.normalize(),nU.crossVectors(n,iU),nU.lengthSq()===0&&(Math.abs(n.z)===1?iU.x+=1e-4:iU.z+=1e-4,iU.normalize(),nU.crossVectors(n,iU)),nU.normalize(),rU.crossVectors(iU,nU),r[0]=nU.x,r[4]=rU.x,r[8]=iU.x,r[1]=nU.y,r[5]=rU.y,r[9]=iU.y,r[2]=nU.z,r[6]=rU.z,r[10]=iU.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,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,n){let 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]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=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,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=QH.set(r[0],r[1],r[2]).length(),a=QH.set(r[4],r[5],r[6]).length(),o=QH.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],$H.copy(this);let c=1/i,l=1/a,u=1/o;return $H.elements[0]*=c,$H.elements[1]*=c,$H.elements[2]*=c,$H.elements[4]*=l,$H.elements[5]*=l,$H.elements[6]*=l,$H.elements[8]*=u,$H.elements[9]*=u,$H.elements[10]*=u,t.setFromRotationMatrix($H),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=OH){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===OH)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===kH)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=OH){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===OH)p=(a+i)*u,m=-2*u;else if(o===kH)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const QH=new JH,$H=new ZH,eU=new JH(0,0,0),tU=new JH(1,1,1),nU=new JH,rU=new JH,iU=new JH;var aU=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}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 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 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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=QV(this.x,e.x,t.x),this.y=QV(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=QV(this.x,e,t),this.y=QV(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(QV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(QV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},oU=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}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,n,r){return this.x=e,this.y=t,this.z=n,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 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 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?1:e.w,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){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let 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,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let 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=QV(this.x,e.x,t.x),this.y=QV(this.y,e.y,t.y),this.z=QV(this.z,e.z,t.z),this.w=QV(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=QV(this.x,e,t),this.y=QV(this.y,e,t),this.z=QV(this.z,e,t),this.w=QV(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(QV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}};function sU(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const cU=(...e)=>sU(e);function lU(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of uU(e))n.push(sU(r.slice(0,-4)),i.getCacheKey(t));return sU(n)}function*uU(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function dU(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function fU(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new WH(...t):n===`vec2`?new aU(...t):n===`vec3`?new JH(...t):n===`vec4`?new oU(...t):n===`mat2`?new KH(...t):n===`mat3`?new AH(...t):n===`mat4`?new ZH(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?mU(t[0]):null}function pU(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function mU(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var hU=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const gU={analyze:`setup`,generate:`analyze`};let _U=0;var vU=class extends hU{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=WV.NONE,this.updateBeforeType=WV.NONE,this.updateAfterType=WV.NONE,this.uuid=yH.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:_U++})}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,WV.FRAME)}onRenderUpdate(e){return this.onUpdate(e,WV.RENDER)}onObjectUpdate(e){return this.onUpdate(e,WV.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(let{childNode:e}of uU(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=cU(lU(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=gU[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return uU(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},yU=vU,bU=class extends yU{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},xU=bU,SU=class extends yU{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){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},CU=SU,wU=class extends yU{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},TU=wU,EU=class extends xU{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},DU=EU;const OU=KV.join(``);var kU=class extends yU{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(let t of this.components)e=Math.max(KV.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){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===OU.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},AU=kU,jU=class extends xU{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=KV[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},MU=jU,NU=class extends xU{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=KV[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},PU=NU,FU=class extends yU{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?dU(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=dU(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=pU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?fU(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.`)}},IU=FU;const LU=/float|u?int/;var RU=class extends IU{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){let n=this.getNodeType(e);return LU.test(n)&&LU.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},zU=RU,BU=class extends yU{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},VU=BU;let HU=null;const UU=new Map;function R(e,t){if(UU.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);UU.set(e,t)}const WU=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),GU=e=>WU(e).split(``).sort().join(``),KU={setup(e,t){let n=t.shift();return e(_W(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(HU.assign(n,...e),n);if(UU.has(t)){let r=UU.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&UU.has(t.slice(0,t.length-6))){let r=UU.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=WU(t),gW(new AU(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=GU(t.slice(3).toLowerCase()),n=>gW(new MU(e,t,gW(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=GU(t.slice(4).toLowerCase()),()=>gW(new PU(gW(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),gW(new AU(e,t));else if(/^\d+$/.test(t)===!0)return gW(new CU(n,new zU(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>gW(new VU(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},qU=new WeakMap,JU=new WeakMap,YU=function(e,t=null){let n=dU(e);if(n===`node`){let t=qU.get(e);return t===void 0&&(t=new Proxy(e,KU),qU.set(e,t),qU.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return gW(dW(e,t));else if(n===`shader`)return bW(e);return e},XU=function(e,t=null){for(let n in e)e[n]=gW(e[n],t);return e},ZU=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=gW(e[r],t);return e},QU=function(e,t=null,n=null,r=null){let i=e=>gW(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...vW(l(t)))):n===null?a=(...n)=>i(new e(t,...vW(l(n)))):(n=gW(n),a=(...r)=>i(new e(t,...vW(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var $U=class extends yU{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=JU.get(e.constructor);r===void 0&&(r=new WeakMap,JU.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=gW(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=gW(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=gW(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},eW=class extends yU{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return _W(e),gW(new $U(this,e))}setup(){return this.call()}};const tW=[!1,!0],nW=[0,1,2,3],rW=[-1,-2],iW=[.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],aW=new Map;for(let e of tW)aW.set(e,new zU(e));const oW=new Map;for(let e of nW)oW.set(e,new zU(e,`uint`));const sW=new Map([...oW].map(e=>new zU(e.value,`int`)));for(let e of rW)sW.set(e,new zU(e,`int`));const cW=new Map([...sW].map(e=>new zU(e.value)));for(let e of iW)cW.set(e,new zU(e));for(let e of iW)cW.set(-e,new zU(-e));const lW={bool:aW,uint:oW,ints:sW,float:cW},uW=new Map([...aW,...cW]),dW=(e,t)=>uW.has(e)?uW.get(e):e.isNode===!0?e:new zU(e,t),fW=e=>{try{return e.getNodeType()}catch{return}},pW=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[fU(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return gW(t.get(n[0]));if(n.length===1){let t=dW(n[0],e);return fW(t)===e?gW(t):gW(new TU(t,e))}let r=n.map(e=>dW(e));return gW(new DU(r,e))}},mW=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function hW(e,t){return new Proxy(new eW(e,t),KU)}const gW=(e,t=null)=>YU(e,t),_W=(e,t=null)=>new XU(e,t),vW=(e,t=null)=>new ZU(e,t),z=(...e)=>new QU(...e);let yW=0;const bW=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new hW(e,n),i=(...e)=>{let t;_W(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ yW++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function xW(e){return HU&&HU.add(e),e}R(`toStack`,xW);const SW=new pW(`color`),CW=new pW(`float`,lW.float),wW=new pW(`int`,lW.ints),TW=new pW(`uint`,lW.uint),EW=new pW(`bool`,lW.bool),DW=new pW(`vec2`),OW=new pW(`ivec2`),kW=new pW(`uvec2`),AW=new pW(`bvec2`),jW=new pW(`vec3`),MW=new pW(`ivec3`),NW=new pW(`uvec3`),PW=new pW(`bvec3`),FW=new pW(`vec4`),IW=new pW(`ivec4`),LW=new pW(`uvec4`),RW=new pW(`bvec4`),zW=new pW(`mat2`),BW=new pW(`mat3`),VW=new pW(`mat4`);R(`toColor`,SW),R(`toFloat`,CW),R(`toInt`,wW),R(`toUint`,TW),R(`toBool`,EW),R(`toVec2`,DW),R(`toIVec2`,OW),R(`toUVec2`,kW),R(`toBVec2`,AW),R(`toVec3`,jW),R(`toIVec3`,MW),R(`toUVec3`,NW),R(`toBVec3`,PW),R(`toVec4`,FW),R(`toIVec4`,IW),R(`toUVec4`,LW),R(`toBVec4`,RW),R(`toMat2`,zW),R(`toMat3`,BW),R(`toMat4`,VW);const HW=z(CU).setParameterLength(2),UW=(e,t)=>gW(new TU(gW(e),t));R(`element`,HW),R(`convert`,UW),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),xW(e)));const WW={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var GW=class e extends xU{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(WW[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===OH;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const KW=z(GW,`+`).setParameterLength(2,1/0).setName(`add`),qW=z(GW,`-`).setParameterLength(2,1/0).setName(`sub`),JW=z(GW,`*`).setParameterLength(2,1/0).setName(`mul`),YW=z(GW,`/`).setParameterLength(2,1/0).setName(`div`),XW=z(GW,`%`).setParameterLength(2).setName(`mod`),ZW=z(GW,`==`).setParameterLength(2).setName(`equal`),QW=z(GW,`!=`).setParameterLength(2).setName(`notEqual`),$W=z(GW,`<`).setParameterLength(2).setName(`lessThan`),eG=z(GW,`>`).setParameterLength(2).setName(`greaterThan`),tG=z(GW,`<=`).setParameterLength(2).setName(`lessThanEqual`),nG=z(GW,`>=`).setParameterLength(2).setName(`greaterThanEqual`),rG=z(GW,`&&`).setParameterLength(2,1/0).setName(`and`),iG=z(GW,`||`).setParameterLength(2,1/0).setName(`or`),aG=z(GW,`!`).setParameterLength(1).setName(`not`),oG=z(GW,`^^`).setParameterLength(2).setName(`xor`),sG=z(GW,`&`).setParameterLength(2).setName(`bitAnd`),cG=z(GW,`~`).setParameterLength(2).setName(`bitNot`),lG=z(GW,`|`).setParameterLength(2).setName(`bitOr`),uG=z(GW,`^`).setParameterLength(2).setName(`bitXor`),dG=z(GW,`<<`).setParameterLength(2).setName(`shiftLeft`),fG=z(GW,`>>`).setParameterLength(2).setName(`shiftRight`),pG=bW(([e])=>(e.addAssign(1),e)),mG=bW(([e])=>(e.subAssign(1),e)),hG=bW(([e])=>{let t=wW(e).toConst();return e.addAssign(1),t}),gG=bW(([e])=>{let t=wW(e).toConst();return e.subAssign(1),t});R(`add`,KW),R(`sub`,qW),R(`mul`,JW),R(`div`,YW),R(`mod`,XW),R(`equal`,ZW),R(`notEqual`,QW),R(`lessThan`,$W),R(`greaterThan`,eG),R(`lessThanEqual`,tG),R(`greaterThanEqual`,nG),R(`and`,rG),R(`or`,iG),R(`not`,aG),R(`xor`,oG),R(`bitAnd`,sG),R(`bitNot`,cG),R(`bitOr`,lG),R(`bitXor`,uG),R(`shiftLeft`,dG),R(`shiftRight`,fG),R(`incrementBefore`,pG),R(`decrementBefore`,mG),R(`increment`,hG),R(`decrement`,gG);const _G=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),XW(e,t)),vG=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),XW(wW(e),wW(t)));R(`remainder`,_G),R(`modInt`,vG);var B=class e extends xU{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=qW(1,n);else if(i===e.RECIPROCAL)a=YW(1,n);else if(i===e.DIFFERENCE)a=BG(qW(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=FW(jW(i),0):e=FW(jW(e),0);let o=JW(e,i).xyz;a=MG(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===OH&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===OH&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===kH&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const yG=CW(Math.PI),toe=CW(Math.PI*2),bG=z(B,B.ALL).setParameterLength(1),xG=z(B,B.ANY).setParameterLength(1),SG=z(B,B.RADIANS).setParameterLength(1),CG=z(B,B.DEGREES).setParameterLength(1),wG=z(B,B.EXP).setParameterLength(1),TG=z(B,B.EXP2).setParameterLength(1),EG=z(B,B.LOG).setParameterLength(1),DG=z(B,B.LOG2).setParameterLength(1),OG=z(B,B.SQRT).setParameterLength(1),kG=z(B,B.INVERSE_SQRT).setParameterLength(1),AG=z(B,B.FLOOR).setParameterLength(1),jG=z(B,B.CEIL).setParameterLength(1),MG=z(B,B.NORMALIZE).setParameterLength(1),NG=z(B,B.FRACT).setParameterLength(1),PG=z(B,B.SIN).setParameterLength(1),FG=z(B,B.COS).setParameterLength(1),IG=z(B,B.TAN).setParameterLength(1),LG=z(B,B.ASIN).setParameterLength(1),RG=z(B,B.ACOS).setParameterLength(1),zG=z(B,B.ATAN).setParameterLength(1,2),BG=z(B,B.ABS).setParameterLength(1),VG=z(B,B.SIGN).setParameterLength(1),HG=z(B,B.LENGTH).setParameterLength(1),UG=z(B,B.NEGATE).setParameterLength(1),WG=z(B,B.ONE_MINUS).setParameterLength(1),GG=z(B,B.DFDX).setParameterLength(1),KG=z(B,B.DFDY).setParameterLength(1),qG=z(B,B.ROUND).setParameterLength(1),JG=z(B,B.RECIPROCAL).setParameterLength(1),YG=z(B,B.TRUNC).setParameterLength(1),XG=z(B,B.FWIDTH).setParameterLength(1),ZG=z(B,B.TRANSPOSE).setParameterLength(1),QG=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),ZW(e,t)),$G=z(B,B.MIN).setParameterLength(2,1/0),eK=z(B,B.MAX).setParameterLength(2,1/0),tK=z(B,B.STEP).setParameterLength(2),nK=z(B,B.REFLECT).setParameterLength(2),rK=z(B,B.DISTANCE).setParameterLength(2),iK=z(B,B.DIFFERENCE).setParameterLength(2),aK=z(B,B.DOT).setParameterLength(2),oK=z(B,B.CROSS).setParameterLength(2),sK=z(B,B.POW).setParameterLength(2),cK=z(B,B.POW,2).setParameterLength(1),lK=z(B,B.POW,3).setParameterLength(1),uK=z(B,B.POW,4).setParameterLength(1),dK=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),fK=e=>JW(VG(e),sK(BG(e),1/3)),pK=e=>aK(e,e),mK=z(B,B.MIX).setParameterLength(3),hK=(e,t=0,n=1)=>gW(new B(B.CLAMP,gW(e),gW(t),gW(n))),gK=e=>hK(e),_K=z(B,B.REFRACT).setParameterLength(3),vK=z(B,B.SMOOTHSTEP).setParameterLength(3),yK=z(B,B.FACEFORWARD).setParameterLength(3),bK=bW(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=aK(e.xy,DW(t,n)),a=XW(i,yG);return NG(PG(a).mul(r))}),xK=(e,t,n)=>mK(t,n,e),SK=(e,t,n)=>vK(t,n,e),CK=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),zG(e,t));R(`all`,bG),R(`any`,xG),R(`equals`,QG),R(`radians`,SG),R(`degrees`,CG),R(`exp`,wG),R(`exp2`,TG),R(`log`,EG),R(`log2`,DG),R(`sqrt`,OG),R(`inverseSqrt`,kG),R(`floor`,AG),R(`ceil`,jG),R(`normalize`,MG),R(`fract`,NG),R(`sin`,PG),R(`cos`,FG),R(`tan`,IG),R(`asin`,LG),R(`acos`,RG),R(`atan`,zG),R(`abs`,BG),R(`sign`,VG),R(`length`,HG),R(`lengthSq`,pK),R(`negate`,UG),R(`oneMinus`,WG),R(`dFdx`,GG),R(`dFdy`,KG),R(`round`,qG),R(`reciprocal`,JG),R(`trunc`,YG),R(`fwidth`,XG),R(`atan2`,CK),R(`min`,$G),R(`max`,eK),R(`step`,tK),R(`reflect`,nK),R(`distance`,rK),R(`dot`,aK),R(`cross`,oK),R(`pow`,sK),R(`pow2`,cK),R(`pow3`,lK),R(`pow4`,uK),R(`transformDirection`,dK),R(`mix`,xK),R(`clamp`,hK),R(`refract`,_K),R(`smoothstep`,SK),R(`faceForward`,yK),R(`difference`,iK),R(`saturate`,gK),R(`cbrt`,fK),R(`transpose`,ZG),R(`rand`,bK);var wK=class extends xU{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const TK=(...e)=>{let t;if(e.length===1){let n=e[0];t=new wK(null,n.length,n)}else{let n=e[0],r=e[1];t=new wK(n,r)}return gW(t)};R(`toArray`,(e,t)=>TK(Array(t).fill(e)));var EK=class extends yU{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const DK=e=>new EK(e),OK=(e,t=0)=>new EK(e,!0,t),kK=OK(`render`),AK=DK(`object`);var jK=class extends IU{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=AK}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){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const MK=(e,t)=>{let n=mW(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return gW(new jK(r,n))};var NK=class extends yU{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const PK=(e,t)=>gW(new NK(e,t));var FK=class extends xU{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=KV.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const IK=z(FK).setParameterLength(2);R(`assign`,IK);var LK=class extends xU{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){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(CW(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(CW(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const RK=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?vW(t):_W(t[0]),gW(new LK(gW(e),t)));R(`call`,RK);var zK=class extends yU{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?PK(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
397
+
398
+ `+e.tab+`}`),o!==null){e.addFlowCode(` else {
399
+
400
+ `).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
401
+
402
+ `+e.tab+`}
403
+
404
+ `)}else e.addFlowCode(`
405
+
406
+ `);return e.format(l,n,t)}};const BK=z(zK).setParameterLength(2,3);R(`select`,BK);const VK=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),BK(...e));R(`cond`,VK);var HK=class extends yU{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){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const UK=z(HK).setParameterLength(1,2),WK=(e,t)=>UK(e,{label:t});R(`context`,UK),R(`label`,WK);var GK=class extends yU{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const KK=z(GK),qK=(e,t=null)=>KK(e,t).toStack(),JK=(e,t=null)=>KK(e,t,!0).toStack();R(`toVar`,qK),R(`toConst`,JK);const YK=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),KK(e));R(`temp`,YK);var XK=class extends yU{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(UV.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(UV.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,UV.VERTEX);e.flowNodeFromShaderStage(UV.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const ZK=z(XK).setParameterLength(1,2),QK=e=>ZK(e);R(`toVarying`,ZK),R(`toVertexStage`,QK),R(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),ZK(...e))),R(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),ZK(...e)));const $K=bW(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=mK(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),eq=bW(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=mK(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),tq=`WorkingColorSpace`,nq=`OutputColorSpace`;var rq=class extends xU{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===tq?LH.workingColorSpace:t===nq?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return LH.enabled===!1||n===r||!n||!r?i:(LH.getTransfer(n)===EH&&(i=FW($K(i.rgb),i.a)),LH.getPrimaries(n)!==LH.getPrimaries(r)&&(i=FW(BW(LH._getMatrix(new AH,n,r)).mul(i.rgb),i.a)),LH.getTransfer(r)===EH&&(i=FW(eq(i.rgb),i.a)),i)}};const iq=(e,t)=>gW(new rq(gW(e),tq,t)),aq=(e,t)=>gW(new rq(gW(e),t,tq));R(`workingToColorSpace`,iq),R(`colorSpaceToWorking`,aq);var oq=class extends CU{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},sq=class extends yU{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=WV.OBJECT}setGroup(e){return this.group=e,this}element(e){return gW(new oq(this,gW(e)))}setNodeType(e){let t=MK(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){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},cq=sq,lq=class extends cq{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(kK)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const uq=(e,t,n=null)=>gW(new lq(e,t,n));var dq=class extends xU{static get type(){return`ToneMappingNode`}constructor(e,t=pq,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return cU(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===bH)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=FW(i(t.rgb,this.exposureNode),t.a),r}};const fq=(e,t,n)=>gW(new dq(e,gW(t),gW(n))),pq=uq(`toneMappingExposure`,`float`);R(`toneMapping`,(e,t,n)=>fq(t,n,e));const mq=new JH,hq=new aU;let gq=0;var _q=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:gq++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=DH,this.updateRanges=[],this.gpuType=xH,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)hq.fromBufferAttribute(this,t),hq.applyMatrix3(e),this.setXY(t,hq.x,hq.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.applyMatrix3(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.applyMatrix4(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.applyNormalMatrix(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.transformDirection(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=_H(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=vH(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=_H(t,this.array)),t}setX(e,t){return this.normalized&&(t=vH(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=_H(t,this.array)),t}setY(e,t){return this.normalized&&(t=vH(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=_H(t,this.array)),t}setZ(e,t){return this.normalized&&(t=vH(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=_H(t,this.array)),t}setW(e,t){return this.normalized&&(t=vH(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array),r=vH(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array),r=vH(r,this.array),i=vH(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==DH&&(e.usage=this.usage),e}};const vq=new JH;var yq=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)vq.fromBufferAttribute(this,t),vq.applyMatrix4(e),this.setXYZ(t,vq.x,vq.y,vq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)vq.fromBufferAttribute(this,t),vq.applyNormalMatrix(e),this.setXYZ(t,vq.x,vq.y,vq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)vq.fromBufferAttribute(this,t),vq.transformDirection(e),this.setXYZ(t,vq.x,vq.y,vq.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=_H(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=vH(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=vH(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vH(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vH(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vH(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=_H(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=_H(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=_H(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=_H(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array),r=vH(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=vH(t,this.array),n=vH(n,this.array),r=vH(r,this.array),i=vH(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new _q(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.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.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,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}}},bq=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=DH,this.updateRanges=[],this.version=0,this.uuid=ZV()}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,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+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=ZV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=ZV()),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}}},xq=class extends IU{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=DH,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;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new bq(n,i),s=new yq(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=ZK(this);i=n.build(e,t)}return i}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 Sq=(e,t=null,n=0,r=0)=>gW(new xq(e,t,n,r));R(`toAttribute`,e=>Sq(e.value));var Cq=class extends yU{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=WV.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const wq=(e,t,n)=>gW(new Cq(gW(e),t,n));R(`compute`,wq);var Tq=class extends yU{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const Eq=(e,t)=>gW(new Tq(gW(e),t));R(`cache`,Eq);var Dq=class extends yU{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){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const Oq=z(Dq).setParameterLength(2);R(`bypass`,Oq);var kq=class extends yU{static get type(){return`RemapNode`}constructor(e,t,n,r=CW(0),i=CW(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const Aq=z(kq,null,null,{doClamp:!1}).setParameterLength(3,5),jq=z(kq).setParameterLength(3,5);R(`remap`,Aq),R(`remapClamp`,jq);var Mq=class extends yU{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const Nq=z(Mq).setParameterLength(1,2),Pq=e=>(e?BK(e,Nq(`discard`)):Nq(`discard`)).toStack();R(`discard`,Pq);var Fq=class extends xU{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||bH,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||SH;return n!==bH&&(t=t.toneMapping(n)),r!==SH&&r!==LH.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const Iq=(e,t=null,n=null)=>gW(new Fq(gW(e),t,n));R(`renderOutput`,Iq);var Lq=class extends xU{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
407
+ `,a+=e.flow.code.replace(/^\t/gm,``)+`
408
+ `,a+=`/* ... */ `+n+` /* ... */
409
+ `,a+=`// #`+i+`#
410
+ `,t===null?console.log(a):t(e,a),n}};const Rq=(e,t=null)=>gW(new Lq(gW(e),t));R(`debug`,Rq);const zq=bW(([e])=>Uq(e.rgb)),Bq=bW(([e,t=CW(1)])=>t.mix(Uq(e.rgb),e.rgb)),Vq=bW(([e,t=CW(1)])=>{let n=KW(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return mK(e.rgb,r,i)}),Hq=bW(([e,t=CW(1)])=>{let n=jW(.57735,.57735,.57735),r=t.cos();return jW(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(aK(n,e.rgb).mul(r.oneMinus())))))}),Uq=(e,t=jW(LH.getLuminanceCoefficients(new JH)))=>aK(e,t),Wq={name:`Grayscale`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t}=ck;if(!e)return console.error(`You must pass a child component into the Grayscale shader.`),t(0);let n=e||t(0,0,0,0);return t(zq(n.rgb).rgb,n.a)}};var Gq=r({__name:`Grayscale`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Wq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Wq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(Wq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Wq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Kq=Gq;const qq={name:`HueShift`,props:{shift:{type:Number,default:0,description:`The amount to shift the hue by`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=ck;if(!t)return console.error(`You must pass a child component into the Hue Shift shader.`),n(0);let r=t||n(0,0,0,0);return n(Hq(r.rgb,e.shift.uniform).rgb,r.a)}};var Jq=r({__name:`HueShift`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},shift:{}},{blendMode:`normal`,opacity:1,...Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${qq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(qq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,qq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Yq=Jq;const Xq={name:`Invert`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t,vec3:n}=ck;if(!e)return console.error(`You must pass a child component into the Invert shader.`),t(0);let r=e||t(0,0,0,0);return t(n(1,1,1).sub(r.rgb),r.a)}};var Zq=r({__name:`Invert`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Xq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Xq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Xq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Xq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(Xq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Xq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Qq=Zq;const $q={name:`LinearGradient`,props:{startColor:{type:String,default:`#1aff00`,transform:jV,description:`The starting color of the gradient`},endColor:{type:String,default:`#0000ff`,transform:jV,description:`The ending color of the gradient`},angle:{type:Number,default:0,description:`rotation angle in degrees (0-360, where 0 = left-to-right)`},center:{type:Object,default:{x:.5,y:.5},transform:MV},autoRotate:{type:Boolean,default:!1,description:`Enable automatic rotation of the gradient`},autoRotateSpeed:{type:Number,default:1,description:`Speed of the automatic rotation in degrees per second`}},fragmentNode:({uniforms:e,onBeforeRender:t})=>{let{vec2:n,mix:r,float:i,cos:a,sin:o,dot:s,radians:c,viewportUV:l,abs:u,div:d,uniform:f}=ck,p=f(0);t(({deltaTime:t})=>{if(e.autoRotate.uniform.value){let n=e.autoRotateSpeed.uniform.value*t*100;p.value=(p.value+n)%360}});let m=e.angle.uniform.add(p),h=c(m),g=a(h),_=o(h),v=n(g,_),y=n(e.center.uniform[0],e.center.uniform[1]),b=l.sub(y),x=s(b,v),S=i(.5).mul(u(g).add(u(_))),ee=d(x,S.max(1e-6)),te=ee.mul(.5).add(.5).clamp(i(0),i(1));return r(e.startColor.uniform,e.endColor.uniform,te)}};var eJ=r({__name:`LinearGradient`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},startColor:{},endColor:{},angle:{},center:{},autoRotate:{type:Boolean},autoRotateSpeed:{}},{blendMode:`normal`,opacity:1,...Object.entries($q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${$q.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries($q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries($q.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI($q,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,$q.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),tJ=eJ,nJ=class extends xU{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const rJ=z(nJ).setParameterLength(2),iJ={name:`Posterize`,props:{intensity:{type:Number,default:5,description:`The intensity of the posterization effect (lower is more posterized)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n,int:r}=ck;if(!t)return console.error(`You must pass a child component into the Posterize shader.`),n(0);let i=t||n(0,0,0,0);return rJ(i,r(e.intensity.uniform))}};var aJ=r({__name:`Posterize`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(iJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${iJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(iJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(iJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(iJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,iJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),oJ=aJ;const sJ={name:`Saturation`,props:{intensity:{type:Number,default:1,description:`The intensity of the saturation effect (1 being no change)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=ck;if(!t)return console.error(`You must pass a child component into the Saturation shader.`),n(0);let r=t||n(0,0,0,0);return n(Bq(r.rgb,e.intensity.uniform).rgb,r.a)}};var cJ=r({__name:`Saturation`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(sJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${sJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(sJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(sJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(sJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,sJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),lJ=cJ;const uJ={name:`SolidColor`,props:{color:{type:String,default:`#5b18ca`,transform:jV,description:`The solid color to display`}},fragmentNode:({uniforms:e})=>e.color.uniform};var dJ=r({__name:`SolidColor`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{}},{blendMode:`normal`,opacity:1,...Object.entries(uJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${uJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(uJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(uJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(uJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,uJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),fJ=dJ;const pJ={name:`Twirl`,props:{center:{type:Object,default:{x:.5,y:.5},transform:MV,description:`The center point of the twirl effect`},intensity:{type:Number,default:1,description:`The strength of the twirl effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec2:n,vec4:r,cos:i,sin:a,length:o,uv:s,convertToTexture:c}=ck;if(!t)return console.error(`You must pass a child component into the Twirl shader.`),r(0);let l=c(t),u=s(),d=n(e.center.uniform.x,e.center.uniform.y),f=u.sub(d),p=e.intensity.uniform.mul(o(f)),m=i(p),h=a(p),g=m.mul(f.x).sub(h.mul(f.y)),_=h.mul(f.x).add(m.mul(f.y)),v=n(g.add(d.x),_.add(d.y));return r(l.sample(v))}};var mJ=r({__name:`Twirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},center:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(pJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${pJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(pJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(pJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(pJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,pJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),hJ=mJ;const gJ={name:`Vibrance`,props:{intensity:{type:Number,default:0,description:`The intensity of the vibrance effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=ck;if(!t)return console.error(`You must pass a child component into the Vibrance shader.`),n(0);let r=t||n(0,0,0,0);return n(Vq(r.rgb,e.intensity.uniform).rgb,r.a)}};var _J=r({__name:`Vibrance`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(gJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${gJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(gJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(gJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=fI(gJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Ombre> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,gJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),vJ=_J;const yJ=`177`,bJ=0,xJ=3,SJ=0,CJ=1,wJ=0,TJ=1,EJ=100,DJ=204,OJ=205,kJ=3,AJ=0,jJ=0,MJ=300,NJ=301,PJ=302,FJ=306,IJ=1e3,LJ=1001,RJ=1002,zJ=1003,BJ=1006,VJ=1008,HJ=1008,UJ=1009,WJ=1013,GJ=1014,KJ=1015,qJ=1016,JJ=1023,YJ=1026,XJ=1027,ZJ=1030,QJ=2300,$J=2301,eY=2302,tY=2400,nY=2401,rY=2402,iY=0,aY=1,oY=``,sY=`srgb`,cY=`srgb-linear`,lY=`linear`,uY=`srgb`,dY=7680,fY=519,pY=512,mY=513,hY=514,gY=515,_Y=516,vY=517,yY=518,bY=519,xY=35044,SY=35048,CY=2e3,wY=2001;var TY=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const EY=`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`.split(`.`);let DY=1234567;const OY=Math.PI/180,kY=180/Math.PI;function AY(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=EY[e&255]+EY[e>>8&255]+EY[e>>16&255]+EY[e>>24&255]+`-`+EY[t&255]+EY[t>>8&255]+`-`+EY[t>>16&15|64]+EY[t>>24&255]+`-`+EY[n&63|128]+EY[n>>8&255]+`-`+EY[n>>16&255]+EY[n>>24&255]+EY[r&255]+EY[r>>8&255]+EY[r>>16&255]+EY[r>>24&255];return i.toLowerCase()}function jY(e,t,n){return Math.max(t,Math.min(n,e))}function MY(e,t){return(e%t+t)%t}function NY(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function PY(e,t,n){return e===t?0:(n-e)/(t-e)}function FY(e,t,n){return(1-n)*e+n*t}function IY(e,t,n,r){return FY(e,t,1-Math.exp(-n*r))}function LY(e,t=1){return t-Math.abs(MY(e,t*2)-t)}function RY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function zY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function BY(e,t){return e+Math.floor(Math.random()*(t-e+1))}function VY(e,t){return e+Math.random()*(t-e)}function HY(e){return e*(.5-Math.random())}function UY(e){e!==void 0&&(DY=e);let t=DY+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function WY(e){return e*OY}function GY(e){return e*kY}function KY(e){return(e&e-1)==0&&e!==0}function qY(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function JY(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function YY(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function XY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function ZY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const QY={DEG2RAD:OY,RAD2DEG:kY,generateUUID:AY,clamp:jY,euclideanModulo:MY,mapLinear:NY,inverseLerp:PY,lerp:FY,damp:IY,pingpong:LY,smoothstep:RY,smootherstep:zY,randInt:BY,randFloat:VY,randFloatSpread:HY,seededRandom:UY,degToRad:WY,radToDeg:GY,isPowerOfTwo:KY,ceilPowerOfTwo:qY,floorPowerOfTwo:JY,setQuaternionFromProperEuler:YY,normalize:ZY,denormalize:XY};var $Y=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}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 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 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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+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=jY(this.x,e.x,t.x),this.y=jY(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=jY(this.x,e,t),this.y=jY(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(jY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(jY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},eX=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,n,r){return this._x=e,this._y=t,this._z=n,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){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(jY(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);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*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*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=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},V=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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 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 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(nX.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(nX.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-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){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=jY(this.x,e.x,t.x),this.y=jY(this.y,e.y,t.y),this.z=jY(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=jY(this.x,e,t),this.y=jY(this.y,e,t),this.z=jY(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(jY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return tX.copy(this).projectOnVector(e),this.sub(tX)}reflect(e){return this.sub(tX.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(jY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+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,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const tX=new V,nX=new eX;var rX=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,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){let 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,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(iX.makeScale(e,t)),this}rotate(e){return this.premultiply(iX.makeRotation(-e)),this}translate(e,t){return this.premultiply(iX.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){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const iX=new rX;function aX(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function oX(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const sX={};function cX(e){e in sX||(sX[e]=!0,console.warn(e))}const lX=new rX().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),uX=new rX().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function dX(){let e={enabled:!0,workingColorSpace:cY,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===uY&&(e.r=pX(e.r),e.g=pX(e.g),e.b=pX(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===uY&&(e.r=mX(e.r),e.g=mX(e.g),e.b=mX(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===oY?lY:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return cX(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return cX(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[cY]:{primaries:t,whitePoint:r,transfer:lY,toXYZ:lX,fromXYZ:uX,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:sY},outputColorSpaceConfig:{drawingBufferColorSpace:sY}},[sY]:{primaries:t,whitePoint:r,transfer:uY,toXYZ:lX,fromXYZ:uX,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:sY}}}),e}const fX=dX();function pX(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function mX(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let hX;var gX=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{hX===void 0&&(hX=oX(`canvas`)),hX.width=e.width,hX.height=e.height;let t=hX.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=hX}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=oX(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=pX(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(pX(t[e]/255)*255):t[e]=pX(t[e]);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 _X=0;var vX=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:_X++}),this.uuid=AY(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(yX(r[t].image)):e.push(yX(r[t]))}else e=yX(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function yX(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?gX.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let bX=0;const xX=new V;var SX=class e extends TY{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=LJ,i=LJ,a=BJ,o=VJ,s=JJ,c=UJ,l=e.DEFAULT_ANISOTROPY,u=oY){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:bX++}),this.uuid=AY(),this.name=``,this.source=new vX(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new $Y(0,0),this.repeat=new $Y(1,1),this.center=new $Y(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rX,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(xX).x}get height(){return this.source.getSize(xX).y}get depth(){return this.source.getSize(xX).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==MJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case IJ:e.x-=Math.floor(e.x);break;case LJ:e.x=e.x<0?0:1;break;case RJ:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case IJ:e.y-=Math.floor(e.y);break;case LJ:e.y=e.y<0?0:1;break;case RJ:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(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++}};SX.DEFAULT_IMAGE=null,SX.DEFAULT_MAPPING=MJ,SX.DEFAULT_ANISOTROPY=1;var CX=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}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,n,r){return this.x=e,this.y=t,this.z=n,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 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 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?1:e.w,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){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let 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,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let 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=jY(this.x,e.x,t.x),this.y=jY(this.y,e.y,t.y),this.z=jY(this.z,e.z,t.z),this.w=jY(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=jY(this.x,e,t),this.y=jY(this.y,e,t),this.z=jY(this.z,e,t),this.w=jY(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(jY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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}},wX=class extends TY{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:BJ,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new CX(0,0,e,t),this.scissorTest=!1,this.viewport=new CX(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new SX(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:BJ,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new vX(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},TX=class extends SX{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=zJ,this.minFilter=zJ,this.wrapR=LJ,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},EX=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-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,n=e.length;t<n;t+=3)this.expandByPoint(OX.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(OX.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=OX.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,OX):OX.fromBufferAttribute(r,t),OX.applyMatrix4(e.matrixWorld),this.expandByPoint(OX);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),kX.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),kX.copy(e.boundingBox)),kX.applyMatrix4(e.matrixWorld),this.union(kX)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],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,OX),OX.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(IX),LX.subVectors(this.max,IX),AX.subVectors(e.a,IX),jX.subVectors(e.b,IX),MX.subVectors(e.c,IX),NX.subVectors(jX,AX),PX.subVectors(MX,jX),FX.subVectors(AX,MX);let t=[0,-NX.z,NX.y,0,-PX.z,PX.y,0,-FX.z,FX.y,NX.z,0,-NX.x,PX.z,0,-PX.x,FX.z,0,-FX.x,-NX.y,NX.x,0,-PX.y,PX.x,0,-FX.y,FX.x,0];return!BX(t,AX,jX,MX,LX)||(t=[1,0,0,0,1,0,0,0,1],!BX(t,AX,jX,MX,LX))?!1:(RX.crossVectors(NX,PX),t=[RX.x,RX.y,RX.z],BX(t,AX,jX,MX,LX))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,OX).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(OX).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:(DX[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),DX[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),DX[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),DX[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),DX[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),DX[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),DX[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),DX[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(DX),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const DX=[new V,new V,new V,new V,new V,new V,new V,new V],OX=new V,kX=new EX,AX=new V,jX=new V,MX=new V,NX=new V,PX=new V,FX=new V,IX=new V,LX=new V,RX=new V,zX=new V;function BX(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){zX.fromArray(e,a);let o=i.x*Math.abs(zX.x)+i.y*Math.abs(zX.y)+i.z*Math.abs(zX.z),s=t.dot(zX),c=n.dot(zX),l=r.dot(zX);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const VX=new EX,HX=new V,UX=new V;var WX=class{constructor(e=new V,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){let n=this.center;t===void 0?VX.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));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){let 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){let n=this.center.distanceToSquared(e);return t.copy(e),n>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*=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;HX.subVectors(e,this.center);let t=HX.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(HX,n/e),this.radius+=n}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):(UX.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(HX.copy(e.center).add(UX)),this.expandByPoint(HX.copy(e.center).sub(UX))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const GX=new V,KX=new V,qX=new V,JX=new V,YX=new V,XX=new V,ZX=new V;var QX=class{constructor(e=new V,t=new V(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,GX)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=GX.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(GX.copy(this.origin).addScaledVector(this.direction,t),GX.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){KX.copy(e).add(t).multiplyScalar(.5),qX.copy(t).sub(e).normalize(),JX.copy(this.origin).sub(KX);let i=e.distanceTo(t)*.5,a=-this.direction.dot(qX),o=JX.dot(this.direction),s=-JX.dot(qX),c=JX.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(KX).addScaledVector(qX,d),f}intersectSphere(e,t){GX.subVectors(e.center,this.origin);let n=GX.dot(this.direction),r=GX.dot(GX)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,GX)!==null}intersectTriangle(e,t,n,r,i){YX.subVectors(t,e),XX.subVectors(n,e),ZX.crossVectors(YX,XX);let a=this.direction.dot(ZX),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;JX.subVectors(this.origin,e);let s=o*this.direction.dot(XX.crossVectors(JX,XX));if(s<0)return null;let c=o*this.direction.dot(YX.cross(JX));if(c<0||s+c>a)return null;let l=-o*JX.dot(ZX);return l<0?null:this.at(l/a,i)}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)}},$X=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,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 e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/eZ.setFromMatrixColumn(e,0).length(),i=1/eZ.setFromMatrixColumn(e,1).length(),a=1/eZ.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}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(nZ,e,rZ)}lookAt(e,t,n){let r=this.elements;return oZ.subVectors(e,t),oZ.lengthSq()===0&&(oZ.z=1),oZ.normalize(),iZ.crossVectors(n,oZ),iZ.lengthSq()===0&&(Math.abs(n.z)===1?oZ.x+=1e-4:oZ.z+=1e-4,oZ.normalize(),iZ.crossVectors(n,oZ)),iZ.normalize(),aZ.crossVectors(oZ,iZ),r[0]=iZ.x,r[4]=aZ.x,r[8]=oZ.x,r[1]=iZ.y,r[5]=aZ.y,r[9]=oZ.y,r[2]=iZ.z,r[6]=aZ.z,r[10]=oZ.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,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,n){let 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]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=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,n,r))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=eZ.set(r[0],r[1],r[2]).length(),a=eZ.set(r[4],r[5],r[6]).length(),o=eZ.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],tZ.copy(this);let c=1/i,l=1/a,u=1/o;return tZ.elements[0]*=c,tZ.elements[1]*=c,tZ.elements[2]*=c,tZ.elements[4]*=l,tZ.elements[5]*=l,tZ.elements[6]*=l,tZ.elements[8]*=u,tZ.elements[9]*=u,tZ.elements[10]*=u,t.setFromRotationMatrix(tZ),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=CY){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===CY)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===wY)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=CY){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===CY)p=(a+i)*u,m=-2*u;else if(o===wY)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const eZ=new V,tZ=new $X,nZ=new V(0,0,0),rZ=new V(1,1,1),iZ=new V,aZ=new V,oZ=new V,sZ=new $X,cZ=new eX;var lZ=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}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,n,r=this._order){return this._x=e,this._y=t,this._z=n,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,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(jY(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-jY(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(jY(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-jY(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(jY(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-jY(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return sZ.makeRotationFromQuaternion(e),this.setFromRotationMatrix(sZ,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return cZ.setFromEuler(this),this.setFromQuaternion(cZ,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}};lZ.DEFAULT_ORDER=`XYZ`;var uZ=class{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 dZ=0;const fZ=new V,pZ=new eX,mZ=new $X,hZ=new V,gZ=new V,_Z=new V,vZ=new eX,yZ=new V(1,0,0),bZ=new V(0,1,0),xZ=new V(0,0,1),SZ={type:`added`},CZ={type:`removed`},wZ={type:`childadded`,child:null},TZ={type:`childremoved`,child:null};var EZ=class e extends TY{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:dZ++}),this.uuid=AY(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new V,n=new lZ,r=new eX,i=new V(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $X},normalMatrix:{value:new rX}}),this.matrix=new $X,this.matrixWorld=new $X,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uZ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.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 pZ.setFromAxisAngle(e,t),this.quaternion.multiply(pZ),this}rotateOnWorldAxis(e,t){return pZ.setFromAxisAngle(e,t),this.quaternion.premultiply(pZ),this}rotateX(e){return this.rotateOnAxis(yZ,e)}rotateY(e){return this.rotateOnAxis(bZ,e)}rotateZ(e){return this.rotateOnAxis(xZ,e)}translateOnAxis(e,t){return fZ.copy(e).applyQuaternion(this.quaternion),this.position.add(fZ.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(yZ,e)}translateY(e){return this.translateOnAxis(bZ,e)}translateZ(e){return this.translateOnAxis(xZ,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mZ.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?hZ.copy(e):hZ.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),gZ.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mZ.lookAt(gZ,hZ,this.up):mZ.lookAt(hZ,gZ,this.up),this.quaternion.setFromRotationMatrix(mZ),r&&(mZ.extractRotation(r.matrixWorld),pZ.setFromRotationMatrix(mZ),this.quaternion.premultiply(pZ.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);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(SZ),wZ.child=e,this.dispatchEvent(wZ),wZ.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(CZ),TZ.child=e,this.dispatchEvent(TZ),TZ.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),mZ.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mZ.multiply(e.parent.matrixWorld)),e.applyMatrix4(mZ),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(SZ),wZ.child=e,this.dispatchEvent(wZ),wZ.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 n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gZ,e,_Z),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gZ,vZ,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let 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);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let 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.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.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=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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 t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};EZ.DEFAULT_UP=new V(0,1,0),EZ.DEFAULT_MATRIX_AUTO_UPDATE=!0,EZ.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const DZ=new V,OZ=new V,kZ=new V,AZ=new V,jZ=new V,MZ=new V,NZ=new V,PZ=new V,FZ=new V,IZ=new V,LZ=new CX,RZ=new CX,zZ=new CX;var BZ=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),DZ.subVectors(e,t),r.cross(DZ);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){DZ.subVectors(r,t),OZ.subVectors(n,t),kZ.subVectors(e,t);let a=DZ.dot(DZ),o=DZ.dot(OZ),s=DZ.dot(kZ),c=OZ.dot(OZ),l=OZ.dot(kZ),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,AZ)===null?!1:AZ.x>=0&&AZ.y>=0&&AZ.x+AZ.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,AZ)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,AZ.x),s.addScaledVector(a,AZ.y),s.addScaledVector(o,AZ.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return LZ.setScalar(0),RZ.setScalar(0),zZ.setScalar(0),LZ.fromBufferAttribute(e,t),RZ.fromBufferAttribute(e,n),zZ.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(LZ,i.x),a.addScaledVector(RZ,i.y),a.addScaledVector(zZ,i.z),a}static isFrontFacing(e,t,n,r){return DZ.subVectors(n,t),OZ.subVectors(e,t),DZ.cross(OZ).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 DZ.subVectors(this.c,this.b),OZ.subVectors(this.a,this.b),DZ.cross(OZ).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;jZ.subVectors(r,n),MZ.subVectors(i,n),PZ.subVectors(e,n);let s=jZ.dot(PZ),c=MZ.dot(PZ);if(s<=0&&c<=0)return t.copy(n);FZ.subVectors(e,r);let l=jZ.dot(FZ),u=MZ.dot(FZ);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(jZ,a);IZ.subVectors(e,i);let f=jZ.dot(IZ),p=MZ.dot(IZ);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(MZ,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return NZ.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(NZ,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(jZ,a).addScaledVector(MZ,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const VZ={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},HZ={h:0,s:0,l:0},UZ={h:0,s:0,l:0};function WZ(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var GZ=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=sY){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,fX.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=fX.workingColorSpace){return this.r=e,this.g=t,this.b=n,fX.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=fX.workingColorSpace){if(e=MY(e,1),t=jY(t,0,1),n=jY(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=WZ(i,r,e+1/3),this.g=WZ(i,r,e),this.b=WZ(i,r,e-1/3)}return fX.colorSpaceToWorking(this,r),this}setStyle(e,t=sY){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,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=sY){let n=VZ[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),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=pX(e.r),this.g=pX(e.g),this.b=pX(e.b),this}copyLinearToSRGB(e){return this.r=mX(e.r),this.g=mX(e.g),this.b=mX(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=sY){return fX.workingToColorSpace(KZ.copy(this),e),Math.round(jY(KZ.r*255,0,255))*65536+Math.round(jY(KZ.g*255,0,255))*256+Math.round(jY(KZ.b*255,0,255))}getHexString(e=sY){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=fX.workingColorSpace){fX.workingToColorSpace(KZ.copy(this),t);let n=KZ.r,r=KZ.g,i=KZ.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=fX.workingColorSpace){return fX.workingToColorSpace(KZ.copy(this),t),e.r=KZ.r,e.g=KZ.g,e.b=KZ.b,e}getStyle(e=sY){fX.workingToColorSpace(KZ.copy(this),e);let t=KZ.r,n=KZ.g,r=KZ.b;return e===sY?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(HZ),this.setHSL(HZ.h+e,HZ.s+t,HZ.l+n)}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,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(HZ),e.getHSL(UZ);let n=FY(HZ.h,UZ.h,t),r=FY(HZ.s,UZ.s,t),i=FY(HZ.l,UZ.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[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 KZ=new GZ;GZ.NAMES=VZ;let qZ=0;var JZ=class extends TY{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:qZ++}),this.uuid=AY(),this.name=``,this.type=`Material`,this.blending=TJ,this.side=SJ,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=DJ,this.blendDst=OJ,this.blendEquation=EJ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new GZ(0,0,0),this.blendAlpha=0,this.depthFunc=kJ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=fY,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=dY,this.stencilZFail=dY,this.stencilZPass=dY,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let 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(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==TJ&&(n.blending=this.blending),this.side!==SJ&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==DJ&&(n.blendSrc=this.blendSrc),this.blendDst!==OJ&&(n.blendDst=this.blendDst),this.blendEquation!==EJ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==kJ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==fY&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==dY&&(n.stencilFail=this.stencilFail),this.stencilZFail!==dY&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==dY&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}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;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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++}},YZ=class extends JZ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new GZ(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 lZ,this.combine=AJ,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 XZ=new V,ZZ=new $Y;let QZ=0;var $Z=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:QZ++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=xY,this.updateRanges=[],this.gpuType=KJ,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,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)ZZ.fromBufferAttribute(this,t),ZZ.applyMatrix3(e),this.setXY(t,ZZ.x,ZZ.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)XZ.fromBufferAttribute(this,t),XZ.applyMatrix3(e),this.setXYZ(t,XZ.x,XZ.y,XZ.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)XZ.fromBufferAttribute(this,t),XZ.applyMatrix4(e),this.setXYZ(t,XZ.x,XZ.y,XZ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)XZ.fromBufferAttribute(this,t),XZ.applyNormalMatrix(e),this.setXYZ(t,XZ.x,XZ.y,XZ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)XZ.fromBufferAttribute(this,t),XZ.transformDirection(e),this.setXYZ(t,XZ.x,XZ.y,XZ.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=XY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ZY(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=XY(t,this.array)),t}setX(e,t){return this.normalized&&(t=ZY(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=XY(t,this.array)),t}setY(e,t){return this.normalized&&(t=ZY(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=XY(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ZY(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=XY(t,this.array)),t}setW(e,t){return this.normalized&&(t=ZY(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array),r=ZY(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array),r=ZY(r,this.array),i=ZY(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==xY&&(e.usage=this.usage),e}},eQ=class extends $Z{constructor(e,t,n){super(new Uint16Array(e),t,n)}},tQ=class extends $Z{constructor(e,t,n){super(new Uint32Array(e),t,n)}},nQ=class extends $Z{constructor(e,t,n){super(new Float32Array(e),t,n)}};let rQ=0;const iQ=new $X,aQ=new EZ,oQ=new V,sQ=new EX,cQ=new EX,lQ=new V;var uQ=class e extends TY{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:rQ++}),this.uuid=AY(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=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(aX(e)?tQ:eQ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new rX().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let 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 iQ.makeRotationFromQuaternion(e),this.applyMatrix4(iQ),this}rotateX(e){return iQ.makeRotationX(e),this.applyMatrix4(iQ),this}rotateY(e){return iQ.makeRotationY(e),this.applyMatrix4(iQ),this}rotateZ(e){return iQ.makeRotationZ(e),this.applyMatrix4(iQ),this}translate(e,t,n){return iQ.makeTranslation(e,t,n),this.applyMatrix4(iQ),this}scale(e,t,n){return iQ.makeScale(e,t,n),this.applyMatrix4(iQ),this}lookAt(e){return aQ.lookAt(e),aQ.updateMatrix(),this.applyMatrix4(aQ.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(oQ).negate(),this.translate(oQ.x,oQ.y,oQ.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new nQ(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new EX);let 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 V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];sQ.setFromBufferAttribute(n),this.morphTargetsRelative?(lQ.addVectors(this.boundingBox.min,sQ.min),this.boundingBox.expandByPoint(lQ),lQ.addVectors(this.boundingBox.max,sQ.max),this.boundingBox.expandByPoint(lQ)):(this.boundingBox.expandByPoint(sQ.min),this.boundingBox.expandByPoint(sQ.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 WX);let 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 V,1/0);return}if(e){let n=this.boundingSphere.center;if(sQ.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];cQ.setFromBufferAttribute(n),this.morphTargetsRelative?(lQ.addVectors(sQ.min,cQ.min),sQ.expandByPoint(lQ),lQ.addVectors(sQ.max,cQ.max),sQ.expandByPoint(lQ)):(sQ.expandByPoint(cQ.min),sQ.expandByPoint(cQ.max))}sQ.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)lQ.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(lQ));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)lQ.fromBufferAttribute(a,t),o&&(oQ.fromBufferAttribute(e,t),lQ.add(oQ)),r=Math.max(r,n.distanceToSquared(lQ))}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(){let 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}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new $Z(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new V,s[e]=new V;let c=new V,l=new V,u=new V,d=new $Y,f=new $Y,p=new $Y,m=new V,h=new V;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new V,y=new V,b=new V,x=new V;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new $Z(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)lQ.fromBufferAttribute(e,t),lQ.normalize(),e.setXYZ(t,lQ.x,lQ.y,lQ.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new $Z(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const dQ=new $X,fQ=new QX,pQ=new WX,mQ=new V,hQ=new V,gQ=new V,_Q=new V,vQ=new V,yQ=new V,bQ=new V,xQ=new V;var SQ=class extends EZ{constructor(e=new uQ,t=new YZ){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){yQ.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(vQ.fromBufferAttribute(s,e),a?yQ.addScaledVector(vQ,r):yQ.addScaledVector(vQ.sub(t),r))}t.add(yQ)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),pQ.copy(n.boundingSphere),pQ.applyMatrix4(i),fQ.copy(e.ray).recast(e.near),!(pQ.containsPoint(fQ.origin)===!1&&(fQ.intersectSphere(pQ,mQ)===null||fQ.origin.distanceToSquared(mQ)>(e.far-e.near)**2))&&(dQ.copy(i).invert(),fQ.copy(e.ray).applyMatrix4(dQ),!(n.boundingBox!==null&&fQ.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,fQ)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=wQ(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=wQ(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=wQ(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=wQ(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function CQ(e,t,n,r,i,a,o,s){let c;if(c=t.side===CJ?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===SJ,s),c===null)return null;xQ.copy(s),xQ.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(xQ);return l<n.near||l>n.far?null:{distance:l,point:xQ.clone(),object:e}}function wQ(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,hQ),e.getVertexPosition(c,gQ),e.getVertexPosition(l,_Q);let u=CQ(e,t,n,r,hQ,gQ,_Q,bQ);if(u){let e=new V;BZ.getBarycoord(bQ,hQ,gQ,_Q,e),i&&(u.uv=BZ.getInterpolatedAttribute(i,s,c,l,e,new $Y)),a&&(u.uv1=BZ.getInterpolatedAttribute(a,s,c,l,e,new $Y)),o&&(u.normal=BZ.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};BZ.getNormal(hQ,gQ,_Q,t.normal),u.face=t,u.barycoord=e}return u}var TQ=class e extends uQ{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new nQ(c,3)),this.setAttribute(`normal`,new nQ(l,3)),this.setAttribute(`uv`,new nQ(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new V;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},EQ=class extends EZ{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new $X,this.projectionMatrix=new $X,this.projectionMatrixInverse=new $X,this.coordinateSystem=CY}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 DQ=new V,OQ=new $Y,kQ=new $Y;var AQ=class extends EQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,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){let t=.5*this.getFilmHeight()/e;this.fov=kY*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(OY*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return kY*2*Math.atan(Math.tan(OY*.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,n){DQ.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(DQ.x,DQ.y).multiplyScalar(-e/DQ.z),DQ.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(DQ.x,DQ.y).multiplyScalar(-e/DQ.z)}getViewSize(e,t){return this.getViewBounds(e,OQ,kQ),t.subVectors(kQ,OQ)}setViewOffset(e,t,n,r,i,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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(OY*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},jQ=class extends SX{constructor(e=[],t=NJ,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},MQ=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=xY,this.updateRanges=[],this.version=0,this.uuid=AY()}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,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+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=AY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}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=AY()),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 NQ=new V;var PQ=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,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,n=this.data.count;t<n;t++)NQ.fromBufferAttribute(this,t),NQ.applyMatrix4(e),this.setXYZ(t,NQ.x,NQ.y,NQ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)NQ.fromBufferAttribute(this,t),NQ.applyNormalMatrix(e),this.setXYZ(t,NQ.x,NQ.y,NQ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)NQ.fromBufferAttribute(this,t),NQ.transformDirection(e),this.setXYZ(t,NQ.x,NQ.y,NQ.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=XY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ZY(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ZY(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ZY(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ZY(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ZY(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=XY(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=XY(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=XY(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=XY(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array),r=ZY(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ZY(t,this.array),n=ZY(n,this.array),r=ZY(r,this.array),i=ZY(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new $Z(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.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.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,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}}},FQ=class extends $Z{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const IQ=new V,LQ=new V,RQ=new rX;var zQ=class{constructor(e=new V(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=IQ.subVectors(n,t).cross(LQ.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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){let n=e.delta(IQ),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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){let n=t||RQ.getNormalMatrix(e),r=this.coplanarPoint(IQ).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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)}},BQ=class extends SX{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=zJ,this.minFilter=zJ,this.generateMipmaps=!1,this.needsUpdate=!0}},VQ=class extends SX{constructor(e,t,n=GJ,r,i,a,o=zJ,s=zJ,c,l=YJ,u=1){if(l!==YJ&&l!==XJ)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vX(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function HQ(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function UQ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var WQ=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},GQ=class extends WQ{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tY,endingEnd:tY}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case nY:i=e,o=2*t-n;break;case rY:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case nY:a=e,s=2*n-t;break;case rY:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},KQ=class extends WQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},qQ=class extends WQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},JQ=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=HQ(t,this.TimeBufferType),this.values=HQ(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:HQ(e.times,Array),values:HQ(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new qQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new KQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new GQ(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case QJ:t=this.InterpolantFactoryMethodDiscrete;break;case $J:t=this.InterpolantFactoryMethodLinear;break;case eY:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`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 Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return QJ;case this.InterpolantFactoryMethodLinear:return $J;case this.InterpolantFactoryMethodSmooth:return eY}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&UQ(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===eY,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};JQ.prototype.ValueTypeName=``,JQ.prototype.TimeBufferType=Float32Array,JQ.prototype.ValueBufferType=Float32Array,JQ.prototype.DefaultInterpolation=$J;var YQ=class extends JQ{constructor(e,t,n){super(e,t,n)}};YQ.prototype.ValueTypeName=`bool`,YQ.prototype.ValueBufferType=Array,YQ.prototype.DefaultInterpolation=QJ,YQ.prototype.InterpolantFactoryMethodLinear=void 0,YQ.prototype.InterpolantFactoryMethodSmooth=void 0;var XQ=class extends JQ{constructor(e,t,n,r){super(e,t,n,r)}};XQ.prototype.ValueTypeName=`color`;var ZQ=class extends JQ{constructor(e,t,n,r){super(e,t,n,r)}};ZQ.prototype.ValueTypeName=`number`;var QQ=class extends WQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)eX.slerpFlat(i,0,a,c-o,a,c,s);return i}},$Q=class extends JQ{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new QQ(this.times,this.values,this.getValueSize(),e)}};$Q.prototype.ValueTypeName=`quaternion`,$Q.prototype.InterpolantFactoryMethodSmooth=void 0;var e$=class extends JQ{constructor(e,t,n){super(e,t,n)}};e$.prototype.ValueTypeName=`string`,e$.prototype.ValueBufferType=Array,e$.prototype.DefaultInterpolation=QJ,e$.prototype.InterpolantFactoryMethodLinear=void 0,e$.prototype.InterpolantFactoryMethodSmooth=void 0;var t$=class extends JQ{constructor(e,t,n,r){super(e,t,n,r)}};t$.prototype.ValueTypeName=`vector`;var n$=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const r$=new n$;var i$=class{constructor(e){this.manager=e===void 0?r$:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}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}};i$.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var a$=class extends EQ{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,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,n,r,i,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=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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 o$=`\\[\\]\\.:\\/`,s$=RegExp(`[`+o$+`]`,`g`),c$=`[^`+o$+`]`,l$=`[^`+o$.replace(`\\.`,``)+`]`,u$=/((?:WC+[\/:])*)/.source.replace(`WC`,c$),d$=/(WCOD+)?/.source.replace(`WCOD`,l$),f$=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,c$),p$=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,c$),m$=RegExp(`^`+u$+d$+f$+p$+`$`),h$=[`material`,`materials`,`bones`,`map`];var g$=class{constructor(e,t,n){let r=n||_$.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},_$=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(s$,``)}static parseTrackName(e){let t=m$.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);h$.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[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){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[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 t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};_$.Composite=g$,_$.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},_$.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},_$.prototype.GetterByBindingType=[_$.prototype._getValue_direct,_$.prototype._getValue_array,_$.prototype._getValue_arrayElement,_$.prototype._getValue_toArray],_$.prototype.SetterByBindingTypeAndVersioning=[[_$.prototype._setValue_direct,_$.prototype._setValue_direct_setNeedsUpdate,_$.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[_$.prototype._setValue_array,_$.prototype._setValue_array_setNeedsUpdate,_$.prototype._setValue_array_setMatrixWorldNeedsUpdate],[_$.prototype._setValue_arrayElement,_$.prototype._setValue_arrayElement_setNeedsUpdate,_$.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[_$.prototype._setValue_fromArray,_$.prototype._setValue_fromArray_setNeedsUpdate,_$.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const noe=new Float32Array(1);var v$=class extends MQ{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},y$=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:yJ}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=yJ);const b$=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var x$=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=b$,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function S$(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const C$=e=>S$(e),w$=e=>S$(e),T$=(...e)=>S$(e);function E$(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of D$(e))n.push(S$(r.slice(0,-4)),i.getCacheKey(t));return S$(n)}function*D$(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const O$=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),k$=new WeakMap;function A$(e){return O$.get(e)}function j$(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function M$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function N$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function P$(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function F$(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function I$(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new GZ(...t):n===`vec2`?new $Y(...t):n===`vec3`?new V(...t):n===`vec4`?new CX(...t):n===`mat2`?new y$(...t):n===`mat3`?new rX(...t):n===`mat4`?new $X(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?z$(t[0]):null}function L$(e){let t=k$.get(e);return t===void 0&&(t={},k$.set(e,t)),t}function R$(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function z$(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const B$={VERTEX:`vertex`,FRAGMENT:`fragment`},V$={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},H$={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},U$={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},W$=[`fragment`,`vertex`],G$=[`setup`,`analyze`,`generate`],K$=[...W$,`compute`],q$=[`x`,`y`,`z`,`w`],J$={analyze:`setup`,generate:`analyze`};let Y$=0;var X$=class extends TY{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=V$.NONE,this.updateBeforeType=V$.NONE,this.updateAfterType=V$.NONE,this.uuid=QY.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Y$++})}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,V$.FRAME)}onRenderUpdate(e){return this.onUpdate(e,V$.RENDER)}onObjectUpdate(e){return this.onUpdate(e,V$.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(let{childNode:e}of D$(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=T$(E$(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=J$[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return D$(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},Z$=class extends X${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){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},Q$=class extends X${static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},$$=class extends X${static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},e1=class extends $${static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const t1=q$.join(``);var n1=class extends X${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(let t of this.components)e=Math.max(q$.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){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===t1.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},r1=class extends $${static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=q$[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},i1=class extends $${static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=q$[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},a1=class extends X${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?F$(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=F$(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=R$(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?I$(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.`)}};const o1=/float|u?int/;var s1=class extends a1{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){let n=this.getNodeType(e);return o1.test(n)&&o1.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},c1=class extends X${static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let l1=null;const u1=new Map;function H(e,t){if(u1.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);u1.set(e,t)}const d1=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),f1=e=>d1(e).split(``).sort().join(``),p1={setup(e,t){let n=t.shift();return e(z1(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(l1.assign(n,...e),n);if(u1.has(t)){let r=u1.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&u1.has(t.slice(0,t.length-6))){let r=u1.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=d1(t),U(new n1(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=f1(t.slice(3).toLowerCase()),n=>U(new r1(e,t,U(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=f1(t.slice(4).toLowerCase()),()=>U(new i1(U(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),U(new n1(e,t));else if(/^\d+$/.test(t)===!0)return U(new Z$(n,new s1(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>U(new c1(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},m1=new WeakMap,h1=new WeakMap,g1=function(e,t=null){let n=F$(e);if(n===`node`){let t=m1.get(e);return t===void 0&&(t=new Proxy(e,p1),m1.set(e,t),m1.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return U(N1(e,t));else if(n===`shader`)return K(e);return e},_1=function(e,t=null){for(let n in e)e[n]=U(e[n],t);return e},v1=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=U(e[r],t);return e},y1=function(e,t=null,n=null,r=null){let i=e=>U(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...B1(l(t)))):n===null?a=(...n)=>i(new e(t,...B1(l(n)))):(n=U(n),a=(...r)=>i(new e(t,...B1(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},b1=function(e,...t){return U(new e(...B1(t)))};var x1=class extends X${constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=h1.get(e.constructor);r===void 0&&(r=new WeakMap,h1.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=U(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=U(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=U(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},S1=class extends X${constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return z1(e),U(new x1(this,e))}setup(){return this.call()}};const C1=[!1,!0],w1=[0,1,2,3],T1=[-1,-2],E1=[.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],D1=new Map;for(let e of C1)D1.set(e,new s1(e));const O1=new Map;for(let e of w1)O1.set(e,new s1(e,`uint`));const k1=new Map([...O1].map(e=>new s1(e.value,`int`)));for(let e of T1)k1.set(e,new s1(e,`int`));const A1=new Map([...k1].map(e=>new s1(e.value)));for(let e of E1)A1.set(e,new s1(e));for(let e of E1)A1.set(-e,new s1(-e));const j1={bool:D1,uint:O1,ints:k1,float:A1},M1=new Map([...D1,...A1]),N1=(e,t)=>M1.has(e)?M1.get(e):e.isNode===!0?e:new s1(e,t),P1=e=>{try{return e.getNodeType()}catch{return}},F1=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[I$(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return U(t.get(n[0]));if(n.length===1){let t=N1(n[0],e);return P1(t)===e?U(t):U(new Q$(t,e))}let r=n.map(e=>N1(e));return U(new e1(r,e))}},I1=e=>typeof e==`object`&&e?e.value:e,L1=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function R1(e,t){return new Proxy(new S1(e,t),p1)}const U=(e,t=null)=>g1(e,t),z1=(e,t=null)=>new _1(e,t),B1=(e,t=null)=>new v1(e,t),W=(...e)=>new y1(...e),G=(...e)=>new b1(...e);let V1=0;const K=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new R1(e,n),i=(...e)=>{let t;z1(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ V1++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},H1=e=>{l1=e},U1=()=>l1,W1=(...e)=>l1.If(...e),G1=(...e)=>l1.Switch(...e);function K1(e){return l1&&l1.add(e),e}H(`toStack`,K1);const q1=new F1(`color`),q=new F1(`float`,j1.float),J=new F1(`int`,j1.ints),J1=new F1(`uint`,j1.uint),Y1=new F1(`bool`,j1.bool),Y=new F1(`vec2`),X1=new F1(`ivec2`),Z1=new F1(`uvec2`),Q1=new F1(`bvec2`),X=new F1(`vec3`),$1=new F1(`ivec3`),e0=new F1(`uvec3`),t0=new F1(`bvec3`),n0=new F1(`vec4`),r0=new F1(`ivec4`),i0=new F1(`uvec4`),a0=new F1(`bvec4`),o0=new F1(`mat2`),s0=new F1(`mat3`),c0=new F1(`mat4`),l0=(e=``)=>U(new s1(e,`string`)),u0=e=>U(new s1(e,`ArrayBuffer`));H(`toColor`,q1),H(`toFloat`,q),H(`toInt`,J),H(`toUint`,J1),H(`toBool`,Y1),H(`toVec2`,Y),H(`toIVec2`,X1),H(`toUVec2`,Z1),H(`toBVec2`,Q1),H(`toVec3`,X),H(`toIVec3`,$1),H(`toUVec3`,e0),H(`toBVec3`,t0),H(`toVec4`,n0),H(`toIVec4`,r0),H(`toUVec4`,i0),H(`toBVec4`,a0),H(`toMat2`,o0),H(`toMat3`,s0),H(`toMat4`,c0);const d0=W(Z$).setParameterLength(2),f0=(e,t)=>U(new Q$(U(e),t)),p0=(e,t)=>U(new n1(U(e),t));H(`element`,d0),H(`convert`,f0);const m0=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),K1(e));H(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),K1(e)));const h0=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),K(...e));var g0=class extends X${static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const _0=(e,t)=>U(new g0(e,t)),v0=(e,t)=>U(new g0(e,t,!0)),y0=G(g0,`vec4`,`DiffuseColor`),b0=G(g0,`vec3`,`EmissiveColor`),x0=G(g0,`float`,`Roughness`),S0=G(g0,`float`,`Metalness`),C0=G(g0,`float`,`Clearcoat`),w0=G(g0,`float`,`ClearcoatRoughness`),T0=G(g0,`vec3`,`Sheen`),E0=G(g0,`float`,`SheenRoughness`),D0=G(g0,`float`,`Iridescence`),O0=G(g0,`float`,`IridescenceIOR`),k0=G(g0,`float`,`IridescenceThickness`),A0=G(g0,`float`,`AlphaT`),j0=G(g0,`float`,`Anisotropy`),M0=G(g0,`vec3`,`AnisotropyT`),N0=G(g0,`vec3`,`AnisotropyB`),P0=G(g0,`color`,`SpecularColor`),F0=G(g0,`float`,`SpecularF90`),I0=G(g0,`float`,`Shininess`),L0=G(g0,`vec4`,`Output`),R0=G(g0,`float`,`dashSize`),z0=G(g0,`float`,`gapSize`),B0=G(g0,`float`,`pointWidth`),V0=G(g0,`float`,`IOR`),H0=G(g0,`float`,`Transmission`),U0=G(g0,`float`,`Thickness`),W0=G(g0,`float`,`AttenuationDistance`),G0=G(g0,`color`,`AttenuationColor`),K0=G(g0,`float`,`Dispersion`);var q0=class extends X${static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const J0=e=>new q0(e),Y0=(e,t=0)=>new q0(e,!0,t),X0=Y0(`frame`),Z0=Y0(`render`),Q0=J0(`object`);var $0=class extends a1{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=Q0}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){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const e2=(e,t)=>{let n=L1(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return U(new $0(r,n))};var t2=class extends $${static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const n2=(...e)=>{let t;if(e.length===1){let n=e[0];t=new t2(null,n.length,n)}else{let n=e[0],r=e[1];t=new t2(n,r)}return U(t)};H(`toArray`,(e,t)=>n2(Array(t).fill(e)));var r2=class extends $${static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=q$.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const i2=W(r2).setParameterLength(2);H(`assign`,i2);var a2=class extends $${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){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const o2=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?B1(t):z1(t[0]),U(new a2(U(e),t)));H(`call`,o2);const s2={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var c2=class e extends $${static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(s2[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===CY;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const l2=W(c2,`+`).setParameterLength(2,1/0).setName(`add`),u2=W(c2,`-`).setParameterLength(2,1/0).setName(`sub`),d2=W(c2,`*`).setParameterLength(2,1/0).setName(`mul`),f2=W(c2,`/`).setParameterLength(2,1/0).setName(`div`),p2=W(c2,`%`).setParameterLength(2).setName(`mod`),m2=W(c2,`==`).setParameterLength(2).setName(`equal`),h2=W(c2,`!=`).setParameterLength(2).setName(`notEqual`),g2=W(c2,`<`).setParameterLength(2).setName(`lessThan`),_2=W(c2,`>`).setParameterLength(2).setName(`greaterThan`),v2=W(c2,`<=`).setParameterLength(2).setName(`lessThanEqual`),y2=W(c2,`>=`).setParameterLength(2).setName(`greaterThanEqual`),b2=W(c2,`&&`).setParameterLength(2,1/0).setName(`and`),x2=W(c2,`||`).setParameterLength(2,1/0).setName(`or`),S2=W(c2,`!`).setParameterLength(1).setName(`not`),C2=W(c2,`^^`).setParameterLength(2).setName(`xor`),w2=W(c2,`&`).setParameterLength(2).setName(`bitAnd`),T2=W(c2,`~`).setParameterLength(2).setName(`bitNot`),E2=W(c2,`|`).setParameterLength(2).setName(`bitOr`),D2=W(c2,`^`).setParameterLength(2).setName(`bitXor`),O2=W(c2,`<<`).setParameterLength(2).setName(`shiftLeft`),k2=W(c2,`>>`).setParameterLength(2).setName(`shiftRight`),A2=K(([e])=>(e.addAssign(1),e)),j2=K(([e])=>(e.subAssign(1),e)),M2=K(([e])=>{let t=J(e).toConst();return e.addAssign(1),t}),N2=K(([e])=>{let t=J(e).toConst();return e.subAssign(1),t});H(`add`,l2),H(`sub`,u2),H(`mul`,d2),H(`div`,f2),H(`mod`,p2),H(`equal`,m2),H(`notEqual`,h2),H(`lessThan`,g2),H(`greaterThan`,_2),H(`lessThanEqual`,v2),H(`greaterThanEqual`,y2),H(`and`,b2),H(`or`,x2),H(`not`,S2),H(`xor`,C2),H(`bitAnd`,w2),H(`bitNot`,T2),H(`bitOr`,E2),H(`bitXor`,D2),H(`shiftLeft`,O2),H(`shiftRight`,k2),H(`incrementBefore`,A2),H(`decrementBefore`,j2),H(`increment`,M2),H(`decrement`,N2);const P2=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),p2(e,t)),F2=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),p2(J(e),J(t)));H(`remainder`,P2),H(`modInt`,F2);var Z=class e extends $${static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=u2(1,n);else if(i===e.RECIPROCAL)a=f2(1,n);else if(i===e.DIFFERENCE)a=o4(u2(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=n0(X(i),0):e=n0(X(e),0);let o=d2(e,i).xyz;a=Q2(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===CY&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===CY&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===wY&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.ALL=`all`,Z.ANY=`any`,Z.RADIANS=`radians`,Z.DEGREES=`degrees`,Z.EXP=`exp`,Z.EXP2=`exp2`,Z.LOG=`log`,Z.LOG2=`log2`,Z.SQRT=`sqrt`,Z.INVERSE_SQRT=`inversesqrt`,Z.FLOOR=`floor`,Z.CEIL=`ceil`,Z.NORMALIZE=`normalize`,Z.FRACT=`fract`,Z.SIN=`sin`,Z.COS=`cos`,Z.TAN=`tan`,Z.ASIN=`asin`,Z.ACOS=`acos`,Z.ATAN=`atan`,Z.ABS=`abs`,Z.SIGN=`sign`,Z.LENGTH=`length`,Z.NEGATE=`negate`,Z.ONE_MINUS=`oneMinus`,Z.DFDX=`dFdx`,Z.DFDY=`dFdy`,Z.ROUND=`round`,Z.RECIPROCAL=`reciprocal`,Z.TRUNC=`trunc`,Z.FWIDTH=`fwidth`,Z.TRANSPOSE=`transpose`,Z.BITCAST=`bitcast`,Z.EQUALS=`equals`,Z.MIN=`min`,Z.MAX=`max`,Z.STEP=`step`,Z.REFLECT=`reflect`,Z.DISTANCE=`distance`,Z.DIFFERENCE=`difference`,Z.DOT=`dot`,Z.CROSS=`cross`,Z.POW=`pow`,Z.TRANSFORM_DIRECTION=`transformDirection`,Z.MIX=`mix`,Z.CLAMP=`clamp`,Z.REFRACT=`refract`,Z.SMOOTHSTEP=`smoothstep`,Z.FACEFORWARD=`faceforward`;const I2=q(1e-6),L2=q(1e6),R2=q(Math.PI),z2=q(Math.PI*2),B2=W(Z,Z.ALL).setParameterLength(1),V2=W(Z,Z.ANY).setParameterLength(1),H2=W(Z,Z.RADIANS).setParameterLength(1),U2=W(Z,Z.DEGREES).setParameterLength(1),W2=W(Z,Z.EXP).setParameterLength(1),G2=W(Z,Z.EXP2).setParameterLength(1),K2=W(Z,Z.LOG).setParameterLength(1),q2=W(Z,Z.LOG2).setParameterLength(1),J2=W(Z,Z.SQRT).setParameterLength(1),Y2=W(Z,Z.INVERSE_SQRT).setParameterLength(1),X2=W(Z,Z.FLOOR).setParameterLength(1),Z2=W(Z,Z.CEIL).setParameterLength(1),Q2=W(Z,Z.NORMALIZE).setParameterLength(1),$2=W(Z,Z.FRACT).setParameterLength(1),e4=W(Z,Z.SIN).setParameterLength(1),t4=W(Z,Z.COS).setParameterLength(1),n4=W(Z,Z.TAN).setParameterLength(1),r4=W(Z,Z.ASIN).setParameterLength(1),i4=W(Z,Z.ACOS).setParameterLength(1),a4=W(Z,Z.ATAN).setParameterLength(1,2),o4=W(Z,Z.ABS).setParameterLength(1),s4=W(Z,Z.SIGN).setParameterLength(1),c4=W(Z,Z.LENGTH).setParameterLength(1),l4=W(Z,Z.NEGATE).setParameterLength(1),u4=W(Z,Z.ONE_MINUS).setParameterLength(1),d4=W(Z,Z.DFDX).setParameterLength(1),f4=W(Z,Z.DFDY).setParameterLength(1),p4=W(Z,Z.ROUND).setParameterLength(1),m4=W(Z,Z.RECIPROCAL).setParameterLength(1),h4=W(Z,Z.TRUNC).setParameterLength(1),g4=W(Z,Z.FWIDTH).setParameterLength(1),_4=W(Z,Z.TRANSPOSE).setParameterLength(1),v4=W(Z,Z.BITCAST).setParameterLength(2),y4=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),m2(e,t)),b4=W(Z,Z.MIN).setParameterLength(2,1/0),x4=W(Z,Z.MAX).setParameterLength(2,1/0),S4=W(Z,Z.STEP).setParameterLength(2),C4=W(Z,Z.REFLECT).setParameterLength(2),w4=W(Z,Z.DISTANCE).setParameterLength(2),T4=W(Z,Z.DIFFERENCE).setParameterLength(2),E4=W(Z,Z.DOT).setParameterLength(2),D4=W(Z,Z.CROSS).setParameterLength(2),O4=W(Z,Z.POW).setParameterLength(2),k4=W(Z,Z.POW,2).setParameterLength(1),A4=W(Z,Z.POW,3).setParameterLength(1),j4=W(Z,Z.POW,4).setParameterLength(1),M4=W(Z,Z.TRANSFORM_DIRECTION).setParameterLength(2),N4=e=>d2(s4(e),O4(o4(e),1/3)),P4=e=>E4(e,e),F4=W(Z,Z.MIX).setParameterLength(3),I4=(e,t=0,n=1)=>U(new Z(Z.CLAMP,U(e),U(t),U(n))),L4=e=>I4(e),R4=W(Z,Z.REFRACT).setParameterLength(3),z4=W(Z,Z.SMOOTHSTEP).setParameterLength(3),B4=W(Z,Z.FACEFORWARD).setParameterLength(3),V4=K(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=E4(e.xy,Y(t,n)),a=p2(i,R2);return $2(e4(a).mul(r))}),H4=(e,t,n)=>F4(t,n,e),U4=(e,t,n)=>z4(t,n,e),W4=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),a4(e,t)),G4=B4,K4=Y2;H(`all`,B2),H(`any`,V2),H(`equals`,y4),H(`radians`,H2),H(`degrees`,U2),H(`exp`,W2),H(`exp2`,G2),H(`log`,K2),H(`log2`,q2),H(`sqrt`,J2),H(`inverseSqrt`,Y2),H(`floor`,X2),H(`ceil`,Z2),H(`normalize`,Q2),H(`fract`,$2),H(`sin`,e4),H(`cos`,t4),H(`tan`,n4),H(`asin`,r4),H(`acos`,i4),H(`atan`,a4),H(`abs`,o4),H(`sign`,s4),H(`length`,c4),H(`lengthSq`,P4),H(`negate`,l4),H(`oneMinus`,u4),H(`dFdx`,d4),H(`dFdy`,f4),H(`round`,p4),H(`reciprocal`,m4),H(`trunc`,h4),H(`fwidth`,g4),H(`atan2`,W4),H(`min`,b4),H(`max`,x4),H(`step`,S4),H(`reflect`,C4),H(`distance`,w4),H(`dot`,E4),H(`cross`,D4),H(`pow`,O4),H(`pow2`,k4),H(`pow3`,A4),H(`pow4`,j4),H(`transformDirection`,M4),H(`mix`,H4),H(`clamp`,I4),H(`refract`,R4),H(`smoothstep`,U4),H(`faceForward`,B4),H(`difference`,T4),H(`saturate`,L4),H(`cbrt`,N4),H(`transpose`,_4),H(`rand`,V4);var q4=class extends X${static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?_0(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
411
+
412
+ `+e.tab+`}`),o!==null){e.addFlowCode(` else {
413
+
414
+ `).addFlowTab();let t=o.build(e,n);t&&(c?t=l+` = `+t+`;`:(t=`return `+t+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),t=`// `+t))),e.removeFlowTab().addFlowCode(e.tab+` `+t+`
415
+
416
+ `+e.tab+`}
417
+
418
+ `)}else e.addFlowCode(`
419
+
420
+ `);return e.format(l,n,t)}};const J4=W(q4).setParameterLength(2,3);H(`select`,J4);const Y4=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),J4(...e));H(`cond`,Y4);var X4=class extends X${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){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const Z4=W(X4).setParameterLength(1,2),Q4=(e,t)=>Z4(e,{label:t});H(`context`,Z4),H(`label`,Q4);var $4=class extends X${static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const e3=W($4),t3=(e,t=null)=>e3(e,t).toStack(),n3=(e,t=null)=>e3(e,t,!0).toStack();H(`toVar`,t3),H(`toConst`,n3);const r3=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),e3(e));H(`temp`,r3);var i3=class extends X${static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(B$.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(B$.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,B$.VERTEX);e.flowNodeFromShaderStage(B$.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const a3=W(i3).setParameterLength(1,2),o3=e=>a3(e);H(`toVarying`,a3),H(`toVertexStage`,o3),H(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),a3(...e))),H(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),a3(...e)));const s3=K(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=F4(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),c3=K(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=F4(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),l3=`WorkingColorSpace`,roe=`OutputColorSpace`;var u3=class extends $${static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===l3?fX.workingColorSpace:t===roe?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return fX.enabled===!1||n===r||!n||!r?i:(fX.getTransfer(n)===uY&&(i=n0(s3(i.rgb),i.a)),fX.getPrimaries(n)!==fX.getPrimaries(r)&&(i=n0(s0(fX._getMatrix(new rX,n,r)).mul(i.rgb),i.a)),fX.getTransfer(r)===uY&&(i=n0(c3(i.rgb),i.a)),i)}};const d3=(e,t)=>U(new u3(U(e),l3,t)),f3=(e,t)=>U(new u3(U(e),t,l3)),ioe=(e,t,n)=>U(new u3(U(e),t,n));H(`workingToColorSpace`,d3),H(`colorSpaceToWorking`,f3);let aoe=class extends Z${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var ooe=class extends X${static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=V$.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new aoe(this,U(e)))}setNodeType(e){let t=e2(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){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},soe=class extends ooe{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Z0)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const p3=(e,t,n=null)=>U(new soe(e,t,n));var coe=class extends $${static get type(){return`ToneMappingNode`}constructor(e,t=h3,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return T$(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===jJ)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=n0(i(t.rgb,this.exposureNode),t.a),r}};const m3=(e,t,n)=>U(new coe(e,U(t),U(n))),h3=p3(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>m3(t,n,e));var loe=class extends a1{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=xY,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;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new MQ(n,i),s=new PQ(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=a3(this);i=n.build(e,t)}return i}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 g3=(e,t=null,n=0,r=0)=>U(new loe(e,t,n,r)),_3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setUsage(SY),v3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setInstanced(!0),y3=(e,t=null,n=0,r=0)=>_3(e,t,n,r).setInstanced(!0);H(`toAttribute`,e=>g3(e.value));var uoe=class extends X${static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=V$.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const b3=(e,t,n)=>U(new uoe(U(e),t,n));H(`compute`,b3);var doe=class extends X${static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const x3=(e,t)=>U(new doe(U(e),t)),S3=(e,t)=>e.context({namespace:t});H(`cache`,x3);var foe=class extends X${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){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const C3=W(foe).setParameterLength(2);H(`bypass`,C3);var w3=class extends X${static get type(){return`RemapNode`}constructor(e,t,n,r=q(0),i=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const T3=W(w3,null,null,{doClamp:!1}).setParameterLength(3,5),E3=W(w3).setParameterLength(3,5);H(`remap`,T3),H(`remapClamp`,E3);var poe=class extends X${static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const D3=W(poe).setParameterLength(1,2),O3=e=>(e?J4(e,D3(`discard`)):D3(`discard`)).toStack(),moe=()=>D3(`return`).toStack();H(`discard`,O3);var hoe=class extends $${static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||jJ,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||oY;return n!==jJ&&(t=t.toneMapping(n)),r!==oY&&r!==fX.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const k3=(e,t=null,n=null)=>U(new hoe(U(e),t,n));H(`renderOutput`,k3);var goe=class extends $${static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
421
+ `,a+=e.flow.code.replace(/^\t/gm,``)+`
422
+ `,a+=`/* ... */ `+n+` /* ... */
423
+ `,a+=`// #`+i+`#
424
+ `,t===null?console.log(a):t(e,a),n}};const A3=(e,t=null)=>U(new goe(U(e),t));H(`debug`,A3);function _oe(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var j3=class extends X${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){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=a3(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}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 M3=(e,t=null)=>U(new j3(e,t)),N3=(e=0)=>M3(`uv`+(e>0?e:``),`vec2`);var voe=class extends X${static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const P3=W(voe).setParameterLength(1,2);var yoe=class extends $0{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=V$.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const F3=W(yoe).setParameterLength(1),I3=new SX;var L3=class extends $0{static get type(){return`TextureNode`}constructor(e=I3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=V$.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===GJ?`uvec4`:this.value.type===WJ?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return N3(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=e2(this.value.matrix)),this._matrixUniform.mul(X(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?V$.OBJECT:V$.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,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,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=f3(D3(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getSelf(),U(t)}blur(e){let t=this.clone();t.biasNode=U(e).mul(F3(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===zJ||n.magFilter===zJ)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getSelf(),U(t)}size(e){return P3(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getSelf(),U(t)}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getSelf(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getSelf(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getSelf(),U(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(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const boe=W(L3).setParameterLength(1,4).setName(`texture`),R3=(e=I3,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=boe(e,t,n,r),i},xoe=(e=I3)=>R3(e),z3=(...e)=>R3(...e).setSampler(!1),Soe=e=>(e.isNode===!0?e:R3(e)).convert(`sampler`),Coe=e=>(e.isNode===!0?e:R3(e)).convert(`samplerComparison`);var B3=class extends $0{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const V3=(e,t,n)=>U(new B3(e,t,n));var woe=class extends Z${static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},H3=class extends B3{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?F$(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=V$.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return U(new woe(this,U(e)))}};const U3=(e,t)=>U(new H3(e,t)),Toe=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),U(new H3(e,t)));var Eoe=class extends X${constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const W3=W(Eoe).setParameterLength(1),G3=e2(0,`uint`).label(`u_cameraIndex`).setGroup(Y0(`cameraIndex`)).toVarying(`v_cameraIndex`),K3=e2(`float`).label(`cameraNear`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.near),q3=e2(`float`).label(`cameraFar`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.far),J3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=U3(n).setGroup(Z0).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrix`)}else t=e2(`mat4`).label(`cameraProjectionMatrix`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Doe=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=U3(n).setGroup(Z0).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrixInverse`)}else t=e2(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Y3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=U3(n).setGroup(Z0).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraViewMatrix`)}else t=e2(`mat4`).label(`cameraViewMatrix`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Ooe=e2(`mat4`).label(`cameraWorldMatrix`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.matrixWorld),koe=e2(`mat3`).label(`cameraNormalMatrix`).setGroup(Z0).onRenderUpdate(({camera:e})=>e.normalMatrix),Aoe=e2(new V).label(`cameraPosition`).setGroup(Z0).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),X3=new WX;var Z3=class e extends X${static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=V$.OBJECT,this.uniformNode=new $0(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),X3.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=X3.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Z3.WORLD_MATRIX=`worldMatrix`,Z3.POSITION=`position`,Z3.SCALE=`scale`,Z3.VIEW_POSITION=`viewPosition`,Z3.DIRECTION=`direction`,Z3.RADIUS=`radius`;const joe=W(Z3,Z3.DIRECTION).setParameterLength(1),Moe=W(Z3,Z3.WORLD_MATRIX).setParameterLength(1),Q3=W(Z3,Z3.POSITION).setParameterLength(1),Noe=W(Z3,Z3.SCALE).setParameterLength(1),Poe=W(Z3,Z3.VIEW_POSITION).setParameterLength(1),Foe=W(Z3,Z3.RADIUS).setParameterLength(1);var $3=class extends Z3{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Ioe=G($3,$3.DIRECTION),e6=G($3,$3.WORLD_MATRIX),Loe=G($3,$3.POSITION),Roe=G($3,$3.SCALE),zoe=G($3,$3.VIEW_POSITION),Boe=G($3,$3.RADIUS),t6=e2(new rX).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Voe=e2(new $X).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),n6=K(e=>e.renderer.overrideNodes.modelViewMatrix||r6).once()().toVar(`modelViewMatrix`),r6=Y3.mul(e6),Hoe=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,e2(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),Uoe=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return e2(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),i6=M3(`position`,`vec3`),a6=i6.toVarying(`positionLocal`),o6=i6.toVarying(`positionPrevious`),s6=K(e=>e6.mul(a6).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),c6=K(e=>{let t=a6.transformDirection(e6).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),l6=K(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),u6=l6.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var Woe=class extends X${static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===CY&&n.side===CJ?`false`:e.getFrontFacing()}};const d6=G(Woe),f6=q(d6).mul(2).sub(1),p6=M3(`normal`,`vec3`),m6=K(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),X(0,1,0)):p6,`vec3`).once()().toVar(`normalLocal`),h6=l6.dFdx().cross(l6.dFdy()).normalize().toVar(`normalFlat`),g6=K(e=>{let t;return t=e.material.flatShading===!0?h6:a3(x6(m6),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_6=K(e=>{let t=g6.transformDirection(Y3);return e.material.flatShading!==!0&&(t=a3(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),v6=K(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedNormalView`),y6=v6.transformDirection(Y3).toVar(`transformedNormalWorld`),Goe=K(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),b6=K(([e,t=e6])=>{let n=s0(t),r=e.div(X(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),x6=K(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=t6.mul(e);return Y3.transformDirection(r)}),S6=new lZ,C6=new $X,w6=e2(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Koe=e2(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),T6=e2(new $X).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(S6.copy(n),C6.makeRotationFromEuler(S6)):C6.identity(),C6}),E6=u6.negate().reflect(v6),D6=u6.negate().refract(v6,w6),O6=E6.transformDirection(Y3).toVar(`reflectVector`),k6=D6.transformDirection(Y3).toVar(`reflectVector`),A6=new jQ;var qoe=class extends L3{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===NJ?O6:e.mapping===PJ?k6:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),X(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===wY||!n.isRenderTargetTexture)&&(t=X(t.x.negate(),t.yz)),T6.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const j6=W(qoe).setParameterLength(1,4).setName(`cubeTexture`),M6=(e=A6,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=j6(e,t,n,r),i},Joe=(e=A6)=>j6(e);var Yoe=class extends Z${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},N6=class extends X${static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=V$.OBJECT}element(e){return U(new Yoe(this,U(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?U3(null,e):e===`texture`?R3(null):e===`cubeTexture`?M6(null):e2(null,e):V3(null,e,this.count),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){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const P6=(e,t,n)=>U(new N6(e,t,n)),F6=(e,t,n,r)=>U(new N6(e,t,r,n));var Xoe=class extends N6{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const I6=(e,t,n=null)=>U(new Xoe(e,t,n)),L6=K(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),M3(`tangent`,`vec4`)))(),R6=L6.xyz.toVar(`tangentLocal`),z6=n6.mul(n0(R6,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),B6=z6.transformDirection(Y3).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),V6=z6.toVar(`transformedTangentView`),Zoe=V6.transformDirection(Y3).normalize().toVar(`transformedTangentWorld`),H6=K(([e,t],n)=>{let r=e.mul(L6.w).xyz;return n.material.flatShading!==!0&&(r=a3(r,t)),r}).once(),Qoe=H6(p6.cross(L6),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),$oe=H6(m6.cross(R6),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),U6=H6(g6.cross(z6),`v_bitangentView`).normalize().toVar(`bitangentView`),ese=H6(_6.cross(B6),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),W6=H6(v6.cross(V6),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),tse=W6.transformDirection(Y3).normalize().toVar(`transformedBitangentWorld`),G6=s0(z6,U6,g6),K6=u6.mul(G6),nse=(e,t)=>e.sub(K6.mul(t)),rse=(()=>{let e=N0.cross(u6);return e=e.cross(N0).normalize(),e=F4(e,v6,j0.mul(x0.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),ise=K(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=f6.mul(m.inverseSqrt());return l2(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var ase=class extends $${static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=iY}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=X(r.xy.mul(n),r.z));let i=null;if(t===aY)i=x6(r);else if(t===iY){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?G6.mul(r).normalize():ise({eye_pos:l6,surf_norm:g6,mapN:r,uv:N3()})}return i}};const q6=W(ase).setParameterLength(1,2),ose=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||N3()),forceUVContext:!0}),r=q(n(e=>e));return Y(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),sse=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(f6),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var cse=class extends $${static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=ose({textureNode:this.textureNode,bumpScale:e});return sse({surf_pos:l6,surf_norm:g6,dHdxy:t})}};const J6=W(cse).setParameterLength(1,2),Y6=new Map;var Q=class e extends X${static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Y6.get(e);return n===void 0&&(n=I6(e,t),Y6.set(e,n)),n}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(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?X():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=q6(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?J6(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):g6;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?q6(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):g6;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=o0(r8.x,r8.y,r8.y.negate(),r8.x);i=t.mul(e.rg.mul(2).sub(Y(1)).normalize().mul(e.b))}else i=r8;else if(r===e.IRIDESCENCE_THICKNESS){let e=P6(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=P6(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;const X6=G(Q,Q.ALPHA_TEST),Z6=G(Q,Q.COLOR),lse=G(Q,Q.SHININESS),Q6=G(Q,Q.EMISSIVE),$6=G(Q,Q.OPACITY),use=G(Q,Q.SPECULAR),dse=G(Q,Q.SPECULAR_INTENSITY),fse=G(Q,Q.SPECULAR_COLOR),pse=G(Q,Q.SPECULAR_STRENGTH),mse=G(Q,Q.REFLECTIVITY),hse=G(Q,Q.ROUGHNESS),gse=G(Q,Q.METALNESS),e8=G(Q,Q.NORMAL),_se=G(Q,Q.CLEARCOAT),vse=G(Q,Q.CLEARCOAT_ROUGHNESS),yse=G(Q,Q.CLEARCOAT_NORMAL),bse=G(Q,Q.ROTATION),xse=G(Q,Q.SHEEN),Sse=G(Q,Q.SHEEN_ROUGHNESS),Cse=G(Q,Q.ANISOTROPY),wse=G(Q,Q.IRIDESCENCE),Tse=G(Q,Q.IRIDESCENCE_IOR),Ese=G(Q,Q.IRIDESCENCE_THICKNESS),Dse=G(Q,Q.TRANSMISSION),Ose=G(Q,Q.THICKNESS),kse=G(Q,Q.IOR),Ase=G(Q,Q.ATTENUATION_DISTANCE),jse=G(Q,Q.ATTENUATION_COLOR),Mse=G(Q,Q.LINE_SCALE),Nse=G(Q,Q.LINE_DASH_SIZE),Pse=G(Q,Q.LINE_GAP_SIZE),Fse=G(Q,Q.LINE_WIDTH),Ise=G(Q,Q.LINE_DASH_OFFSET),Lse=G(Q,Q.POINT_SIZE),Rse=G(Q,Q.DISPERSION),t8=G(Q,Q.LIGHT_MAP),n8=G(Q,Q.AO),r8=e2(new $Y).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),i8=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var a8=class e extends X${static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=a3(this);a=e.build(t,n)}return a}};a8.VERTEX=`vertex`,a8.INSTANCE=`instance`,a8.SUBGROUP=`subgroup`,a8.INVOCATION_LOCAL=`invocationLocal`,a8.INVOCATION_SUBGROUP=`invocationSubgroup`,a8.DRAW=`draw`;const o8=G(a8,a8.VERTEX),s8=G(a8,a8.INSTANCE),zse=G(a8,a8.SUBGROUP),Bse=G(a8,a8.INVOCATION_SUBGROUP),Vse=G(a8,a8.INVOCATION_LOCAL),c8=G(a8,a8.DRAW);var l8=class extends X${static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=V$.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=V3(n.array,`mat4`,Math.max(t,1)).element(s8);else{let e=new v$(n.array,16,1);this.buffer=e;let t=n.usage===SY?y3:v3,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=c0(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new FQ(r.array,3),t=r.usage===SY?y3:v3;this.bufferColor=e,a=X(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(a6).xyz;if(a6.assign(o),e.hasGeometryAttribute(`normal`)){let e=b6(m6,i);m6.assign(e)}this.instanceColorNode!==null&&v0(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==SY&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==SY&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const Hse=W(l8).setParameterLength(2,3);var Use=class extends l8{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const u8=W(Use).setParameterLength(1);var Wse=class extends X${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=s8:this.batchingIdNode=c8);let t=K(([e])=>{let t=J(P3(z3(this.batchMesh._indirectTexture),0).x),n=J(e).mod(t),r=J(e).div(t);return z3(this.batchMesh._indirectTexture,X1(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(J(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=J(P3(z3(r),0).x),a=q(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=c0(z3(r,X1(o,s)),z3(r,X1(o.add(1),s)),z3(r,X1(o.add(2),s)),z3(r,X1(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=K(([e])=>{let t=J(P3(z3(l),0).x),n=e,r=n.mod(t),i=n.div(t);return z3(l,X1(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);v0(`vec3`,`vBatchColor`).assign(t)}let u=s0(c);a6.assign(c.mul(a6));let d=m6.div(X(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;m6.assign(f),e.hasGeometryAttribute(`tangent`)&&R6.mulAssign(u)}};const d8=W(Wse).setParameterLength(1);var Gse=class extends Z${static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const Kse=W(Gse).setParameterLength(2);var qse=class extends B3{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=A$(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=U$.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return Kse(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(U$.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=g3(this.value),this._varying=a3(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const f8=(e,t=null,n=0)=>U(new qse(e,t,n)),Jse=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),f8(e,t,n).setPBO(!0)),p8=new WeakMap;var m8=class extends X${static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=V$.OBJECT,this.skinIndexNode=M3(`skinIndex`,`uvec4`),this.skinWeightNode=M3(`skinWeight`,`vec4`),this.bindMatrixNode=P6(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=P6(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=F6(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=a6,this.toPositionNode=a6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=l2(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=m6){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=l2(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=F6(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,o6)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||L$(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&o6.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();m6.assign(t),e.hasGeometryAttribute(`tangent`)&&R6.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;p8.get(t)!==e.frameId&&(p8.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const h8=e=>U(new m8(e)),Yse=(e,t=null)=>{let n=new m8(e);return n.positionNode=f8(new FQ(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinIndexNode=f8(new FQ(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinWeightNode=f8(new FQ(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.bindMatrixNode=e2(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=e2(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=V3(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,U(n)};var Xse=class extends X${static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=D3(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=K(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
425
+ `:``)+e.tab+f+` {
426
+
427
+ `).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
428
+ `+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
429
+
430
+ `).removeFlowTab();return e.addFlowTab(),a}};const g8=(...e)=>U(new Xse(B1(e,`int`))).toStack(),Zse=()=>D3(`continue`).toStack(),_8=()=>D3(`break`).toStack(),Qse=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),g8(...e)),v8=new WeakMap,y8=new CX,b8=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=J(o8).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=z3(e,X1(c,s)).depth(i).xyz;return l.mul(t)});function $se(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=v8.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new TX(p,u,d,a);m.type=KJ,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(y8.fromBufferAttribute(a,e),p[f+i+0]=y8.x,p[f+i+1]=y8.y,p[f+i+2]=y8.z,p[f+i+3]=0),n===!0&&(y8.fromBufferAttribute(o,e),p[f+i+4]=y8.x,p[f+i+5]=y8.y,p[f+i+6]=y8.z,p[f+i+7]=0),r===!0&&(y8.fromBufferAttribute(l,e),p[f+i+8]=y8.x,p[f+i+9]=y8.y,p[f+i+10]=y8.z,p[f+i+11]=l.itemSize===4?y8.w:1)}}o={count:a,texture:m,stride:l,size:new $Y(u,d)},v8.set(e,o);function g(){m.dispose(),v8.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var ece=class extends X${static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=e2(1),this.updateType=V$.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=$se(t);n===!0&&a6.mulAssign(this.morphBaseInfluence),r===!0&&m6.mulAssign(this.morphBaseInfluence);let l=J(c.width);g8(a,({i:e})=>{let t=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(z3(this.mesh.morphTexture,X1(J(e).add(1),J(s8))).r):t.assign(P6(`morphTargetInfluences`,`float`).element(e).toVar()),W1(t.notEqual(0),()=>{n===!0&&a6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(0)})),r===!0&&m6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const x8=W(ece).setParameterLength(1);var S8=class extends X${static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},tce=class extends S8{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},nce=class extends X4{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=X().toVar(`directDiffuse`),r=X().toVar(`directSpecular`),i=X().toVar(`indirectDiffuse`),a=X().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:X().toVar(`radiance`),irradiance:X().toVar(`irradiance`),iblIrradiance:X().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const C8=W(nce);var rce=class extends S8{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let w8,T8;var E8=class e extends X${static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=V$.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=V$.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(T8),T8.multiplyScalar(t.getPixelRatio())):T8.copy(n.viewport):n===null?t.getDrawingBufferSize(w8):(w8.width=n.width,w8.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?e2(w8||=new $Y):t===e.VIEWPORT?e2(T8||=new CX):Y(k8.div(O8)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(O8).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};E8.COORDINATE=`coordinate`,E8.VIEWPORT=`viewport`,E8.SIZE=`size`,E8.UV=`uv`;const D8=G(E8,E8.UV),O8=G(E8,E8.SIZE),k8=G(E8,E8.COORDINATE),A8=G(E8,E8.VIEWPORT),j8=A8.zw,M8=k8.sub(A8.xy),ice=M8.div(j8),ace=K(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),O8),`vec2`).once()(),oce=K(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),D8),`vec2`).once()(),sce=K(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),D8.flipY()),`vec2`).once()(),N8=new $Y;var P8=class extends L3{static get type(){return`ViewportTextureNode`}constructor(e=D8,t=null,n=null){n===null&&(n=new BQ,n.minFilter=VJ),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=V$.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(N8);let n=this.value;(n.image.width!==N8.width||n.image.height!==N8.height)&&(n.image.width=N8.width,n.image.height=N8.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const cce=W(P8).setParameterLength(0,3),lce=W(P8,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let F8=null;var uce=class extends P8{static get type(){return`ViewportDepthTextureNode`}constructor(e=D8,t=null){F8===null&&(F8=new VQ),super(e,t,F8)}};const I8=W(uce).setParameterLength(0,2);var L8=class e extends X${static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=H8().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?z8(l6.z,K3,q3):R8(l6.z,K3,q3);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=B8(r,K3,q3);i=R8(e,K3,q3)}else i=r;else i=R8(l6.z,K3,q3);return i}};L8.DEPTH_BASE=`depthBase`,L8.DEPTH=`depth`,L8.LINEAR_DEPTH=`linearDepth`;const R8=(e,t,n)=>e.add(t).div(t.sub(n)),dce=(e,t,n)=>t.sub(n).mul(e).sub(t),z8=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),B8=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),V8=(e,t,n)=>{t=t.max(1e-6).toVar();let r=q2(e.negate().div(t)),i=q2(n.div(t));return r.div(i)},fce=(e,t,n)=>{let r=e.mul(K2(n.div(t)));return q(Math.E).pow(r).mul(t).negate()},H8=W(L8,L8.DEPTH_BASE),U8=G(L8,L8.DEPTH),W8=W(L8,L8.LINEAR_DEPTH).setParameterLength(0,1),pce=W8(I8());U8.assign=e=>H8(e);var G8=class e extends X${static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=U3(t);g8(a,({i:t})=>{let a=e.element(t);n.assign(l6.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(z4(r.negate(),r,n))})}let o=e.length;if(o>0){let t=U3(e),a=q(1).toVar(`intersectionClipOpacity`);g8(o,({i:e})=>{let i=t.element(e);n.assign(l6.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(z4(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}y0.a.mulAssign(i),y0.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=U3(t);g8(n,({i:t})=>{let n=e.element(t);l6.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=U3(e),n=Y1(!0).toVar(`clipped`);g8(r,({i:e})=>{let r=t.element(e);n.assign(l6.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=U3(e),i=W3(t.getClipDistance());g8(n,({i:e})=>{let t=r.element(e),n=l6.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};G8.ALPHA_TO_COVERAGE=`alphaToCoverage`,G8.DEFAULT=`default`,G8.HARDWARE=`hardware`;const mce=()=>U(new G8),hce=()=>U(new G8(G8.ALPHA_TO_COVERAGE)),gce=()=>U(new G8(G8.HARDWARE)),_ce=.05,K8=K(([e])=>$2(d2(1e4,e4(d2(17,e.x).add(d2(.1,e.y)))).mul(l2(.1,o4(e4(d2(13,e.y).add(e.x))))))),q8=K(([e])=>K8(Y(K8(e.xy),e.z))),vce=K(([e])=>{let t=x4(c4(d4(e.xyz)),c4(f4(e.xyz))),n=q(1).div(q(_ce).mul(t)).toVar(`pixScale`),r=Y(G2(X2(q2(n))),G2(Z2(q2(n)))),i=Y(q8(X2(r.x.mul(e.xyz))),q8(X2(r.y.mul(e.xyz)))),a=$2(q2(n)),o=l2(d2(a.oneMinus(),i.x),d2(a,i.y)),s=b4(a,a.oneMinus()),c=X(o.mul(o).div(d2(2,s).mul(u2(1,s))),o.sub(d2(.5,s)).div(u2(1,s)),u2(1,u2(1,o).mul(u2(1,o)).div(d2(2,s).mul(u2(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return I4(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var yce=class extends j3{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new CX(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const J8=(e=0)=>U(new yce(e));var Y8=class extends JZ{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+E$(this)}build(e){this.setup(e)}setupObserver(e){return new x$(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=n0(r,y0.a).max(0);a=this.setupOutput(e,i),L0.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&L0.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=n0(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=hce():e.stack.add(mce())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(gce()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?V8(l6.z,K3,q3):R8(l6.z,K3,q3))}r!==null&&U8.assign(r).toStack()}setupPositionView(){return n6.mul(a6).xyz}setupModelViewProjection(){return J3.mul(l6)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),i8}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&x8(t).toStack(),t.isSkinnedMesh===!0&&h8(t).toStack(),this.displacementMap){let e=I6(`displacementMap`,`texture`),t=I6(`displacementScale`,`float`),n=I6(`displacementBias`,`float`);a6.addAssign(m6.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&d8(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&u8(t).toStack(),this.positionNode!==null&&a6.assign(S3(this.positionNode,`POSITION`)),a6}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Y1(this.maskNode).not().discard();let n=this.colorNode?n0(this.colorNode):Z6;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(J8())),e.instanceColor){let e=v0(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=v0(`vec3`,`vBatchColor`);n=e.mul(n)}y0.assign(n);let r=this.opacityNode?q(this.opacityNode):$6;y0.a.assign(y0.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?X6:q(this.alphaTestNode),y0.a.lessThanEqual(i).discard()),this.alphaHash===!0&&y0.a.lessThan(vce(a6)).discard();let a=this.transparent===!1&&this.blending===TJ&&this.alphaToCoverage===!1;a?y0.a.assign(1):i===null&&y0.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?X(0):y0.rgb}setupNormal(){return this.normalNode?X(this.normalNode):e8}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?I6(`envMap`,`cubeTexture`):I6(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new rce(t8)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?n8:this.aoNode;t.push(new tce(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=C8(o,t,n,r)}else n!==null&&(s=X(r===null?n:F4(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(b0.assign(X(i||Q6)),s=s.add(b0)),s}setupFog(e,t){let n=e.fogNode;return n&&(L0.assign(t),t=n0(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=JZ.prototype.toJSON.call(this,e),r=D$(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}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.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};let X8=null;var bce=class extends P8{static get type(){return`ViewportSharedTextureNode`}constructor(e=D8,t=null){X8===null&&(X8=new BQ),super(e,t,X8)}updateReference(){return this}};const xce=W(bce).setParameterLength(0,2),Sce=e=>U(e).mul(.5).add(.5),Cce=e=>U(e).mul(2).sub(1);var wce=class extends $${static get type(){return`EquirectUVNode`}constructor(e=c6){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,n)}};const Z8=W(wce).setParameterLength(0,1),Q8=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Tce=K(e=>e.diffuseColor.mul(1/Math.PI)),$8=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=g6.dFdx().abs().max(g6.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),Ece=K(e=>{let{roughness:t}=e,n=$8(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),e5=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return f2(.5,i.add(a).max(I2))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Dce=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(X(e.mul(n),t.mul(r),o).length()),l=o.mul(X(e.mul(i),t.mul(a),s).length()),u=f2(.5,c.add(l));return u.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`}]}),t5=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Oce=q(1/Math.PI),kce=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=X(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Oce.mul(a.mul(c.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`}]}),Ace=K(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||v6,l=i.pow2(),u=t.add(u6).normalize(),d=c.dot(t).clamp(),f=c.dot(u6).clamp(),p=c.dot(u).clamp(),m=u6.dot(u).clamp(),h=Q8({f0:n,f90:r,dotVH:m}),g,_;if(I1(o)&&(h=D0.mix(h,a)),I1(s)){let e=M0.dot(t),n=M0.dot(u6),r=M0.dot(u),i=N0.dot(t),a=N0.dot(u6),o=N0.dot(u);g=Dce({alphaT:A0,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=kce({alphaT:A0,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=e5({alpha:l,dotNL:d,dotNV:f}),_=t5({alpha:l,dotNH:p});return h.mul(g).mul(_)}),jce=K(({roughness:e,dotNV:t})=>{let n=n0(-1,-.0275,-.572,.022),r=n0(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=Y(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Mce=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(X(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),n5=1/6,r5=e=>d2(n5,d2(e,d2(e,e.negate().add(3)).sub(3)).add(1)),i5=e=>d2(n5,d2(e,d2(e,d2(3,e).sub(6))).add(4)),a5=e=>d2(n5,d2(e,d2(e,d2(-3,e).add(3)).add(3)).add(1)),o5=e=>d2(n5,O4(e,3)),s5=e=>r5(e).add(i5(e)),c5=e=>a5(e).add(o5(e)),l5=e=>l2(-1,i5(e).div(r5(e).add(i5(e)))),u5=e=>l2(1,o5(e).div(a5(e).add(o5(e)))),d5=(e,t,n)=>{let r=e.uvNode,i=d2(r,t.zw).add(.5),a=X2(i),o=$2(i),s=s5(o.x),c=c5(o.x),l=l5(o.x),u=u5(o.x),d=l5(o.y),f=u5(o.y),p=Y(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=Y(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=Y(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=Y(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=s5(o.y).mul(l2(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=c5(o.y).mul(l2(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Nce=K(([e,t=q(3)])=>{let n=Y(e.size(J(t))),r=Y(e.size(J(t.add(1)))),i=f2(1,n),a=f2(1,r),o=d5(e,n0(i,n),X2(t)),s=d5(e,n0(a,r),Z2(t));return $2(t).mix(o,s)}),Pce=X(.04),Fce=q(1),f5=q(1),p5=q(-2),m5=q(.8),h5=q(-1),g5=q(.4),_5=q(2),v5=q(.305),y5=q(3),b5=q(.21),Ice=q(4),x5=q(4),Lce=q(16),Rce=K(([e])=>{let t=X(o4(e)).toVar(),n=q(-1).toVar();return W1(t.x.greaterThan(t.z),()=>{W1(t.x.greaterThan(t.y),()=>{n.assign(J4(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(J4(e.y.greaterThan(0),1,4))})}).Else(()=>{W1(t.z.greaterThan(t.y),()=>{n.assign(J4(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(J4(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),zce=K(([e,t])=>{let n=Y().toVar();return W1(t.equal(0),()=>{n.assign(Y(e.z,e.y).div(o4(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(Y(e.x.negate(),e.z.negate()).div(o4(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(Y(e.x.negate(),e.y).div(o4(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(Y(e.z.negate(),e.y).div(o4(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(Y(e.x.negate(),e.z).div(o4(e.y)))}).Else(()=>{n.assign(Y(e.x,e.y).div(o4(e.z)))}),d2(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),Bce=K(([e])=>{let t=q(0).toVar();return W1(e.greaterThanEqual(m5),()=>{t.assign(f5.sub(e).mul(h5.sub(p5)).div(f5.sub(m5)).add(p5))}).ElseIf(e.greaterThanEqual(g5),()=>{t.assign(m5.sub(e).mul(_5.sub(h5)).div(m5.sub(g5)).add(h5))}).ElseIf(e.greaterThanEqual(v5),()=>{t.assign(g5.sub(e).mul(y5.sub(_5)).div(g5.sub(v5)).add(_5))}).ElseIf(e.greaterThanEqual(b5),()=>{t.assign(v5.sub(e).mul(Ice.sub(y5)).div(v5.sub(b5)).add(y5))}).Else(()=>{t.assign(q(-2).mul(q2(d2(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),S5=K(([e,t])=>{let n=e.toVar();n.assign(d2(2,n).sub(1));let r=X(n,1).toVar();return W1(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),C5=K(([e,t,n,r,i,a])=>{let o=q(n),s=X(t),c=I4(Bce(o),p5,a),l=$2(c),u=X2(c),d=X(w5(e,s,u,r,i,a)).toVar();return W1(l.notEqual(0),()=>{let t=X(w5(e,s,u.add(1),r,i,a)).toVar();d.assign(F4(d,t,l))}),d}),w5=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=X(t),c=q(Rce(s)).toVar(),l=q(x4(x5.sub(o),0)).toVar();o.assign(x4(o,x5));let u=q(G2(o)).toVar(),d=Y(zce(s,c).mul(u.sub(2)).add(1)).toVar();return W1(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(d2(3,Lce))),d.y.addAssign(d2(4,G2(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(Y(),Y())}),T5=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=t4(r),l=n.mul(c).add(i.cross(n).mul(e4(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return w5(e,l,t,a,o,s)}),E5=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=X(J4(t,n,D4(n,r))).toVar();W1(f.equal(X(0)),()=>{f.assign(X(r.z,0,r.x.negate()))}),f.assign(Q2(f));let p=X().toVar();return p.addAssign(i.element(0).mul(T5({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),g8({start:J(1),end:e},({i:e})=>{W1(e.greaterThanEqual(a),()=>{_8()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(T5({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(T5({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),n0(p,1)}),D5=4,O5=[.125,.215,.35,.446,.526,.582],k5=20,A5=new a$(-1,1,1,-1,0,1),Vce=new AQ(90,1),j5=new GZ;let M5=null,N5=0,P5=0;const F5=(1+Math.sqrt(5))/2,I5=1/F5,L5=[new V(-F5,I5,0),new V(F5,I5,0),new V(-I5,0,F5),new V(I5,0,F5),new V(0,F5,-I5),new V(0,F5,I5),new V(-1,1,-1),new V(1,1,-1),new V(-1,1,1),new V(1,1,1)],Hce=new V,R5=new WeakMap,Uce=[3,1,5,0,4,2],z5=S5(N3(),M3(`faceIndex`)).normalize(),B5=X(z5.x,z5.y,z5.z);var Wce=class{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}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=Hce,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=W5(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G5(),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())}_setSizeFromTexture(e){e.mapping===NJ||e.mapping===PJ?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=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(M5,N5,P5),e.scissorTest=!1,H5(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=V5(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V5(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=Gce(t)),this._blurMaterial=Kce(t,e.width,e.height)}}async _compileMaterial(e){let t=new SQ(this._lodPlanes[0],e);await this._renderer.compile(t,A5)}_sceneToCubeUV(e,t,n,r,i){let a=Vce;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(j5),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new YZ({name:`PMREM.Background`,side:CJ,depthWrite:!1,depthTest:!1});u=new SQ(new TQ,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(j5),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;H5(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===NJ||e.mapping===PJ;r?this._cubemapMaterial===null&&(this._cubemapMaterial=W5(e)):this._equirectMaterial===null&&(this._equirectMaterial=G5(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;H5(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,A5)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=L5[(r-t-1)%L5.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=R5.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*k5-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):k5;h>k5&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${k5}`);let g=[],_=0;for(let e=0;e<k5;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-D5?r-v+D5:0),x=4*(this._cubeSize-y);H5(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,A5)}};function Gce(e){let t=[],n=[],r=[],i=[],a=e,o=e-D5+1+O5.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-D5?c=O5[s-e+D5-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=Uce[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new uQ;x.setAttribute(`position`,new $Z(v,h)),x.setAttribute(`uv`,new $Z(y,g)),x.setAttribute(`faceIndex`,new $Z(b,_)),t.push(x),i.push(new SQ(x,null)),a>D5&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function V5(e,t){let n={magFilter:BJ,minFilter:BJ,generateMipmaps:!1,type:qJ,format:JJ,colorSpace:cY},r=new wX(e,t,n);return r.texture.mapping=FJ,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function H5(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function U5(e){let t=new Y8;return t.depthTest=!1,t.depthWrite=!1,t.blending=wJ,t.name=`PMREM_${e}`,t}function Kce(e,t,n){let r=U3(Array(k5).fill(0)),i=e2(new V(0,1,0)),a=e2(0),o=q(k5),s=e2(0),c=e2(1),l=R3(null),u=e2(0),d=q(1/t),f=q(1/n),p=q(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:B5,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=U5(`blur`);return h.fragmentNode=E5({...m,latitudinal:s.equal(1)}),R5.set(h,m),h}function W5(e){let t=U5(`cubemap`);return t.fragmentNode=M6(e,B5),t}function G5(e){let t=U5(`equirect`);return t.fragmentNode=R3(e,Z8(B5),0),t}const K5=new WeakMap;function qce(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function Jce(e,t,n){let r=Yce(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(Zce(t))i=n.fromCubemap(e,i);else return null;else if(Qce(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function Yce(e){let t=K5.get(e);return t===void 0&&(t=new WeakMap,K5.set(e,t)),t}var Xce=class extends $${static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new SX;r.isRenderTargetTexture=!0,this._texture=R3(r),this._width=e2(0),this._height=e2(0),this._maxMip=e2(0),this.updateBeforeType=V$.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=qce(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:Jce(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new Wce(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=T6.mul(X(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),C5(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function Zce(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function Qce(e){return e==null?!1:e.height>0}const $ce=W(Xce).setParameterLength(1,3);var ele=class extends $${static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=X(u6.z,0,u6.x.negate()).normalize(),t=u6.cross(e);return Y(e.dot(v6),t.dot(v6)).mul(.495).add(.5)}};const tle=G(ele);var nle=class extends $${static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=o0(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=c0(n0(1,0,0,0),n0(0,t4(e.x),e4(e.x).negate(),0),n0(0,e4(e.x),t4(e.x),0),n0(0,0,0,1)),i=c0(n0(t4(e.y),0,e4(e.y),0),n0(0,1,0,0),n0(e4(e.y).negate(),0,t4(e.y),0),n0(0,0,0,1)),a=c0(n0(t4(e.z),e4(e.z).negate(),0,0),n0(e4(e.z),t4(e.z),0,0),n0(0,0,1,0),n0(0,0,0,1));return r.mul(i).mul(a).mul(n0(n,1)).xyz}}};const q5=W(nle).setParameterLength(2),rle=_0(`vec3`),ile=_0(`vec3`),ale=_0(`vec3`);var ole=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},sle=class extends g0{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const cle=(e,t)=>U(new sle(e,t));var lle=class extends X${static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new R1(t);return this._currentCond=J4(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new R1(t),r=J4(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new R1(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(U(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new R1(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=J4(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=U1();H1(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return H1(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const ule=W(lle).setParameterLength(0,1);function dle(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var fle=class extends X${static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=dle(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=N$(i)*t,o=P$(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},ple=class extends X${static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const mle=(e,t=null)=>{let n=new fle(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return U(new ple(n,r))};return r.layout=n,r.isStruct=!0,r};var J5=class extends X${static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const hle=W(J5);function Y5(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var gle=class extends J5{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){let t={...this.outputNodes,...e.outputNodes};return X5(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=Y5(i,e);r[n]=n0(t[e])}return this.members=r,super.setup(e)}};const X5=W(gle),_le=K(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),Z5=(e,t)=>O4(d2(4,e.mul(u2(1,e))),t),vle=(e,t)=>e.lessThan(.5)?Z5(e.mul(2),t).div(2):u2(1,Z5(d2(u2(1,e),2),t).div(2)),yle=(e,t,n)=>O4(f2(O4(e,t),l2(O4(e,t),O4(u2(1,e),n))),1/t),ble=(e,t)=>e4(R2.mul(t.mul(e).sub(1))).div(R2.mul(t.mul(e).sub(1))),Q5=K(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),xle=K(([e])=>X(Q5(e.z.add(Q5(e.y.mul(1)))),Q5(e.z.add(Q5(e.x.mul(1)))),Q5(e.y.add(Q5(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Sle=K(([e,t,n])=>{let r=X(e).toVar(),i=q(1.4).toVar(),a=q(0).toVar(),o=X(r).toVar();return g8({start:q(0),end:q(3),type:`float`,condition:`<=`},()=>{let e=X(xle(o.mul(2))).toVar();r.addAssign(e.add(n.mul(q(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=q(Q5(r.z.add(Q5(r.x.add(Q5(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Cle=class extends X${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){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const wle=W(Cle),$5=e=>(...t)=>wle(e,...t),e7=e2(0).setGroup(Z0).onRenderUpdate(e=>e.time),t7=e2(0).setGroup(Z0).onRenderUpdate(e=>e.deltaTime),Tle=e2(0,`uint`).setGroup(Z0).onRenderUpdate(e=>e.frameId),Ele=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),e7.mul(e)),Dle=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),e7.mul(e)),Ole=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),t7.mul(e)),kle=(e=e7)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Ale=(e=e7)=>e.fract().round(),jle=(e=e7)=>e.add(.5).fract().mul(2).sub(1).abs(),Mle=(e=e7)=>e.fract(),Nle=K(([e,t,n=Y(.5)])=>q5(e.sub(n),t).add(n)),Ple=K(([e,t,n=Y(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),Fle=K(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=e6:(r=e6.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Y3.mul(r);return I1(t)&&(i[0][0]=e6[0].length(),i[0][1]=0,i[0][2]=0),I1(n)&&(i[1][0]=0,i[1][1]=e6[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,J3.mul(i).mul(a6)}),Ile=K(([e=null])=>{let t=W8(),n=W8(I8(e)).sub(t),r=n.lessThan(0).select(D8,e);return r});var Lle=class extends X${static get type(){return`SpriteSheetUVNode`}constructor(e,t=N3(),n=q(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=Y(o,s);return t.add(l).mul(c)}};const Rle=W(Lle).setParameterLength(3);var zle=class extends X${static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=q(1),i=a6,a=m6){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(X(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=R3(u,s).mul(o.x),m=R3(d,c).mul(o.y),h=R3(f,l).mul(o.z);return l2(p,m,h)}};const n7=W(zle).setParameterLength(1,6),Ble=(...e)=>n7(...e),r7=new zQ,i7=new V,a7=new V,o7=new V,s7=new $X,c7=new V(0,0,-1),l7=new CX,u7=new V,d7=new V,f7=new CX,p7=new $Y,m7=new wX,Vle=D8.flipX();m7.depthTexture=new VQ(1,1);let h7=!1;var Hle=class e extends L3{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||m7.texture,Vle),this._reflectorBaseNode=e.reflector||new Ule(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=U(new e({defaultTexture:m7.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},Ule=class extends X${static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new EZ,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?V$.RENDER:V$.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(p7),e.setSize(Math.round(p7.width*n),Math.round(p7.height*n))}setup(e){return this._updateResolution(m7,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}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 wX(0,0,{type:qJ}),this.generateMipmaps===!0&&(t.texture.minFilter=HJ,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new VQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&h7)return!1;h7=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(p7),this._updateResolution(s,r),a7.setFromMatrixPosition(a.matrixWorld),o7.setFromMatrixPosition(n.matrixWorld),s7.extractRotation(a.matrixWorld),i7.set(0,0,1),i7.applyMatrix4(s7),u7.subVectors(a7,o7);let c=u7.dot(i7)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){h7=!1;return}l=!0}u7.reflect(i7).negate(),u7.add(a7),s7.extractRotation(n.matrixWorld),c7.set(0,0,-1),c7.applyMatrix4(s7),c7.add(o7),d7.subVectors(a7,c7),d7.reflect(i7).negate(),d7.add(a7),o.coordinateSystem=n.coordinateSystem,o.position.copy(u7),o.up.set(0,1,0),o.up.applyMatrix4(s7),o.up.reflect(i7),o.lookAt(d7),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),r7.setFromNormalAndCoplanarPoint(i7,a7),r7.applyMatrix4(o.matrixWorldInverse),l7.set(r7.normal.x,r7.normal.y,r7.normal.z,r7.constant);let u=o.projectionMatrix;f7.x=(Math.sign(l7.x)+u.elements[8])/u.elements[0],f7.y=(Math.sign(l7.y)+u.elements[9])/u.elements[5],f7.z=-1,f7.w=(1+u.elements[10])/u.elements[14],l7.multiplyScalar(1/l7.dot(f7));let d=0;u.elements[2]=l7.x,u.elements[6]=l7.y,u.elements[10]=r.coordinateSystem===wY?l7.z-d:l7.z+1-d,u.elements[14]=l7.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,h7=!1,this.forceUpdate=!1}};const Wle=e=>U(new Hle(e)),g7=new a$(-1,1,1,-1,0,1);var Gle=class extends uQ{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new nQ([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new nQ(t,2))}};const Kle=new Gle;var _7=class extends SQ{constructor(e=null){super(Kle,e),this.camera=g7,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,g7)}render(e){e.render(this,g7)}};const qle=new $Y;var Jle=class extends L3{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:qJ}){let i=new wX(t,n,r);super(i.texture,N3()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _7(new Y8),this.updateBeforeType=V$.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;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,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();let t=e.getSize(qle);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new L3(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const v7=(e,...t)=>U(new Jle(U(e),...t)),Yle=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():v7(e,...t),y7=K(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===wY?(e=Y(e.x,e.y.oneMinus()).mul(2).sub(1),i=n0(X(e,t),1)):i=n0(X(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=n0(n.mul(i));return a.xyz.div(a.w)}),Xle=K(([e,t])=>{let n=t.mul(n0(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return Y(r.x,r.y.oneMinus())}),Zle=K(([e,t,n])=>{let r=P3(z3(t)),i=X1(e.mul(r)).toVar(),a=z3(t,i).toVar(),o=z3(t,i.sub(X1(2,0))).toVar(),s=z3(t,i.sub(X1(1,0))).toVar(),c=z3(t,i.add(X1(1,0))).toVar(),l=z3(t,i.add(X1(2,0))).toVar(),u=z3(t,i.add(X1(0,2))).toVar(),d=z3(t,i.add(X1(0,1))).toVar(),f=z3(t,i.sub(X1(0,1))).toVar(),p=z3(t,i.sub(X1(0,2))).toVar(),m=o4(u2(q(2).mul(s).sub(o),a)).toVar(),h=o4(u2(q(2).mul(c).sub(l),a)).toVar(),g=o4(u2(q(2).mul(d).sub(u),a)).toVar(),_=o4(u2(q(2).mul(f).sub(p),a)).toVar(),v=y7(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(y7(e.sub(Y(q(1).div(r.x),0)),s,n)),v.negate().add(y7(e.add(Y(q(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(y7(e.add(Y(0,q(1).div(r.y))),d,n)),v.negate().add(y7(e.sub(Y(0,q(1).div(r.y))),f,n)));return Q2(D4(y,b))});var Qle=class extends FQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},$le=class extends $Z{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const eue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=j$(`float`)):(n=M$(t),r=j$(t));let i=new $le(e,n,r),a=f8(i,t,e);return a},tue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=j$(`float`)):(n=M$(t),r=j$(t));let i=new Qle(e,n,r),a=f8(i,t,e);return a};var nue=class extends X${static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const rue=G(nue),b7=new lZ,x7=new $X;var S7=class e extends X${static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=P6(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=P6(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=e2(`mat4`).label(`backgroundRotation`).setGroup(Z0).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==MJ?(b7.copy(r.backgroundRotation),b7.x*=-1,b7.y*=-1,b7.z*=-1,x7.makeRotationFromEuler(b7)):x7.identity(),x7}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};S7.BACKGROUND_BLURRINESS=`backgroundBlurriness`,S7.BACKGROUND_INTENSITY=`backgroundIntensity`,S7.BACKGROUND_ROTATION=`backgroundRotation`;const iue=G(S7,S7.BACKGROUND_BLURRINESS),aue=G(S7,S7.BACKGROUND_INTENSITY),oue=G(S7,S7.BACKGROUND_ROTATION);var sue=class extends L3{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=U$.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(U$.READ_WRITE)}toReadOnly(){return this.setAccess(U$.READ_ONLY)}toWriteOnly(){return this.setAccess(U$.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const C7=W(sue).setParameterLength(1,3),cue=(e,t,n)=>{let r=C7(e,t,n);return n!==null&&r.toStack(),r},lue=K(({texture:e,uv:t})=>{let n=1e-4,r=X().toVar();return W1(t.x.lessThan(n),()=>{r.assign(X(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(X(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(X(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(X(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(X(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(X(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(X(-.01,0,0))).r.sub(e.sample(t.add(X(n,0,0))).r),a=e.sample(t.add(X(0,-.01,0))).r.sub(e.sample(t.add(X(0,n,0))).r),o=e.sample(t.add(X(0,0,-.01))).r.sub(e.sample(t.add(X(0,0,n))).r);r.assign(X(i,a,o))}),r.normalize()});var uue=class extends L3{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return X(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return lue({texture:this,uv:e})}};const due=W(uue).setParameterLength(1,3);var fue=class extends N6{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const pue=(e,t,n)=>U(new fue(e,t,n)),w7=new WeakMap;var mue=class extends $${static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=V$.OBJECT,this.updateAfterType=V$.OBJECT,this.previousModelWorldMatrix=e2(new $X),this.previousProjectionMatrix=e2(new $X).setGroup(Z0),this.previousCameraViewMatrix=e2(new $X)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=E7(n);this.previousModelWorldMatrix.value.copy(r);let i=T7(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new $X,i.previousCameraViewMatrix=new $X,i.currentProjectionMatrix=new $X,i.currentCameraViewMatrix=new $X,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){E7(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?J3:e2(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(n6).mul(a6),r=this.previousProjectionMatrix.mul(t).mul(o6),i=n.xy.div(n.w),a=r.xy.div(r.w),o=u2(i,a);return o}};function T7(e){let t=w7.get(e);return t===void 0&&(t={},w7.set(e,t)),t}function E7(e,t=0){let n=T7(e),r=n[t];return r===void 0&&(n[t]=r=new $X,n[t].copy(e.matrixWorld)),r}const hue=G(mue),D7=K(([e,t])=>b4(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),O7=K(([e,t])=>b4(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),k7=K(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),A7=K(([e,t])=>F4(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),S4(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),gue=K(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return n0(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),_ue=K(([e])=>n0(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),vue=K(([e])=>(W1(e.a.equal(0),()=>n0(0)),n0(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),yue=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),D7(e)),bue=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),O7(e)),xue=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),k7(e)),Sue=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),A7(e)),Cue=K(([e])=>j7(e.rgb)),wue=K(([e,t=q(1)])=>t.mix(j7(e.rgb),e.rgb)),Tue=K(([e,t=q(1)])=>{let n=l2(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return F4(e.rgb,r,i)}),Eue=K(([e,t=q(1)])=>{let n=X(.57735,.57735,.57735),r=t.cos();return X(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(E4(n,e.rgb).mul(r.oneMinus())))))}),j7=(e,t=X(fX.getLuminanceCoefficients(new V)))=>E4(e,t),Due=K(([e,t=X(1),n=X(0),r=X(1),i=q(1),a=X(fX.getLuminanceCoefficients(new V,cY))])=>{let o=e.rgb.dot(X(a)),s=x4(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return W1(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),W1(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),W1(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),n0(s.rgb,e.a)});var Oue=class extends $${static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const kue=W(Oue).setParameterLength(2),M7=new $Y;var N7=class extends L3{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)}},P7=class extends N7{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}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)}},F7=class e extends $${static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new VQ;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new wX(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:qJ,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=e2(0),this._cameraFar=e2(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=V$.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=U(new P7(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new P7(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=B8(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=R8(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),M7.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(M7)),this._pixelRatio=i,this.setSize(M7.width,M7.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};F7.COLOR=`color`,F7.DEPTH=`depth`;const Aue=(e,t,n)=>U(new F7(F7.COLOR,e,t,n)),jue=(e,t)=>U(new N7(e,t)),Mue=(e,t,n)=>U(new F7(F7.DEPTH,e,t,n));var Nue=class extends F7{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(F7.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Y8;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=CJ;let t=m6.negate(),n=J3.mul(n6),r=q(1),i=n.mul(n0(a6,1)),a=n.mul(n0(a6.add(t),1)),o=Q2(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=n0(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 Pue=(e,t,n=new GZ(0,0,0),r=.003,i=1)=>U(new Nue(e,t,U(n),U(r),U(i))),Fue=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Iue=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Lue=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Rue=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),zue=K(([e,t])=>{let n=s0(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=s0(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Rue(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Bue=s0(X(1.6605,-.1246,-.0182),X(-.5876,1.1329,-.1006),X(-.0728,-.0083,1.1187)),Vue=s0(X(.6274,.0691,.0164),X(.3293,.9195,.088),X(.0433,.0113,.8956)),Hue=K(([e])=>{let t=X(e).toVar(),n=X(t.mul(t)).toVar(),r=X(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(d2(40.14,r.mul(t))).add(d2(31.96,r).sub(d2(6.868,n.mul(t))).add(d2(.4298,n).add(d2(.1191,t).sub(.00232))))}),Uue=K(([e,t])=>{let n=X(e).toVar(),r=s0(X(.856627153315983,.137318972929847,.11189821299995),X(.0951212405381588,.761241990602591,.0767994186031903),X(.0482516061458583,.101439036467562,.811302368396859)),i=s0(X(1.1271005818144368,-.1413297634984383,-.14132976349843826),X(-.11060664309660323,1.157823702216272,-.11060664309660294),X(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(Vue.mul(n)),n.assign(r.mul(n)),n.assign(x4(n,1e-10)),n.assign(q2(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(I4(n,0,1)),n.assign(Hue(n)),n.assign(i.mul(n)),n.assign(O4(x4(X(0),n),X(2.2))),n.assign(Bue.mul(n)),n.assign(I4(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Wue=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=b4(e.r,b4(e.g,e.b)),a=J4(i.lessThan(.08),i.sub(d2(6.25,i.mul(i))),.04);e.subAssign(a);let o=x4(e.r,x4(e.g,e.b));W1(o.lessThan(n),()=>e);let s=u2(1,n),c=u2(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=u2(1,f2(1,r.mul(o.sub(c)).add(1)));return F4(e,X(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var I7=class extends X${static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.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 L7=W(I7).setParameterLength(1,3),Gue=(e,t)=>L7(e,t,`js`),Kue=(e,t)=>L7(e,t,`wgsl`),que=(e,t)=>L7(e,t,`glsl`);var Jue=class extends I7{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
431
+ `,t===`property`?o:e.format(`${o}()`,i,t)}};const R7=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=U(new Jue(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},Yue=(e,t)=>R7(e,t,`glsl`),Xue=(e,t)=>R7(e,t,`wgsl`);var Zue=class extends X${static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new TY,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(){let 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:q()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=R$(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?z$(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}};const z7=W(Zue).setParameterLength(1);var B7=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},Que=class{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){let t=this.parameters[e],n=t?t.getValue():null;return n}};const V7=new B7;var $ue=class extends X${static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new B7,this._output=z7(null),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(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=z7(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=z7(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[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(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r(...t)}async callAsync(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r.constructor.name===`AsyncFunction`?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new Que(this),r=V7.get(`THREE`),i=V7.get(`TSL`),a=this.getMethod(),o=[n,this._local,V7,e,t,r,i];this._object=a(...o);let s=this._object.layout;if(s&&(s.cache===!1&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(let e of s.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){for(let t in super.deserialize(e),this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:q()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`],n=t.join(`, `),r=`var `+n+`; var output = {};
432
+ `,i=`
433
+ return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),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){let t=[C$(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return w$(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 ede=W($ue).setParameterLength(1,2);function H7(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||l6.z).negate()}const U7=K(([e,t],n)=>{let r=H7(n);return z4(e,t,r)}),W7=K(([e],t)=>{let n=H7(t);return e.mul(e,n,n).negate().exp().oneMinus()}),G7=K(([e,t])=>n0(t.toFloat().mix(L0.rgb,e.toVec3()),L0.a));function tde(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),G7(e,U7(t,n))}function nde(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),G7(e,W7(t))}let K7=null,q7=null;var rde=class extends X${static get type(){return`RangeNode`}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(F$(this.minNode.value)),n=e.getTypeLength(F$(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(F$(r)),o=e.getTypeLength(F$(i));K7||=new CX,q7||=new CX,K7.setScalar(0),q7.setScalar(0),a===1?K7.setScalar(r):r.isColor?K7.set(r.r,r.g,r.b,1):K7.set(r.x,r.y,r.z||0,r.w||0),o===1?q7.setScalar(i):i.isColor?q7.set(i.r,i.g,i.b,1):q7.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=K7.getComponent(t),r=q7.getComponent(t);l[e]=QY.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=V3(l,`vec4`,t.count).element(s8).convert(u);else{let t=new FQ(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=v3(t).convert(u)}}else n=q(0);return n}};const ide=W(rde).setParameterLength(2);var ade=class extends X${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){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} 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 J7=(e,t)=>U(new ade(e,t)),ode=J7(`numWorkgroups`,`uvec3`),sde=J7(`workgroupId`,`uvec3`),cde=J7(`globalId`,`uvec3`),lde=J7(`localId`,`uvec3`),ude=J7(`subgroupSize`,`uint`);var dde=class extends X${constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const Y7=W(dde),fde=()=>Y7(`workgroup`).toStack(),pde=()=>Y7(`storage`).toStack(),mde=()=>Y7(`texture`).toStack();var hde=class extends Z${constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},gde=class extends X${constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new hde(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const _de=(e,t)=>U(new gde(`Workgroup`,e,t));var X7=class extends X${static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=D3(l,i).toConst()),t.constNode.build(e)}};X7.ATOMIC_LOAD=`atomicLoad`,X7.ATOMIC_STORE=`atomicStore`,X7.ATOMIC_ADD=`atomicAdd`,X7.ATOMIC_SUB=`atomicSub`,X7.ATOMIC_MAX=`atomicMax`,X7.ATOMIC_MIN=`atomicMin`,X7.ATOMIC_AND=`atomicAnd`,X7.ATOMIC_OR=`atomicOr`,X7.ATOMIC_XOR=`atomicXor`;const vde=W(X7),Z7=(e,t,n)=>vde(e,t,n).toStack(),yde=e=>Z7(X7.ATOMIC_LOAD,e,null),bde=(e,t)=>Z7(X7.ATOMIC_STORE,e,t),xde=(e,t)=>Z7(X7.ATOMIC_ADD,e,t),Sde=(e,t)=>Z7(X7.ATOMIC_SUB,e,t),Cde=(e,t)=>Z7(X7.ATOMIC_MAX,e,t),wde=(e,t)=>Z7(X7.ATOMIC_MIN,e,t),Tde=(e,t)=>Z7(X7.ATOMIC_AND,e,t),Ede=(e,t)=>Z7(X7.ATOMIC_OR,e,t),Dde=(e,t)=>Z7(X7.ATOMIC_XOR,e,t);let Q7;function $7(e){Q7||=new WeakMap;let t=Q7.get(e);return t===void 0&&Q7.set(e,t={}),t}function e9(e){let t=$7(e);return t.shadowMatrix||=e2(`mat4`).setGroup(Z0).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function Ode(e,t=s6){let n=e9(e).mul(t),r=n.xyz.div(n.w);return r}function t9(e){let t=$7(e);return t.position||=e2(new V).setGroup(Z0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function n9(e){let t=$7(e);return t.targetPosition||=e2(new V).setGroup(Z0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function kde(e){let t=$7(e);return t.viewPosition||=e2(new V).setGroup(Z0).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const Ade=e=>Y3.transformDirection(t9(e).sub(n9(e))),jde=e=>e.sort((e,t)=>e.id-t.id),Mde=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},r9=new WeakMap,i9=[];var Nde=class extends X${static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=X().toVar(),this.totalSpecularNode=X().toVar(),this.outgoingLightNode=X().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(i9.push(n.id),i9.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;i9.push(e,t)}}let t=w$(i9);return i9.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=jde(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(U(e));else{let r=null;if(n!==null&&(r=Mde(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;r9.has(e)?r=r9.get(e):(r=U(new n(e)),r9.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=X(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const Pde=(e=[])=>U(new Nde).setLights(e);var Fde=class extends X${static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=V$.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){a9.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s6)}};const a9=_0(`vec3`,`shadowPositionWorld`);function Ide(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new GZ),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Lde(e,t){return t=Ide(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Rde(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function zde(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function Bde(e,t){return t=zde(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Vde(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Hde(e,t,n){return n=Lde(e,n),n=Bde(t,n),n}function Ude(e,t,n){Rde(e,n),Vde(t,n)}const o9=new WeakMap,s9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=R3(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),c9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup(Z0),o=P6(`radius`,`float`,n).setGroup(Z0),s=Y(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return l2(i(t.xy.add(Y(c,l)),t.z),i(t.xy.add(Y(0,l)),t.z),i(t.xy.add(Y(u,l)),t.z),i(t.xy.add(Y(f,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(c,0)),t.z),i(t.xy.add(Y(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(f,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(m,h)),t.z),i(t.xy.add(Y(c,d)),t.z),i(t.xy.add(Y(0,d)),t.z),i(t.xy.add(Y(u,d)),t.z)).mul(1/17)}),l9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup(Z0),o=Y(1).div(a),s=o.x,c=o.y,l=t.xy,u=$2(l.mul(a).add(.5));return l.subAssign(u.mul(o)),l2(i(l,t.z),i(l.add(Y(s,0)),t.z),i(l.add(Y(0,c)),t.z),i(l.add(o),t.z),F4(i(l.add(Y(s.negate(),0)),t.z),i(l.add(Y(s.mul(2),0)),t.z),u.x),F4(i(l.add(Y(s.negate(),c)),t.z),i(l.add(Y(s.mul(2),c)),t.z),u.x),F4(i(l.add(Y(0,c.negate())),t.z),i(l.add(Y(0,c.mul(2))),t.z),u.y),F4(i(l.add(Y(s,c.negate())),t.z),i(l.add(Y(s,c.mul(2))),t.z),u.y),F4(F4(i(l.add(Y(s.negate(),c.negate())),t.z),i(l.add(Y(s.mul(2),c.negate())),t.z),u.x),F4(i(l.add(Y(s.negate(),c.mul(2))),t.z),i(l.add(Y(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),u9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=q(1).toVar(),i=R3(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=S4(t.z,i.x);return W1(a.notEqual(q(1)),()=>{let e=t.z.sub(i.x),n=x4(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=I4(u2(o,.3).div(.6499999999999999)),r.assign(I4(x4(a,o)))}),r}),Wde=K(([e,t,n])=>{let r=s6.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),Gde=e=>{let t=e.shadow.camera,n=P6(`near`,`float`,t).setGroup(Z0),r=P6(`far`,`float`,t).setGroup(Z0),i=Q3(e);return Wde(i,n,r)},d9=e=>{let t=o9.get(e);if(t===void 0){let n=e.isPointLight?Gde(e):null;t=new Y8,t.colorNode=n0(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,o9.set(e,t)}return t},f9=new ole,p9=[],m9=(e,t,n,r)=>{p9[0]=e,p9[1]=t;let i=f9.get(p9);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===xJ)&&(r&&(L$(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,f9.set(p9,i)),p9[0]=null,p9[1]=null,i},Kde=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(l2(k8.xy,Y(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=J2(o.sub(a.mul(a)));return Y(a,l)}),qde=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(l2(k8.xy,Y(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(l2(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=J2(o.sub(a.mul(a)));return Y(a,l)}),Jde=[s9,c9,l9,u9];let h9;const g9=new _7;var _9=class extends Fde{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=P6(`bias`,`float`,n).setGroup(Z0),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===wY&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=P6(`near`,`float`,n.camera).setGroup(Z0),r=P6(`far`,`float`,n.camera).setGroup(Z0);o=V8(e.negate(),t,r)}return a=X(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return Jde[e]}setupRenderTarget(e,t){let n=new VQ(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=mY;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===xJ&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:ZJ,type:qJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:ZJ,type:qJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:ZJ,type:qJ,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:ZJ,type:qJ,depthBuffer:!1}));let t=R3(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=R3(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=P6(`blurSamples`,`float`,r).setGroup(Z0),s=P6(`radius`,`float`,r).setGroup(Z0),c=P6(`mapSize`,`vec2`,r).setGroup(Z0),l=this.vsmMaterialVertical||=new Y8;l.fragmentNode=Kde({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Y8,l.fragmentNode=qde({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=P6(`intensity`,`float`,r).setGroup(Z0),c=P6(`normalBias`,`float`,r).setGroup(Z0),l=e9(n).mul(a9.add(y6.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===xJ&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=R3(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=F4(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;h9=Hde(i,a,h9),a.overrideMaterial=d9(n),i.setRenderObjectFunction(m9(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===xJ&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,Ude(i,a,h9)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),g9.material=this.vsmMaterialVertical,g9.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),g9.material=this.vsmMaterialHorizontal,g9.render(e)}dispose(){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),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const Yde=(e,t)=>U(new _9(e,t)),Xde=new GZ,v9=K(([e,t])=>{let n=e.toVar(),r=o4(n),i=f2(1,x4(r.x,x4(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=Y(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return W1(r.z.greaterThanEqual(s),()=>{W1(n.z.greaterThan(0),()=>{a.x.assign(u2(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=s4(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=s4(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),Y(.125,.25).mul(a).add(Y(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),y9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>R3(e,v9(t,r.y)).compare(n)),b9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=P6(`radius`,`float`,i).setGroup(Z0),o=Y(-1,1).mul(a).mul(r.y);return R3(e,v9(t.add(o.xyy),r.y)).compare(n).add(R3(e,v9(t.add(o.yyy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xyx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yyx),r.y)).compare(n)).add(R3(e,v9(t,r.y)).compare(n)).add(R3(e,v9(t.add(o.xxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xxx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),Zde=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=e2(`float`).setGroup(Z0).onRenderUpdate(()=>r.camera.near),s=e2(`float`).setGroup(Z0).onRenderUpdate(()=>r.camera.far),c=P6(`bias`,`float`,r).setGroup(Z0),l=e2(r.mapSize).setGroup(Z0),u=q(1).toVar();return W1(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=Y(1).div(l.mul(Y(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),x9=new CX,S9=new $Y,C9=new $Y;var Qde=class extends _9{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===bJ?y9:b9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return Zde({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();C9.copy(t.mapSize),C9.multiply(o),n.setSize(C9.width,C9.height),S9.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(Xde),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=S9.x*o.x,c=C9.y-S9.y-S9.y*o.y;x9.set(s,c,S9.x*o.z,S9.y*o.w),n.viewport.copy(x9),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const $de=(e,t)=>U(new Qde(e,t)),w9=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),efe=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=w9({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}},tfe=K(([e=N3()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),nfe=K(([e=N3()],{renderer:t,material:n})=>{let r=P4(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=q(r.fwidth()).toVar();i=z4(e.oneMinus(),e.add(1),r).oneMinus()}else i=J4(r.greaterThan(1),0,1);return i}),T9=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=Y1(e).toVar();return J4(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),E9=K(([e,t])=>{let n=Y1(t).toVar(),r=q(e).toVar();return J4(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),D9=K(([e])=>{let t=q(e).toVar();return J(X2(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),O9=K(([e,t])=>{let n=q(e).toVar();return t.assign(D9(n)),n.sub(q(t))}),rfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=q(r).toVar(),l=q(n).toVar(),u=q(t).toVar(),d=q(e).toVar(),f=q(u2(1,s)).toVar();return u2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).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`}]}),ife=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=X(r).toVar(),l=X(n).toVar(),u=X(t).toVar(),d=X(e).toVar(),f=q(u2(1,s)).toVar();return u2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).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`}]}),k9=$5([rfe,ife]),afe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=q(s).toVar(),h=q(o).toVar(),g=q(a).toVar(),_=q(i).toVar(),v=q(r).toVar(),y=q(n).toVar(),b=q(t).toVar(),x=q(e).toVar(),S=q(u2(1,p)).toVar(),ee=q(u2(1,f)).toVar(),te=q(u2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).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`}]}),ofe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=X(s).toVar(),h=X(o).toVar(),g=X(a).toVar(),_=X(i).toVar(),v=X(r).toVar(),y=X(n).toVar(),b=X(t).toVar(),x=X(e).toVar(),S=q(u2(1,p)).toVar(),ee=q(u2(1,f)).toVar(),te=q(u2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).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`}]}),A9=$5([afe,ofe]),sfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=J1(e).toVar(),o=J1(a.bitAnd(J1(7))).toVar(),s=q(T9(o.lessThan(J1(4)),i,r)).toVar(),c=q(d2(2,T9(o.lessThan(J1(4)),r,i))).toVar();return E9(s,Y1(o.bitAnd(J1(1)))).add(E9(c,Y1(o.bitAnd(J1(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),cfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=J1(e).toVar(),c=J1(s.bitAnd(J1(15))).toVar(),l=q(T9(c.lessThan(J1(8)),o,a)).toVar(),u=q(T9(c.lessThan(J1(4)),a,T9(c.equal(J1(12)).or(c.equal(J1(14))),o,i))).toVar();return E9(l,Y1(c.bitAnd(J1(1)))).add(E9(u,Y1(c.bitAnd(J1(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`}]}),j9=$5([sfe,cfe]),lfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=e0(e).toVar();return X(j9(a.x,i,r),j9(a.y,i,r),j9(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),ufe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=e0(e).toVar();return X(j9(s.x,o,a,i),j9(s.y,o,a,i),j9(s.z,o,a,i))}).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`}]}),M9=$5([lfe,ufe]),dfe=K(([e])=>{let t=q(e).toVar();return d2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),ffe=K(([e])=>{let t=q(e).toVar();return d2(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),pfe=K(([e])=>{let t=X(e).toVar();return d2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),N9=$5([dfe,pfe]),mfe=K(([e])=>{let t=X(e).toVar();return d2(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),P9=$5([ffe,mfe]),F9=K(([e,t])=>{let n=J(t).toVar(),r=J1(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(J(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),I9=K(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(F9(n,J(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(F9(n,J(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(4))),t.addAssign(e)}),L9=K(([e,t,n])=>{let r=J1(n).toVar(),i=J1(t).toVar(),a=J1(e).toVar();return r.bitXorAssign(i),r.subAssign(F9(i,J(14))),a.bitXorAssign(r),a.subAssign(F9(r,J(11))),i.bitXorAssign(a),i.subAssign(F9(a,J(25))),r.bitXorAssign(i),r.subAssign(F9(i,J(16))),a.bitXorAssign(r),a.subAssign(F9(r,J(4))),i.bitXorAssign(a),i.subAssign(F9(a,J(14))),r.bitXorAssign(i),r.subAssign(F9(i,J(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),R9=K(([e])=>{let t=J1(e).toVar();return q(t).div(q(J1(J(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),z9=K(([e])=>{let t=q(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),hfe=K(([e])=>{let t=J(e).toVar(),n=J1(J1(1)).toVar(),r=J1(J1(J(3735928559)).add(n.shiftLeft(J1(2))).add(J1(13))).toVar();return L9(r.add(J1(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),gfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=J1(J1(2)).toVar(),a=J1().toVar(),o=J1().toVar(),s=J1().toVar();return a.assign(o.assign(s.assign(J1(J(3735928559)).add(i.shiftLeft(J1(2))).add(J1(13))))),a.addAssign(J1(r)),o.addAssign(J1(n)),L9(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),_fe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=J1(J1(3)).toVar(),s=J1().toVar(),c=J1().toVar(),l=J1().toVar();return s.assign(c.assign(l.assign(J1(J(3735928559)).add(o.shiftLeft(J1(2))).add(J1(13))))),s.addAssign(J1(a)),c.addAssign(J1(i)),l.addAssign(J1(r)),L9(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),vfe=K(([e,t,n,r])=>{let i=J(r).toVar(),a=J(n).toVar(),o=J(t).toVar(),s=J(e).toVar(),c=J1(J1(4)).toVar(),l=J1().toVar(),u=J1().toVar(),d=J1().toVar();return l.assign(u.assign(d.assign(J1(J(3735928559)).add(c.shiftLeft(J1(2))).add(J1(13))))),l.addAssign(J1(s)),u.addAssign(J1(o)),d.addAssign(J1(a)),I9(l,u,d),l.addAssign(J1(i)),L9(l,u,d)}).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`}]}),yfe=K(([e,t,n,r,i])=>{let a=J(i).toVar(),o=J(r).toVar(),s=J(n).toVar(),c=J(t).toVar(),l=J(e).toVar(),u=J1(J1(5)).toVar(),d=J1().toVar(),f=J1().toVar(),p=J1().toVar();return d.assign(f.assign(p.assign(J1(J(3735928559)).add(u.shiftLeft(J1(2))).add(J1(13))))),d.addAssign(J1(l)),f.addAssign(J1(c)),p.addAssign(J1(s)),I9(d,f,p),d.addAssign(J1(o)),f.addAssign(J1(a)),L9(d,f,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`}]}),B9=$5([hfe,gfe,_fe,vfe,yfe]),bfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=J1(B9(r,n)).toVar(),a=e0().toVar();return a.x.assign(i.bitAnd(J(255))),a.y.assign(i.shiftRight(J(8)).bitAnd(J(255))),a.z.assign(i.shiftRight(J(16)).bitAnd(J(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),xfe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=J1(B9(a,i,r)).toVar(),s=e0().toVar();return s.x.assign(o.bitAnd(J(255))),s.y.assign(o.shiftRight(J(8)).bitAnd(J(255))),s.z.assign(o.shiftRight(J(16)).bitAnd(J(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),V9=$5([bfe,xfe]),Sfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=q(k9(j9(B9(n,r),i,a),j9(B9(n.add(J(1)),r),i.sub(1),a),j9(B9(n,r.add(J(1))),i,a.sub(1)),j9(B9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Cfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=q(A9(j9(B9(n,r,i),a,o,s),j9(B9(n.add(J(1)),r,i),a.sub(1),o,s),j9(B9(n,r.add(J(1)),i),a,o.sub(1),s),j9(B9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),j9(B9(n,r,i.add(J(1))),a,o,s.sub(1)),j9(B9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),j9(B9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),j9(B9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),H9=$5([Sfe,Cfe]),wfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=X(k9(M9(V9(n,r),i,a),M9(V9(n.add(J(1)),r),i.sub(1),a),M9(V9(n,r.add(J(1))),i,a.sub(1)),M9(V9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Tfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=X(A9(M9(V9(n,r,i),a,o,s),M9(V9(n.add(J(1)),r,i),a.sub(1),o,s),M9(V9(n,r.add(J(1)),i),a,o.sub(1),s),M9(V9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),M9(V9(n,r,i.add(J(1))),a,o,s.sub(1)),M9(V9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),M9(V9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),M9(V9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U9=$5([wfe,Tfe]),Efe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return R9(B9(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Dfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return R9(B9(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Ofe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return R9(B9(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),kfe=K(([e])=>{let t=n0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return R9(B9(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Afe=$5([Efe,Dfe,Ofe,kfe]),jfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return X(R9(B9(n,J(0))),R9(B9(n,J(1))),R9(B9(n,J(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Mfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return X(R9(B9(n,r,J(0))),R9(B9(n,r,J(1))),R9(B9(n,r,J(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Nfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return X(R9(B9(n,r,i,J(0))),R9(B9(n,r,i,J(1))),R9(B9(n,r,i,J(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Pfe=K(([e])=>{let t=n0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return X(R9(B9(n,r,i,a,J(0))),R9(B9(n,r,i,a,J(1))),R9(B9(n,r,i,a,J(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),W9=$5([jfe,Mfe,Nfe,Pfe]),G9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=q(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(H9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).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`}]}),K9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(U9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).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`}]}),Ffe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar();return Y(G9(s,o,a,i),G9(s.add(X(J(19),J(193),J(17))),o,a,i))}).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`}]}),Ife=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(K9(s,o,a,i)).toVar(),l=q(G9(s.add(X(J(19),J(193),J(17))),o,a,i)).toVar();return n0(c,l)}).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`}]}),Lfe=K(([e,t,n,r,i,a,o])=>{let s=J(o).toVar(),c=q(a).toVar(),l=J(i).toVar(),u=J(r).toVar(),d=J(n).toVar(),f=J(t).toVar(),p=Y(e).toVar(),m=X(W9(Y(f.add(u),d.add(l)))).toVar(),h=Y(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=Y(Y(q(f),q(d)).add(h)).toVar(),_=Y(g.sub(p)).toVar();return W1(s.equal(J(2)),()=>o4(_.x).add(o4(_.y))),W1(s.equal(J(3)),()=>x4(o4(_.x),o4(_.y))),E4(_,_)}).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`}]}),Rfe=K(([e,t,n,r,i,a,o,s,c])=>{let l=J(c).toVar(),u=q(s).toVar(),d=J(o).toVar(),f=J(a).toVar(),p=J(i).toVar(),m=J(r).toVar(),h=J(n).toVar(),g=J(t).toVar(),_=X(e).toVar(),v=X(W9(X(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=X(X(q(g),q(h),q(m)).add(v)).toVar(),b=X(y.sub(_)).toVar();return W1(l.equal(J(2)),()=>o4(b.x).add(o4(b.y)).add(o4(b.z))),W1(l.equal(J(3)),()=>x4(o4(b.x),o4(b.y),o4(b.z))),E4(b,b)}).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`}]}),q9=$5([Lfe,Rfe]),zfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();l.assign(b4(l,n))})}),W1(r.equal(J(0)),()=>{l.assign(J2(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Bfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();W1(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),W1(r.equal(J(0)),()=>{l.assign(J2(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Vfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();W1(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),W1(r.equal(J(0)),()=>{l.assign(J2(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Hfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();u.assign(b4(u,a))})})}),W1(r.equal(J(0)),()=>{u.assign(J2(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Ufe=$5([zfe,Hfe]),Wfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();W1(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),W1(r.equal(J(0)),()=>{u.assign(J2(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Gfe=$5([Bfe,Wfe]),Kfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();W1(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),W1(r.equal(J(0)),()=>{u.assign(J2(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),qfe=$5([Vfe,Kfe]),Jfe=K(([e])=>{let t=e.y,n=e.z,r=X().toVar();return W1(t.lessThan(1e-4),()=>{r.assign(X(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(X2(i)).mul(6).toVar();let a=J(h4(i)),o=i.sub(q(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());W1(a.equal(J(0)),()=>{r.assign(X(n,l,s))}).ElseIf(a.equal(J(1)),()=>{r.assign(X(c,n,s))}).ElseIf(a.equal(J(2)),()=>{r.assign(X(s,n,l))}).ElseIf(a.equal(J(3)),()=>{r.assign(X(s,c,n))}).ElseIf(a.equal(J(4)),()=>{r.assign(X(l,s,n))}).Else(()=>{r.assign(X(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),Yfe=K(([e])=>{let t=X(e).toVar(),n=q(t.x).toVar(),r=q(t.y).toVar(),i=q(t.z).toVar(),a=q(b4(n,b4(r,i))).toVar(),o=q(x4(n,x4(r,i))).toVar(),s=q(o.sub(a)).toVar(),c=q().toVar(),l=q().toVar(),u=q().toVar();return u.assign(o),W1(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),W1(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{W1(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(l2(2,i.sub(n).div(s)))}).Else(()=>{c.assign(l2(4,n.sub(r).div(s)))}),c.mulAssign(1/6),W1(c.lessThan(0),()=>{c.addAssign(1)})}),X(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),Xfe=K(([e])=>{let t=X(e).toVar(),n=t0(_2(t,X(.04045))).toVar(),r=X(t.div(12.92)).toVar(),i=X(O4(x4(t.add(X(.055)),X(0)).div(1.055),X(2.4))).toVar();return F4(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),J9=(e,t)=>{e=q(e),t=q(t);let n=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return z4(e.sub(n),e.add(n),t)},Y9=(e,t,n,r)=>F4(e,t,n[r].clamp()),Zfe=(e,t,n=N3())=>Y9(e,t,n,`x`),Qfe=(e,t,n=N3())=>Y9(e,t,n,`y`),X9=(e,t,n,r,i)=>F4(e,t,J9(n,r[i])),$fe=(e,t,n,r=N3())=>X9(e,t,n,r,`x`),epe=(e,t,n,r=N3())=>X9(e,t,n,r,`y`),tpe=(e=1,t=0,n=N3())=>n.mul(e).add(t),npe=(e,t=1)=>(e=q(e),e.abs().pow(t).mul(e.sign())),rpe=(e,t=1,n=.5)=>q(e).sub(n).mul(t).add(n),ipe=(e=N3(),t=1,n=0)=>H9(e.convert(`vec2|vec3`)).mul(t).add(n),ape=(e=N3(),t=1,n=0)=>U9(e.convert(`vec2|vec3`)).mul(t).add(n),ope=(e=N3(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=n0(U9(e),H9(e.add(Y(19,73))));return r.mul(t).add(n)},spe=(e=N3(),t=1)=>Ufe(e.convert(`vec2|vec3`),t,J(1)),cpe=(e=N3(),t=1)=>Gfe(e.convert(`vec2|vec3`),t,J(1)),lpe=(e=N3(),t=1)=>qfe(e.convert(`vec2|vec3`),t,J(1)),upe=(e=N3())=>Afe(e.convert(`vec2|vec3`)),dpe=(e=N3(),t=3,n=2,r=.5,i=1)=>G9(e,J(t),n,r).mul(i),fpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Ffe(e,J(t),n,r).mul(i),ppe=(e=N3(),t=3,n=2,r=.5,i=1)=>K9(e,J(t),n,r).mul(i),mpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Ife(e,J(t),n,r).mul(i),hpe=K(([e,t,n])=>{let r=Q2(e).toVar(),i=u2(q(.5).mul(t.sub(n)),s6).div(r).toVar(),a=u2(q(-.5).mul(t.sub(n)),s6).div(r).toVar(),o=X().toVar();o.x=r.x.greaterThan(q(0)).select(i.x,a.x),o.y=r.y.greaterThan(q(0)).select(i.y,a.y),o.z=r.z.greaterThan(q(0)).select(i.z,a.z);let s=b4(o.x,o.y,o.z).toVar(),c=s6.add(r.mul(s)).toVar();return c.sub(n)}),gpe=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(d2(n,n).sub(d2(r,r)))),a});var $=Object.freeze({__proto__:null,BRDF_GGX:Ace,BRDF_Lambert:Tce,BasicPointShadowFilter:y9,BasicShadowFilter:s9,Break:_8,Const:n3,Continue:Zse,DFGApprox:jce,D_GGX:t5,Discard:O3,EPSILON:I2,F_Schlick:Q8,Fn:K,INFINITY:L2,If:W1,Loop:g8,NodeAccess:U$,NodeShaderStage:B$,NodeType:H$,NodeUpdateType:V$,PCFShadowFilter:c9,PCFSoftShadowFilter:l9,PI:R2,PI2:z2,PointShadowFilter:b9,Return:moe,Schlick_to_F0:Mce,ScriptableNodeResources:V7,ShaderNode:R1,Stack:K1,Switch:G1,TBNViewMatrix:G6,VSMShadowFilter:u9,V_GGX_SmithCorrelated:e5,Var:t3,abs:o4,acesFilmicToneMapping:zue,acos:i4,add:l2,addMethodChaining:H,addNodeElement:_oe,agxToneMapping:Uue,all:B2,alphaT:A0,and:b2,anisotropy:j0,anisotropyB:N0,anisotropyT:M0,any:V2,append:m0,array:n2,arrayBuffer:u0,asin:r4,assign:i2,atan:a4,atan2:W4,atomicAdd:xde,atomicAnd:Tde,atomicFunc:Z7,atomicLoad:yde,atomicMax:Cde,atomicMin:wde,atomicOr:Ede,atomicStore:bde,atomicSub:Sde,atomicXor:Dde,attenuationColor:G0,attenuationDistance:W0,attribute:M3,attributeArray:eue,backgroundBlurriness:iue,backgroundIntensity:aue,backgroundRotation:oue,batch:d8,billboarding:Fle,bitAnd:w2,bitNot:T2,bitOr:E2,bitXor:D2,bitangentGeometry:Qoe,bitangentLocal:$oe,bitangentView:U6,bitangentWorld:ese,bitcast:v4,blendBurn:D7,blendColor:gue,blendDodge:O7,blendOverlay:A7,blendScreen:k7,blur:E5,bool:Y1,buffer:V3,bufferAttribute:g3,bumpMap:J6,burn:yue,bvec2:Q1,bvec3:t0,bvec4:a0,bypass:C3,cache:x3,call:o2,cameraFar:q3,cameraIndex:G3,cameraNear:K3,cameraNormalMatrix:koe,cameraPosition:Aoe,cameraProjectionMatrix:J3,cameraProjectionMatrixInverse:Doe,cameraViewMatrix:Y3,cameraWorldMatrix:Ooe,cbrt:N4,cdl:Due,ceil:Z2,checker:tfe,cineonToneMapping:Lue,clamp:I4,clearcoat:C0,clearcoatRoughness:w0,code:L7,color:q1,colorSpaceToWorking:f3,colorToDirection:Cce,compute:b3,computeSkinning:Yse,cond:Y4,context:Z4,convert:f0,convertColorSpace:ioe,convertToTexture:Yle,cos:t4,cross:D4,cubeTexture:M6,cubeTextureBase:j6,cubeToUV:v9,dFdx:d4,dFdy:f4,dashSize:R0,debug:A3,decrement:N2,decrementBefore:j2,defaultBuildStages:G$,defaultShaderStages:W$,defined:I1,degrees:U2,deltaTime:t7,densityFog:nde,densityFogFactor:W7,depth:U8,depthPass:Mue,difference:T4,diffuseColor:y0,directPointLight:efe,directionToColor:Sce,dispersion:K0,distance:w4,div:f2,dodge:bue,dot:E4,drawIndex:c8,dynamicBufferAttribute:_3,element:d0,emissive:b0,equal:m2,equals:y4,equirectUV:Z8,exp:W2,exp2:G2,expression:D3,faceDirection:f6,faceForward:B4,faceforward:G4,float:q,floor:X2,fog:G7,fract:$2,frameGroup:X0,frameId:Tle,frontFacing:d6,fwidth:g4,gain:vle,gapSize:z0,getConstNodeType:L1,getCurrentStack:U1,getDirection:S5,getDistanceAttenuation:w9,getGeometryRoughness:$8,getNormalFromDepth:Zle,getParallaxCorrectNormal:hpe,getRoughness:Ece,getScreenPosition:Xle,getShIrradianceAt:gpe,getShadowMaterial:d9,getShadowRenderObjectFunction:m9,getTextureIndex:Y5,getViewPosition:y7,globalId:cde,glsl:que,glslFn:Yue,grayscale:Cue,greaterThan:_2,greaterThanEqual:y2,hash:_le,highpModelNormalViewMatrix:Uoe,highpModelViewMatrix:Hoe,hue:Eue,increment:M2,incrementBefore:A2,instance:Hse,instanceIndex:s8,instancedArray:tue,instancedBufferAttribute:v3,instancedDynamicBufferAttribute:y3,instancedMesh:u8,int:J,inverseSqrt:Y2,inversesqrt:K4,invocationLocalIndex:Vse,invocationSubgroupIndex:Bse,ior:V0,iridescence:D0,iridescenceIOR:O0,iridescenceThickness:k0,ivec2:X1,ivec3:$1,ivec4:r0,js:Gue,label:Q4,length:c4,lengthSq:P4,lessThan:g2,lessThanEqual:v2,lightPosition:t9,lightProjectionUV:Ode,lightShadowMatrix:e9,lightTargetDirection:Ade,lightTargetPosition:n9,lightViewPosition:kde,lightingContext:C8,lights:Pde,linearDepth:W8,linearToneMapping:Fue,localId:lde,log:K2,log2:q2,logarithmicDepthToViewZ:fce,loop:Qse,luminance:j7,mat2:o0,mat3:s0,mat4:c0,matcapUV:tle,materialAO:n8,materialAlphaTest:X6,materialAnisotropy:Cse,materialAnisotropyVector:r8,materialAttenuationColor:jse,materialAttenuationDistance:Ase,materialClearcoat:_se,materialClearcoatNormal:yse,materialClearcoatRoughness:vse,materialColor:Z6,materialDispersion:Rse,materialEmissive:Q6,materialEnvIntensity:Koe,materialEnvRotation:T6,materialIOR:kse,materialIridescence:wse,materialIridescenceIOR:Tse,materialIridescenceThickness:Ese,materialLightMap:t8,materialLineDashOffset:Ise,materialLineDashSize:Nse,materialLineGapSize:Pse,materialLineScale:Mse,materialLineWidth:Fse,materialMetalness:gse,materialNormal:e8,materialOpacity:$6,materialPointSize:Lse,materialReference:I6,materialReflectivity:mse,materialRefractionRatio:w6,materialRotation:bse,materialRoughness:hse,materialSheen:xse,materialSheenRoughness:Sse,materialShininess:lse,materialSpecular:use,materialSpecularColor:fse,materialSpecularIntensity:dse,materialSpecularStrength:pse,materialThickness:Ose,materialTransmission:Dse,max:x4,maxMipLevel:F3,mediumpModelViewMatrix:r6,metalness:S0,min:b4,mix:F4,mixElement:H4,mod:p2,modInt:F2,modelDirection:Ioe,modelNormalMatrix:t6,modelPosition:Loe,modelRadius:Boe,modelScale:Roe,modelViewMatrix:n6,modelViewPosition:zoe,modelViewProjection:i8,modelWorldMatrix:e6,modelWorldMatrixInverse:Voe,morphReference:x8,mrt:X5,mul:d2,mx_aastep:J9,mx_cell_noise_float:upe,mx_contrast:rpe,mx_fractal_noise_float:dpe,mx_fractal_noise_vec2:fpe,mx_fractal_noise_vec3:ppe,mx_fractal_noise_vec4:mpe,mx_hsvtorgb:Jfe,mx_noise_float:ipe,mx_noise_vec3:ape,mx_noise_vec4:ope,mx_ramplr:Zfe,mx_ramptb:Qfe,mx_rgbtohsv:Yfe,mx_safepower:npe,mx_splitlr:$fe,mx_splittb:epe,mx_srgb_texture_to_lin_rec709:Xfe,mx_transform_uv:tpe,mx_worley_noise_float:spe,mx_worley_noise_vec2:cpe,mx_worley_noise_vec3:lpe,namespace:S3,negate:l4,neutralToneMapping:Wue,nodeArray:B1,nodeImmutable:G,nodeObject:U,nodeObjects:z1,nodeProxy:W,normalFlat:h6,normalGeometry:p6,normalLocal:m6,normalMap:q6,normalView:g6,normalWorld:_6,normalize:Q2,not:S2,notEqual:h2,numWorkgroups:ode,objectDirection:joe,objectGroup:Q0,objectPosition:Q3,objectRadius:Foe,objectScale:Noe,objectViewPosition:Poe,objectWorldMatrix:Moe,oneMinus:u4,or:x2,orthographicDepthToViewZ:dce,oscSawtooth:Mle,oscSine:kle,oscSquare:Ale,oscTriangle:jle,output:L0,outputStruct:hle,overlay:Sue,overloadingFn:$5,parabola:Z5,parallaxDirection:K6,parallaxUV:nse,parameter:cle,pass:Aue,passTexture:jue,pcurve:yle,perspectiveDepthToViewZ:B8,pmremTexture:$ce,pointShadow:$de,pointUV:rue,pointWidth:B0,positionGeometry:i6,positionLocal:a6,positionPrevious:o6,positionView:l6,positionViewDirection:u6,positionWorld:s6,positionWorldDirection:c6,posterize:kue,pow:O4,pow2:k4,pow3:A4,pow4:j4,premult:_ue,property:_0,radians:H2,rand:V4,range:ide,rangeFog:tde,rangeFogFactor:U7,reciprocal:m4,reference:P6,referenceBuffer:F6,reflect:C4,reflectVector:O6,reflectView:E6,reflector:Wle,refract:R4,refractVector:k6,refractView:D6,reinhardToneMapping:Iue,remainder:P2,remap:T3,remapClamp:E3,renderGroup:Z0,renderOutput:k3,rendererReference:p3,rotate:q5,rotateUV:Nle,roughness:x0,round:p4,rtt:v7,sRGBTransferEOTF:s3,sRGBTransferOETF:c3,sampler:Soe,samplerComparison:Coe,saturate:L4,saturation:wue,screen:xue,screenCoordinate:k8,screenSize:O8,screenUV:D8,scriptable:ede,scriptableValue:z7,select:J4,setCurrentStack:H1,shaderStages:K$,shadow:Yde,shadowPositionWorld:a9,shapeCircle:nfe,sharedUniformGroup:Y0,sheen:T0,sheenRoughness:E0,shiftLeft:O2,shiftRight:k2,shininess:I0,sign:s4,sin:e4,sinc:ble,skinning:h8,smoothstep:z4,smoothstepElement:U4,specularColor:P0,specularF90:F0,spherizeUV:Ple,split:p0,spritesheetUV:Rle,sqrt:J2,stack:ule,step:S4,storage:f8,storageBarrier:pde,storageObject:Jse,storageTexture:C7,string:l0,struct:mle,sub:u2,subgroupIndex:zse,subgroupSize:ude,tan:n4,tangentGeometry:L6,tangentLocal:R6,tangentView:z6,tangentWorld:B6,temp:r3,texture:R3,texture3D:due,textureBarrier:mde,textureBicubic:Nce,textureCubeUV:C5,textureLoad:z3,textureSize:P3,textureStore:cue,thickness:U0,time:e7,timerDelta:Ole,timerGlobal:Dle,timerLocal:Ele,toneMapping:m3,toneMappingExposure:h3,toonOutlinePass:Pue,transformDirection:M4,transformNormal:b6,transformNormalToView:x6,transformedBentNormalView:rse,transformedBitangentView:W6,transformedBitangentWorld:tse,transformedClearcoatNormalView:Goe,transformedNormalView:v6,transformedNormalWorld:y6,transformedTangentView:V6,transformedTangentWorld:Zoe,transmission:H0,transpose:_4,triNoise3D:Sle,triplanarTexture:Ble,triplanarTextures:n7,trunc:h4,tslFn:h0,uint:J1,uniform:e2,uniformArray:U3,uniformCubeTexture:Joe,uniformGroup:J0,uniformTexture:xoe,uniforms:Toe,unpremult:vue,userData:pue,uv:N3,uvec2:Z1,uvec3:e0,uvec4:i0,varying:a3,varyingProperty:v0,vec2:Y,vec3:X,vec4:n0,vectorComponents:q$,velocity:hue,vertexColor:J8,vertexIndex:o8,vertexStage:o3,vibrance:Tue,viewZToLogarithmicDepth:V8,viewZToOrthographicDepth:R8,viewZToPerspectiveDepth:z8,viewport:A8,viewportBottomLeft:sce,viewportCoordinate:M8,viewportDepthTexture:I8,viewportLinearDepth:pce,viewportMipTexture:lce,viewportResolution:ace,viewportSafeUV:Ile,viewportSharedTexture:xce,viewportSize:j8,viewportTexture:cce,viewportTopLeft:oce,viewportUV:ice,wgsl:Kue,wgslFn:Xue,workgroupArray:_de,workgroupBarrier:fde,workgroupId:sde,workingToColorSpace:d3,xor:C2}),_pe=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};_pe.isNodeFunctionInput=!0;var vpe=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};vpe.isNodeFunction=!0;const ype={[pY]:`never`,[mY]:`less`,[hY]:`equal`,[gY]:`less-equal`,[_Y]:`greater`,[yY]:`greater-equal`,[bY]:`always`,[vY]:`not-equal`},Z9=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},bpe={[U$.READ_ONLY]:`read`,[U$.WRITE_ONLY]:`write`,[U$.READ_WRITE]:`read_write`},xpe={[IJ]:`repeat`,[LJ]:`clamp`,[RJ]:`mirror`},Spe={vertex:Z9?Z9.VERTEX:1,fragment:Z9?Z9.FRAGMENT:2,compute:Z9?Z9.COMPUTE:4},Q9={tsl_xor:new I7(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new I7(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new I7(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new I7(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new I7(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new I7(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new I7(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new I7(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new I7(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new I7(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new I7(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new I7(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new I7(`
434
+ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
435
+
436
+ let res = vec2f( iRes );
437
+
438
+ let uvScaled = coord * res;
439
+ let uvWrapping = ( ( uvScaled % res ) + res ) % res;
440
+
441
+ // https://www.shadertoy.com/view/WtyXRy
442
+
443
+ let uv = uvWrapping - 0.5;
444
+ let iuv = floor( uv );
445
+ let f = fract( uv );
446
+
447
+ let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
448
+ let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
449
+ let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
450
+ let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
451
+
452
+ return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
453
+
454
+ }
455
+ `)},$9={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(Q9.pow_float=new I7(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),Q9.pow_vec2=new I7(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[Q9.pow_float]),Q9.pow_vec3=new I7(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[Q9.pow_float]),Q9.pow_vec4=new I7(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[Q9.pow_float]),$9.pow_float=`tsl_pow_float`,$9.pow_vec2=`tsl_pow_vec2`,$9.pow_vec3=`tsl_pow_vec3`,$9.pow_vec4=`tsl_pow_vec4`);let Cpe=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Cpe+=`diagnostic( off, derivative_uniformity );
456
+ `);const wpe=$.BRDF_GGX,Tpe=$.BRDF_Lambert,Epe=$.BasicShadowFilter,Dpe=$.Break,Ope=$.Continue,kpe=$.DFGApprox,Ape=$.D_GGX,jpe=$.Discard,Mpe=$.EPSILON,Npe=$.F_Schlick,Ppe=$.Fn,Fpe=$.INFINITY,Ipe=$.If,Lpe=$.Switch,Rpe=$.Loop,zpe=$.NodeShaderStage,Bpe=$.NodeType,Vpe=$.NodeUpdateType,Hpe=$.NodeAccess,Upe=$.PCFShadowFilter,Wpe=$.PCFSoftShadowFilter,Gpe=$.PI,Kpe=$.PI2,qpe=$.Return,Jpe=$.Schlick_to_F0,Ype=$.ScriptableNodeResources,Xpe=$.ShaderNode,Zpe=$.TBNViewMatrix,Qpe=$.VSMShadowFilter,$pe=$.V_GGX_SmithCorrelated,eme=$.abs,tme=$.acesFilmicToneMapping,nme=$.acos,rme=$.add,ime=$.addNodeElement,ame=$.agxToneMapping,ome=$.all,sme=$.alphaT,cme=$.and,lme=$.anisotropy,ume=$.anisotropyB,dme=$.anisotropyT,fme=$.any,pme=$.append,mme=$.array,hme=$.arrayBuffer,gme=$.asin,_me=$.assign,vme=$.atan,yme=$.atan2,bme=$.atomicAdd,xme=$.atomicAnd,Sme=$.atomicFunc,Cme=$.atomicMax,wme=$.atomicMin,Tme=$.atomicOr,Eme=$.atomicStore,Dme=$.atomicSub,Ome=$.atomicXor,kme=$.atomicLoad,Ame=$.attenuationColor,jme=$.attenuationDistance,Mme=$.attribute,Nme=$.attributeArray,Pme=$.backgroundBlurriness,Fme=$.backgroundIntensity,Ime=$.backgroundRotation,Lme=$.batch,Rme=$.billboarding,zme=$.bitAnd,Bme=$.bitNot,Vme=$.bitOr,Hme=$.bitXor,Ume=$.bitangentGeometry,Wme=$.bitangentLocal,Gme=$.bitangentView,Kme=$.bitangentWorld,qme=$.bitcast,Jme=$.blendBurn,Yme=$.blendColor,Xme=$.blendDodge,Zme=$.blendOverlay,Qme=$.blendScreen,$me=$.blur,ehe=$.bool,the=$.buffer,nhe=$.bufferAttribute,rhe=$.bumpMap,ihe=$.burn,ahe=$.bvec2,ohe=$.bvec3,she=$.bvec4,che=$.bypass,lhe=$.cache,uhe=$.call,dhe=$.cameraFar,fhe=$.cameraIndex,phe=$.cameraNear,mhe=$.cameraNormalMatrix,hhe=$.cameraPosition,ghe=$.cameraProjectionMatrix,_he=$.cameraProjectionMatrixInverse,vhe=$.cameraViewMatrix,yhe=$.cameraWorldMatrix,bhe=$.cbrt,xhe=$.cdl,She=$.ceil,Che=$.checker,whe=$.cineonToneMapping,The=$.clamp,Ehe=$.clearcoat,Dhe=$.clearcoatRoughness,Ohe=$.code,khe=$.color,Ahe=$.colorSpaceToWorking,jhe=$.colorToDirection,Mhe=$.compute,Nhe=$.computeSkinning,Phe=$.cond,Fhe=$.Const,Ihe=$.context,Lhe=$.convert,Rhe=$.convertColorSpace,zhe=$.convertToTexture,Bhe=$.cos,Vhe=$.cross,Hhe=$.cubeTexture,Uhe=$.dFdx,Whe=$.dFdy,Ghe=$.dashSize,Khe=$.debug,qhe=$.decrement,Jhe=$.decrementBefore,Yhe=$.defaultBuildStages,Xhe=$.defaultShaderStages,Zhe=$.defined,Qhe=$.degrees,$he=$.deltaTime,ege=$.densityFog,tge=$.densityFogFactor,nge=$.depth,rge=$.depthPass,ige=$.difference,age=$.diffuseColor,oge=$.directPointLight,sge=$.directionToColor,cge=$.dispersion,lge=$.distance,uge=$.div,dge=$.dodge,fge=$.dot,pge=$.drawIndex,mge=$.dynamicBufferAttribute,hge=$.element,gge=$.emissive,_ge=$.equal,vge=$.equals,yge=$.equirectUV,bge=$.exp,xge=$.exp2,Sge=$.expression,Cge=$.faceDirection,wge=$.faceForward,Tge=$.faceforward,Ege=$.float,Dge=$.floor,Oge=$.fog,kge=$.fract,Age=$.frameGroup,jge=$.frameId,Mge=$.frontFacing,Nge=$.fwidth,Pge=$.gain,Fge=$.gapSize,Ige=$.getConstNodeType,Lge=$.getCurrentStack,Rge=$.getDirection,zge=$.getDistanceAttenuation,Bge=$.getGeometryRoughness,Vge=$.getNormalFromDepth,Hge=$.getParallaxCorrectNormal,Uge=$.getRoughness,Wge=$.getScreenPosition,Gge=$.getShIrradianceAt,Kge=$.getTextureIndex,qge=$.getViewPosition,Jge=$.getShadowMaterial,Yge=$.getShadowRenderObjectFunction,Xge=$.glsl,Zge=$.glslFn,Qge=$.grayscale,$ge=$.greaterThan,e_e=$.greaterThanEqual,t_e=$.hash,n_e=$.highpModelNormalViewMatrix,r_e=$.highpModelViewMatrix,i_e=$.hue,a_e=$.increment,o_e=$.incrementBefore,s_e=$.instance,c_e=$.instanceIndex,l_e=$.instancedArray,u_e=$.instancedBufferAttribute,d_e=$.instancedDynamicBufferAttribute,f_e=$.instancedMesh,p_e=$.int,m_e=$.inverseSqrt,h_e=$.inversesqrt,g_e=$.invocationLocalIndex,__e=$.invocationSubgroupIndex,v_e=$.ior,y_e=$.iridescence,b_e=$.iridescenceIOR,x_e=$.iridescenceThickness,S_e=$.ivec2,C_e=$.ivec3,w_e=$.ivec4,T_e=$.js,E_e=$.label,D_e=$.length,O_e=$.lengthSq,k_e=$.lessThan,A_e=$.lessThanEqual,j_e=$.lightPosition,M_e=$.lightShadowMatrix,N_e=$.lightTargetDirection,P_e=$.lightTargetPosition,F_e=$.lightViewPosition,I_e=$.lightingContext,L_e=$.lights,R_e=$.linearDepth,z_e=$.linearToneMapping,B_e=$.localId,V_e=$.globalId,H_e=$.log,U_e=$.log2,W_e=$.logarithmicDepthToViewZ,G_e=$.loop,K_e=$.luminance,q_e=$.mediumpModelViewMatrix,J_e=$.mat2,Y_e=$.mat3,X_e=$.mat4,Z_e=$.matcapUV,Q_e=$.materialAO,$_e=$.materialAlphaTest,eve=$.materialAnisotropy,tve=$.materialAnisotropyVector,nve=$.materialAttenuationColor,rve=$.materialAttenuationDistance,ive=$.materialClearcoat,ave=$.materialClearcoatNormal,ove=$.materialClearcoatRoughness,sve=$.materialColor,cve=$.materialDispersion,lve=$.materialEmissive,uve=$.materialIOR,dve=$.materialIridescence,fve=$.materialIridescenceIOR,pve=$.materialIridescenceThickness,mve=$.materialLightMap,hve=$.materialLineDashOffset,gve=$.materialLineDashSize,_ve=$.materialLineGapSize,vve=$.materialLineScale,yve=$.materialLineWidth,bve=$.materialMetalness,xve=$.materialNormal,Sve=$.materialOpacity,Cve=$.materialPointSize,wve=$.materialReference,Tve=$.materialReflectivity,Eve=$.materialRefractionRatio,Dve=$.materialRotation,Ove=$.materialRoughness,kve=$.materialSheen,Ave=$.materialSheenRoughness,jve=$.materialShininess,Mve=$.materialSpecular,Nve=$.materialSpecularColor,Pve=$.materialSpecularIntensity,Fve=$.materialSpecularStrength,Ive=$.materialThickness,Lve=$.materialTransmission,Rve=$.max,zve=$.maxMipLevel,Bve=$.metalness,Vve=$.min,Hve=$.mix,Uve=$.mixElement,Wve=$.mod,Gve=$.modInt,Kve=$.modelDirection,qve=$.modelNormalMatrix,Jve=$.modelPosition,Yve=$.modelRadius,Xve=$.modelScale,Zve=$.modelViewMatrix,Qve=$.modelViewPosition,$ve=$.modelViewProjection,eye=$.modelWorldMatrix,tye=$.modelWorldMatrixInverse,nye=$.morphReference,rye=$.mrt,iye=$.mul,aye=$.mx_aastep,oye=$.mx_cell_noise_float,sye=$.mx_contrast,cye=$.mx_fractal_noise_float,lye=$.mx_fractal_noise_vec2,uye=$.mx_fractal_noise_vec3,dye=$.mx_fractal_noise_vec4,fye=$.mx_hsvtorgb,pye=$.mx_noise_float,mye=$.mx_noise_vec3,hye=$.mx_noise_vec4,gye=$.mx_ramplr,_ye=$.mx_ramptb,vye=$.mx_rgbtohsv,yye=$.mx_safepower,bye=$.mx_splitlr,xye=$.mx_splittb,Sye=$.mx_srgb_texture_to_lin_rec709,Cye=$.mx_transform_uv,wye=$.mx_worley_noise_float,Tye=$.mx_worley_noise_vec2,Eye=$.mx_worley_noise_vec3,Dye=$.namespace,Oye=$.negate,kye=$.neutralToneMapping,Aye=$.nodeArray,jye=$.nodeImmutable,Mye=$.nodeObject,Nye=$.nodeObjects,Pye=$.nodeProxy,Fye=$.normalFlat,Iye=$.normalGeometry,Lye=$.normalLocal,Rye=$.normalMap,zye=$.normalView,Bye=$.normalWorld,Vye=$.normalize,Hye=$.not,Uye=$.notEqual,Wye=$.numWorkgroups,Gye=$.objectDirection,Kye=$.objectGroup,qye=$.objectPosition,Jye=$.objectRadius,Yye=$.objectScale,Xye=$.objectViewPosition,Zye=$.objectWorldMatrix,Qye=$.oneMinus,$ye=$.or,ebe=$.orthographicDepthToViewZ,tbe=$.oscSawtooth,nbe=$.oscSine,rbe=$.oscSquare,ibe=$.oscTriangle,abe=$.output,obe=$.outputStruct,sbe=$.overlay,cbe=$.overloadingFn,lbe=$.parabola,ube=$.parallaxDirection,dbe=$.parallaxUV,fbe=$.parameter,pbe=$.pass,mbe=$.passTexture,hbe=$.pcurve,gbe=$.perspectiveDepthToViewZ,_be=$.pmremTexture,vbe=$.pointUV,ybe=$.pointWidth,bbe=$.positionGeometry,xbe=$.positionLocal,Sbe=$.positionPrevious,Cbe=$.positionView,wbe=$.positionViewDirection,Tbe=$.positionWorld,Ebe=$.positionWorldDirection,Dbe=$.posterize,Obe=$.pow,kbe=$.pow2,Abe=$.pow3,jbe=$.pow4,Mbe=$.premult,Nbe=$.property,Pbe=$.radians,Fbe=$.rand,Ibe=$.range,Lbe=$.rangeFog,Rbe=$.rangeFogFactor,zbe=$.reciprocal,Bbe=$.lightProjectionUV,Vbe=$.reference,Hbe=$.referenceBuffer,Ube=$.reflect,Wbe=$.reflectVector,Gbe=$.reflectView,Kbe=$.reflector,qbe=$.refract,Jbe=$.refractVector,Ybe=$.refractView,Xbe=$.reinhardToneMapping,Zbe=$.remainder,Qbe=$.remap,$be=$.remapClamp,exe=$.renderGroup,txe=$.renderOutput,nxe=$.rendererReference,rxe=$.rotate,ixe=$.rotateUV,axe=$.roughness,oxe=$.round,sxe=$.rtt,cxe=$.sRGBTransferEOTF,lxe=$.sRGBTransferOETF,uxe=$.sampler,dxe=$.samplerComparison,fxe=$.saturate,pxe=$.saturation,mxe=$.screen,hxe=$.screenCoordinate,gxe=$.screenSize,_xe=$.screenUV,vxe=$.scriptable,yxe=$.scriptableValue,bxe=$.select,xxe=$.setCurrentStack,Sxe=$.shaderStages,Cxe=$.shadow,wxe=$.pointShadow,Txe=$.shadowPositionWorld,Exe=$.sharedUniformGroup,Dxe=$.shapeCircle,Oxe=$.sheen,kxe=$.sheenRoughness,Axe=$.shiftLeft,jxe=$.shiftRight,Mxe=$.shininess,Nxe=$.sign,Pxe=$.sin,Fxe=$.sinc,Ixe=$.skinning,Lxe=$.smoothstep,Rxe=$.smoothstepElement,zxe=$.specularColor,Bxe=$.specularF90,Vxe=$.spherizeUV,Hxe=$.split,Uxe=$.spritesheetUV,Wxe=$.sqrt,Gxe=$.stack,Kxe=$.step,qxe=$.storage,Jxe=$.storageBarrier,Yxe=$.storageObject,Xxe=$.storageTexture,Zxe=$.string,Qxe=$.struct,$xe=$.sub,eSe=$.subgroupIndex,tSe=$.subgroupSize,nSe=$.tan,rSe=$.tangentGeometry,iSe=$.tangentLocal,aSe=$.tangentView,oSe=$.tangentWorld,sSe=$.temp,cSe=$.texture,lSe=$.texture3D,uSe=$.textureBarrier,dSe=$.textureBicubic,fSe=$.textureCubeUV,pSe=$.textureLoad,mSe=$.textureSize,hSe=$.textureStore,gSe=$.thickness,_Se=$.time,vSe=$.timerDelta,ySe=$.timerGlobal,bSe=$.timerLocal,xSe=$.toneMapping,SSe=$.toneMappingExposure,CSe=$.toonOutlinePass,wSe=$.transformDirection,TSe=$.transformNormal,ESe=$.transformNormalToView,DSe=$.transformedBentNormalView,OSe=$.transformedBitangentView,kSe=$.transformedBitangentWorld,ASe=$.transformedClearcoatNormalView,jSe=$.transformedNormalView,MSe=$.transformedNormalWorld,NSe=$.transformedTangentView,PSe=$.transformedTangentWorld,FSe=$.transmission,ISe=$.transpose,LSe=$.triNoise3D,RSe=$.triplanarTexture,zSe=$.triplanarTextures,BSe=$.trunc,VSe=$.tslFn,HSe=$.uint,USe=$.uniform,WSe=$.uniformCubeTexture,GSe=$.uniformArray,KSe=$.uniformGroup,qSe=$.uniformTexture,JSe=$.uniforms,YSe=$.unpremult,XSe=$.userData,ZSe=$.uv,QSe=$.uvec2,$Se=$.uvec3,eCe=$.uvec4,tCe=$.Var,nCe=$.varying,rCe=$.varyingProperty,iCe=$.vec2,aCe=$.vec3,oCe=$.vec4,sCe=$.vectorComponents,cCe=$.velocity,lCe=$.vertexColor,uCe=$.vertexIndex,dCe=$.vibrance,fCe=$.viewZToLogarithmicDepth,pCe=$.viewZToOrthographicDepth,mCe=$.viewZToPerspectiveDepth,hCe=$.viewport,gCe=$.viewportBottomLeft,_Ce=$.viewportCoordinate,vCe=$.viewportDepthTexture,yCe=$.viewportLinearDepth,bCe=$.viewportMipTexture,xCe=$.viewportResolution,SCe=$.viewportSafeUV,CCe=$.viewportSharedTexture,wCe=$.viewportSize,TCe=$.viewportTexture,ECe=$.viewportTopLeft,DCe=$.viewportUV,OCe=$.wgsl,kCe=$.wgslFn,ACe=$.workgroupArray,jCe=$.workgroupBarrier,MCe=$.workgroupId,NCe=$.workingToColorSpace,PCe=$.xor;var FCe=r({__name:`Ombre`,props:{hideNotice:{type:Boolean,default:!1}},setup(e){let r=e,i=f(null),a=f(`ombre-root-`+Math.random().toString(36).substring(7)),o=f(uI());return d(`ombreParentId`,a.value),d(`ombreNodeRegister`,(e,t,n,r,i=null)=>{o.value.registerNode(e,t,n,r,i)}),d(`ombreUniformUpdate`,(e,t,n)=>{o.value.updateUniformValue(e,t,n)}),d(`ombreMetadataUpdate`,(e,t)=>{o.value.updateNodeMetadata(e,t)}),l(async()=>{i.value&&(o.value.registerNode(a.value,({childNode:e})=>e||oCe(0,0,0,0),null,null,{}),await o.value.initialize({canvas:i.value}),r.hideNotice||o.value.showLicenseWarning())}),c(()=>{o.value.cleanup()}),(e,r)=>(u(),t(`div`,null,[n(`canvas`,s({"data-renderer":`ombre`,ref_key:`canvasRef`,ref:i,style:{...e.$attrs.class?{}:{width:`1200px`,height:`800px`},...typeof e.$attrs.style==`object`?e.$attrs.style:{}}},e.$attrs),null,16),p(e.$slots,`default`)]))}}),ICe=FCe;export{RV as Circle,HV as GlassTiles,Kq as Grayscale,Yq as HueShift,Qq as Invert,tJ as LinearGradient,ICe as Ombre,oJ as Posterize,lJ as Saturation,fJ as SolidColor,hJ as Twirl,vJ as Vibrance};