shaders 2.0.0-alpha.6 → 2.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.cjs +22 -22
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +2460 -2460
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.js +18 -18
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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() {
|
|
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,Tn=34056,En=5386,Dn=512,On=513,kn=514,An=515,jn=516,Mn=517,Nn=518,Pn=519,Fn=512,In=513,Ln=514,Rn=515,zn=516,Bn=517,Vn=518,Hn=519,Un=35044,Wn=35048,Gn=2e3,Kn=2001;var qn=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 Jn=`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 Yn=1234567;const Xn=Math.PI/180,Zn=180/Math.PI;function Qn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=Jn[e&255]+Jn[e>>8&255]+Jn[e>>16&255]+Jn[e>>24&255]+`-`+Jn[t&255]+Jn[t>>8&255]+`-`+Jn[t>>16&15|64]+Jn[t>>24&255]+`-`+Jn[n&63|128]+Jn[n>>8&255]+`-`+Jn[n>>16&255]+Jn[n>>24&255]+Jn[r&255]+Jn[r>>8&255]+Jn[r>>16&255]+Jn[r>>24&255];return i.toLowerCase()}function $n(e,t,n){return Math.max(t,Math.min(n,e))}function er(e,t){return(e%t+t)%t}function tr(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function nr(e,t,n){return e===t?0:(n-e)/(t-e)}function rr(e,t,n){return(1-n)*e+n*t}function ir(e,t,n,r){return rr(e,t,1-Math.exp(-n*r))}function ar(e,t=1){return t-Math.abs(er(e,t*2)-t)}function or(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function tee(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function nee(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ree(e,t){return e+Math.random()*(t-e)}function iee(e){return e*(.5-Math.random())}function aee(e){e!==void 0&&(Yn=e);let t=Yn+=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 oee(e){return e*Xn}function see(e){return e*Zn}function cee(e){return(e&e-1)==0&&e!==0}function lee(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function uee(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function dee(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 sr(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 cr(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 lr={DEG2RAD:Xn,RAD2DEG:Zn,generateUUID:Qn,clamp:$n,euclideanModulo:er,mapLinear:tr,inverseLerp:nr,lerp:rr,damp:ir,pingpong:ar,smoothstep:or,smootherstep:tee,randInt:nee,randFloat:ree,randFloatSpread:iee,seededRandom:aee,degToRad:oee,radToDeg:see,isPowerOfTwo:cee,ceilPowerOfTwo:lee,floorPowerOfTwo:uee,setQuaternionFromProperEuler:dee,normalize:cr,denormalize:sr};var ur=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=$n(this.x,e.x,t.x),this.y=$n(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$n(this.x,e,t),this.y=$n(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($n(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($n(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}},dr=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($n(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(pr.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(pr.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=$n(this.x,e.x,t.x),this.y=$n(this.y,e.y,t.y),this.z=$n(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$n(this.x,e,t),this.y=$n(this.y,e,t),this.z=$n(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($n(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 fr.copy(this).projectOnVector(e),this.sub(fr)}reflect(e){return this.sub(fr.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($n(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 fr=new C,pr=new dr;var mr=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(hr.makeScale(e,t)),this}rotate(e){return this.premultiply(hr.makeRotation(-e)),this}translate(e,t){return this.premultiply(hr.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 hr=new mr;function gr(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function _r(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function vr(){let e=_r(`canvas`);return e.style.display=`block`,e}const yr={};function br(e){e in yr||(yr[e]=!0,console.warn(e))}const xr=new mr().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sr=new mr().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cr(){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=Tr(e.r),e.g=Tr(e.g),e.b=Tr(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=Er(e.r),e.g=Er(e.g),e.b=Er(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 br(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return br(`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:xr,fromXYZ:Sr,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:t,whitePoint:r,transfer:vn,toXYZ:xr,fromXYZ:Sr,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}}),e}const wr=Cr();function Tr(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Er(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let Dr;var Or=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{Dr===void 0&&(Dr=_r(`canvas`)),Dr.width=e.width,Dr.height=e.height;let t=Dr.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Dr}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=_r(`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]=Tr(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(Tr(t[e]/255)*255):t[e]=Tr(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 kr=0;var Ar=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:kr++}),this.uuid=Qn(),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(jr(r[t].image)):e.push(jr(r[t]))}else e=jr(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function jr(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Or.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 Mr=0;const Nr=new C;var Pr=class e extends qn{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:Mr++}),this.uuid=Qn(),this.name=``,this.source=new Ar(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 ur(0,0),this.repeat=new ur(1,1),this.center=new ur(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new mr,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(Nr).x}get height(){return this.source.getSize(Nr).y}get depth(){return this.source.getSize(Nr).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++}};Pr.DEFAULT_IMAGE=null,Pr.DEFAULT_MAPPING=Ge,Pr.DEFAULT_ANISOTROPY=1;var Fr=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=$n(this.x,e.x,t.x),this.y=$n(this.y,e.y,t.y),this.z=$n(this.z,e.z,t.z),this.w=$n(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$n(this.x,e,t),this.y=$n(this.y,e,t),this.z=$n(this.z,e,t),this.w=$n(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($n(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}},Ir=class extends qn{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 Fr(0,0,e,t),this.scissorTest=!1,this.viewport=new Fr(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new Pr(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 Ar(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`})}},Lr=class extends Ir{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Rr=class extends Pr{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()}},zr=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(Vr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Vr.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=Vr.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,Vr):Vr.fromBufferAttribute(r,t),Vr.applyMatrix4(e.matrixWorld),this.expandByPoint(Vr);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),Hr.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),Hr.copy(e.boundingBox)),Hr.applyMatrix4(e.matrixWorld),this.union(Hr)}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,Vr),Vr.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(Yr),Xr.subVectors(this.max,Yr),Ur.subVectors(e.a,Yr),Wr.subVectors(e.b,Yr),Gr.subVectors(e.c,Yr),Kr.subVectors(Wr,Ur),qr.subVectors(Gr,Wr),Jr.subVectors(Ur,Gr);let t=[0,-Kr.z,Kr.y,0,-qr.z,qr.y,0,-Jr.z,Jr.y,Kr.z,0,-Kr.x,qr.z,0,-qr.x,Jr.z,0,-Jr.x,-Kr.y,Kr.x,0,-qr.y,qr.x,0,-Jr.y,Jr.x,0];return!$r(t,Ur,Wr,Gr,Xr)||(t=[1,0,0,0,1,0,0,0,1],!$r(t,Ur,Wr,Gr,Xr))?!1:(Zr.crossVectors(Kr,qr),t=[Zr.x,Zr.y,Zr.z],$r(t,Ur,Wr,Gr,Xr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Vr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Vr).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:(Br[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Br[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Br[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Br[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Br[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Br[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Br[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Br[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Br),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 Br=[new C,new C,new C,new C,new C,new C,new C,new C],Vr=new C,Hr=new zr,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,Qr=new C;function $r(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Qr.fromArray(e,a);let o=i.x*Math.abs(Qr.x)+i.y*Math.abs(Qr.y)+i.z*Math.abs(Qr.z),s=t.dot(Qr),c=n.dot(Qr),l=r.dot(Qr);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const ei=new zr,ti=new C,ni=new C;var ri=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?ei.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;ti.subVectors(e,this.center);let t=ti.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(ti,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):(ni.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ti.copy(e.center).add(ni)),this.expandByPoint(ti.copy(e.center).sub(ni))),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 ii=new C,ai=new C,oi=new C,si=new C,ci=new C,li=new C,ui=new C;var di=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,ii)),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=ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ii.copy(this.origin).addScaledVector(this.direction,t),ii.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){ai.copy(e).add(t).multiplyScalar(.5),oi.copy(t).sub(e).normalize(),si.copy(this.origin).sub(ai);let i=e.distanceTo(t)*.5,a=-this.direction.dot(oi),o=si.dot(this.direction),s=-si.dot(oi),c=si.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(ai).addScaledVector(oi,d),f}intersectSphere(e,t){ii.subVectors(e.center,this.origin);let n=ii.dot(this.direction),r=ii.dot(ii)-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,ii)!==null}intersectTriangle(e,t,n,r,i){ci.subVectors(t,e),li.subVectors(n,e),ui.crossVectors(ci,li);let a=this.direction.dot(ui),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;si.subVectors(this.origin,e);let s=o*this.direction.dot(li.crossVectors(si,li));if(s<0)return null;let c=o*this.direction.dot(ci.cross(si));if(c<0||s+c>a)return null;let l=-o*si.dot(ui);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)}},fi=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/pi.setFromMatrixColumn(e,0).length(),i=1/pi.setFromMatrixColumn(e,1).length(),a=1/pi.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(hi,e,gi)}lookAt(e,t,n){let r=this.elements;return yi.subVectors(e,t),yi.lengthSq()===0&&(yi.z=1),yi.normalize(),_i.crossVectors(n,yi),_i.lengthSq()===0&&(Math.abs(n.z)===1?yi.x+=1e-4:yi.z+=1e-4,yi.normalize(),_i.crossVectors(n,yi)),_i.normalize(),vi.crossVectors(yi,_i),r[0]=_i.x,r[4]=vi.x,r[8]=yi.x,r[1]=_i.y,r[5]=vi.y,r[9]=yi.y,r[2]=_i.z,r[6]=vi.z,r[10]=yi.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=pi.set(r[0],r[1],r[2]).length(),a=pi.set(r[4],r[5],r[6]).length(),o=pi.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],mi.copy(this);let c=1/i,l=1/a,u=1/o;return mi.elements[0]*=c,mi.elements[1]*=c,mi.elements[2]*=c,mi.elements[4]*=l,mi.elements[5]*=l,mi.elements[6]*=l,mi.elements[8]*=u,mi.elements[9]*=u,mi.elements[10]*=u,t.setFromRotationMatrix(mi),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Gn){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===Gn)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===Kn)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=Gn){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===Gn)p=(a+i)*u,m=-2*u;else if(o===Kn)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 pi=new C,mi=new fi,hi=new C(0,0,0),gi=new C(1,1,1),_i=new C,vi=new C,yi=new C,bi=new fi,xi=new dr;var Si=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($n(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(-$n(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($n(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(-$n(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($n(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(-$n(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 bi.makeRotationFromQuaternion(e),this.setFromRotationMatrix(bi,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xi.setFromEuler(this),this.setFromQuaternion(xi,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}};Si.DEFAULT_ORDER=`XYZ`;var Ci=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 wi=0;const Ti=new C,Ei=new dr,Di=new fi,Oi=new C,ki=new C,Ai=new C,ji=new dr,Mi=new C(1,0,0),Ni=new C(0,1,0),Pi=new C(0,0,1),Fi={type:`added`},Ii={type:`removed`},Li={type:`childadded`,child:null},Ri={type:`childremoved`,child:null};var zi=class e extends qn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:wi++}),this.uuid=Qn(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new C,n=new Si,r=new dr,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 fi},normalMatrix:{value:new mr}}),this.matrix=new fi,this.matrixWorld=new fi,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ci,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 Ei.setFromAxisAngle(e,t),this.quaternion.multiply(Ei),this}rotateOnWorldAxis(e,t){return Ei.setFromAxisAngle(e,t),this.quaternion.premultiply(Ei),this}rotateX(e){return this.rotateOnAxis(Mi,e)}rotateY(e){return this.rotateOnAxis(Ni,e)}rotateZ(e){return this.rotateOnAxis(Pi,e)}translateOnAxis(e,t){return Ti.copy(e).applyQuaternion(this.quaternion),this.position.add(Ti.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Mi,e)}translateY(e){return this.translateOnAxis(Ni,e)}translateZ(e){return this.translateOnAxis(Pi,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Di.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Oi.copy(e):Oi.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),ki.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Di.lookAt(ki,Oi,this.up):Di.lookAt(Oi,ki,this.up),this.quaternion.setFromRotationMatrix(Di),r&&(Di.extractRotation(r.matrixWorld),Ei.setFromRotationMatrix(Di),this.quaternion.premultiply(Ei.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(Fi),Li.child=e,this.dispatchEvent(Li),Li.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(Ii),Ri.child=e,this.dispatchEvent(Ri),Ri.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),Di.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Di.multiply(e.parent.matrixWorld)),e.applyMatrix4(Di),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Fi),Li.child=e,this.dispatchEvent(Li),Li.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(ki,e,Ai),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ki,ji,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}};zi.DEFAULT_UP=new C(0,1,0),zi.DEFAULT_MATRIX_AUTO_UPDATE=!0,zi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const 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 C,Xi=new Fr,Zi=new Fr,Qi=new Fr;var $i=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),Bi.subVectors(e,t),r.cross(Bi);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){Bi.subVectors(r,t),Vi.subVectors(n,t),Hi.subVectors(e,t);let a=Bi.dot(Bi),o=Bi.dot(Vi),s=Bi.dot(Hi),c=Vi.dot(Vi),l=Vi.dot(Hi),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,Ui)===null?!1:Ui.x>=0&&Ui.y>=0&&Ui.x+Ui.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Ui)===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,Ui.x),s.addScaledVector(a,Ui.y),s.addScaledVector(o,Ui.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Xi.setScalar(0),Zi.setScalar(0),Qi.setScalar(0),Xi.fromBufferAttribute(e,t),Zi.fromBufferAttribute(e,n),Qi.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Xi,i.x),a.addScaledVector(Zi,i.y),a.addScaledVector(Qi,i.z),a}static isFrontFacing(e,t,n,r){return Bi.subVectors(n,t),Vi.subVectors(e,t),Bi.cross(Vi).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 Bi.subVectors(this.c,this.b),Vi.subVectors(this.a,this.b),Bi.cross(Vi).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;Wi.subVectors(r,n),Gi.subVectors(i,n),qi.subVectors(e,n);let s=Wi.dot(qi),c=Gi.dot(qi);if(s<=0&&c<=0)return t.copy(n);Ji.subVectors(e,r);let l=Wi.dot(Ji),u=Gi.dot(Ji);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(Wi,a);Yi.subVectors(e,i);let f=Wi.dot(Yi),p=Gi.dot(Yi);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(Gi,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ki.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ki,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Wi,a).addScaledVector(Gi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const ea={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},ta={h:0,s:0,l:0},na={h:0,s:0,l:0};function ra(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 ia=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,wr.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=wr.workingColorSpace){return this.r=e,this.g=t,this.b=n,wr.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=wr.workingColorSpace){if(e=er(e,1),t=$n(t,0,1),n=$n(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=ra(i,r,e+1/3),this.g=ra(i,r,e),this.b=ra(i,r,e-1/3)}return wr.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=ea[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=Tr(e.r),this.g=Tr(e.g),this.b=Tr(e.b),this}copyLinearToSRGB(e){return this.r=Er(e.r),this.g=Er(e.g),this.b=Er(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hn){return wr.workingToColorSpace(aa.copy(this),e),Math.round($n(aa.r*255,0,255))*65536+Math.round($n(aa.g*255,0,255))*256+Math.round($n(aa.b*255,0,255))}getHexString(e=hn){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=wr.workingColorSpace){wr.workingToColorSpace(aa.copy(this),t);let n=aa.r,r=aa.g,i=aa.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=wr.workingColorSpace){return wr.workingToColorSpace(aa.copy(this),t),e.r=aa.r,e.g=aa.g,e.b=aa.b,e}getStyle(e=hn){wr.workingToColorSpace(aa.copy(this),e);let t=aa.r,n=aa.g,r=aa.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(ta),this.setHSL(ta.h+e,ta.s+t,ta.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(ta),e.getHSL(na);let n=rr(ta.h,na.h,t),r=rr(ta.s,na.s,t),i=rr(ta.l,na.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 aa=new ia;ia.NAMES=ea;let fee=0;var oa=class extends qn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:fee++}),this.uuid=Qn(),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 ia(0,0,0),this.blendAlpha=0,this.depthFunc=Ae,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Pn,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!==Pn&&(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++}},sa=class extends oa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new ia(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 Si,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 ca=pee();function pee(){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 la(e){Math.abs(e)>65504&&console.warn(`THREE.DataUtils.toHalfFloat(): Value out of range.`),e=$n(e,-65504,65504),ca.floatView[0]=e;let t=ca.uint32View[0],n=t>>23&511;return ca.baseTable[n]+((t&8388607)>>ca.shiftTable[n])}function ua(e){let t=e>>10;return ca.uint32View[0]=ca.mantissaTable[ca.offsetTable[t]+(e&1023)]+ca.exponentTable[t],ca.floatView[0]}const da=new C,fa=new ur;let mee=0;var pa=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:mee++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Un,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++)fa.fromBufferAttribute(this,t),fa.applyMatrix3(e),this.setXY(t,fa.x,fa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)da.fromBufferAttribute(this,t),da.applyMatrix3(e),this.setXYZ(t,da.x,da.y,da.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)da.fromBufferAttribute(this,t),da.applyMatrix4(e),this.setXYZ(t,da.x,da.y,da.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)da.fromBufferAttribute(this,t),da.applyNormalMatrix(e),this.setXYZ(t,da.x,da.y,da.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)da.fromBufferAttribute(this,t),da.transformDirection(e),this.setXYZ(t,da.x,da.y,da.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=sr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=sr(t,this.array)),t}setX(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=sr(t,this.array)),t}setY(e,t){return this.normalized&&(t=cr(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=sr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cr(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=sr(t,this.array)),t}setW(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cr(t,this.array),n=cr(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=cr(t,this.array),n=cr(n,this.array),r=cr(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=cr(t,this.array),n=cr(n,this.array),r=cr(r,this.array),i=cr(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!==Un&&(e.usage=this.usage),e}},ma=class extends pa{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ha=class extends pa{constructor(e,t,n){super(new Uint32Array(e),t,n)}},ga=class extends pa{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=ua(this.array[e*this.itemSize]);return this.normalized&&(t=sr(t,this.array)),t}setX(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize]=la(t),this}getY(e){let t=ua(this.array[e*this.itemSize+1]);return this.normalized&&(t=sr(t,this.array)),t}setY(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize+1]=la(t),this}getZ(e){let t=ua(this.array[e*this.itemSize+2]);return this.normalized&&(t=sr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize+2]=la(t),this}getW(e){let t=ua(this.array[e*this.itemSize+3]);return this.normalized&&(t=sr(t,this.array)),t}setW(e,t){return this.normalized&&(t=cr(t,this.array)),this.array[e*this.itemSize+3]=la(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cr(t,this.array),n=cr(n,this.array)),this.array[e+0]=la(t),this.array[e+1]=la(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=cr(t,this.array),n=cr(n,this.array),r=cr(r,this.array)),this.array[e+0]=la(t),this.array[e+1]=la(n),this.array[e+2]=la(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=cr(t,this.array),n=cr(n,this.array),r=cr(r,this.array),i=cr(i,this.array)),this.array[e+0]=la(t),this.array[e+1]=la(n),this.array[e+2]=la(r),this.array[e+3]=la(i),this}},_a=class extends pa{constructor(e,t,n){super(new Float32Array(e),t,n)}};let va=0;const ya=new fi,ba=new zi,xa=new C,Sa=new zr,Ca=new zr,wa=new C;var Ta=class e extends qn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:va++}),this.uuid=Qn(),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(gr(e)?ha:ma)(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 mr().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 ya.makeRotationFromQuaternion(e),this.applyMatrix4(ya),this}rotateX(e){return ya.makeRotationX(e),this.applyMatrix4(ya),this}rotateY(e){return ya.makeRotationY(e),this.applyMatrix4(ya),this}rotateZ(e){return ya.makeRotationZ(e),this.applyMatrix4(ya),this}translate(e,t,n){return ya.makeTranslation(e,t,n),this.applyMatrix4(ya),this}scale(e,t,n){return ya.makeScale(e,t,n),this.applyMatrix4(ya),this}lookAt(e){return ba.lookAt(e),ba.updateMatrix(),this.applyMatrix4(ba.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xa).negate(),this.translate(xa.x,xa.y,xa.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 _a(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 zr);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];Sa.setFromBufferAttribute(n),this.morphTargetsRelative?(wa.addVectors(this.boundingBox.min,Sa.min),this.boundingBox.expandByPoint(wa),wa.addVectors(this.boundingBox.max,Sa.max),this.boundingBox.expandByPoint(wa)):(this.boundingBox.expandByPoint(Sa.min),this.boundingBox.expandByPoint(Sa.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 ri);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(Sa.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ca.setFromBufferAttribute(n),this.morphTargetsRelative?(wa.addVectors(Sa.min,Ca.min),Sa.expandByPoint(wa),wa.addVectors(Sa.max,Ca.max),Sa.expandByPoint(wa)):(Sa.expandByPoint(Ca.min),Sa.expandByPoint(Ca.max))}Sa.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)wa.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(wa));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++)wa.fromBufferAttribute(a,t),o&&(xa.fromBufferAttribute(e,t),wa.add(xa)),r=Math.max(r,n.distanceToSquared(wa))}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 pa(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 ur,f=new ur,p=new ur,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 pa(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++)wa.fromBufferAttribute(e,t),wa.normalize(),e.setXYZ(t,wa.x,wa.y,wa.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 pa(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 Ea=new fi,Da=new di,Oa=new ri,ka=new C,Aa=new C,ja=new C,Ma=new C,Na=new C,Pa=new C,Fa=new C,Ia=new C;var La=class extends zi{constructor(e=new Ta,t=new sa){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){Pa.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(Na.fromBufferAttribute(s,e),a?Pa.addScaledVector(Na,r):Pa.addScaledVector(Na.sub(t),r))}t.add(Pa)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Oa.copy(n.boundingSphere),Oa.applyMatrix4(i),Da.copy(e.ray).recast(e.near),!(Oa.containsPoint(Da.origin)===!1&&(Da.intersectSphere(Oa,ka)===null||Da.origin.distanceToSquared(ka)>(e.far-e.near)**2))&&(Ea.copy(i).invert(),Da.copy(e.ray).applyMatrix4(Ea),!(n.boundingBox!==null&&Da.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Da)))}_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=za(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=za(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=za(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=za(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function Ra(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;Ia.copy(s),Ia.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Ia);return l<n.near||l>n.far?null:{distance:l,point:Ia.clone(),object:e}}function za(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Aa),e.getVertexPosition(c,ja),e.getVertexPosition(l,Ma);let u=Ra(e,t,n,r,Aa,ja,Ma,Fa);if(u){let e=new C;$i.getBarycoord(Fa,Aa,ja,Ma,e),i&&(u.uv=$i.getInterpolatedAttribute(i,s,c,l,e,new ur)),a&&(u.uv1=$i.getInterpolatedAttribute(a,s,c,l,e,new ur)),o&&(u.normal=$i.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};$i.getNormal(Aa,ja,Ma,t.normal),u.face=t,u.barycoord=e}return u}var Ba=class e extends Ta{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 _a(c,3)),this.setAttribute(`normal`,new _a(l,3)),this.setAttribute(`uv`,new _a(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 Va(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 Ha(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}var Ua=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
-
}`,
|
|
3
|
+
}`,Wa=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
-
}`,
|
|
5
|
+
}`,Ga=class extends oa{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ua,this.fragmentShader=Wa,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Va(e.uniforms),this.uniformsGroups=Ha(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}},Ka=class extends zi{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new fi,this.projectionMatrix=new fi,this.projectionMatrixInverse=new fi,this.coordinateSystem=Gn}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 qa=new C,Ja=new ur,Ya=new ur;var Xa=class extends Ka{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=Zn*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Xn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Zn*2*Math.atan(Math.tan(Xn*.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){qa.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(qa.x,qa.y).multiplyScalar(-e/qa.z),qa.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(qa.x,qa.y).multiplyScalar(-e/qa.z)}getViewSize(e,t){return this.getViewBounds(e,Ja,Ya),t.subVectors(Ya,Ja)}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(Xn*.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 Za=-90,Qa=1;var $a=class extends zi{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Xa(Za,Qa,e,t);r.layers=this.layers,this.add(r);let i=new Xa(Za,Qa,e,t);i.layers=this.layers,this.add(i);let a=new Xa(Za,Qa,e,t);a.layers=this.layers,this.add(a);let o=new Xa(Za,Qa,e,t);o.layers=this.layers,this.add(o);let s=new Xa(Za,Qa,e,t);s.layers=this.layers,this.add(s);let c=new Xa(Za,Qa,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===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 if(e===Kn)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}},eo=class extends Pr{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}},to=class extends Lr{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 eo(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
6
|
|
|
7
7
|
varying vec3 vWorldDirection;
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ import{computed as e,createElementBlock as t,createElementVNode as n,defineCompo
|
|
|
37
37
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
38
|
|
|
39
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 wee=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 pu=E(wee).setParameterLength(2);w(`assign`,pu);var mu=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 hu=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?il(t):rl(t[0]),T(new mu(T(e),t)));w(`call`,hu);const gu={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var _u=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(gu[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 vu=E(_u,`+`).setParameterLength(2,1/0).setName(`add`),yu=E(_u,`-`).setParameterLength(2,1/0).setName(`sub`),bu=E(_u,`*`).setParameterLength(2,1/0).setName(`mul`),xu=E(_u,`/`).setParameterLength(2,1/0).setName(`div`),Su=E(_u,`%`).setParameterLength(2).setName(`mod`),Cu=E(_u,`==`).setParameterLength(2).setName(`equal`),wu=E(_u,`!=`).setParameterLength(2).setName(`notEqual`),Tu=E(_u,`<`).setParameterLength(2).setName(`lessThan`),Eu=E(_u,`>`).setParameterLength(2).setName(`greaterThan`),Du=E(_u,`<=`).setParameterLength(2).setName(`lessThanEqual`),Ou=E(_u,`>=`).setParameterLength(2).setName(`greaterThanEqual`),ku=E(_u,`&&`).setParameterLength(2,1/0).setName(`and`),Au=E(_u,`||`).setParameterLength(2,1/0).setName(`or`),ju=E(_u,`!`).setParameterLength(1).setName(`not`),Mu=E(_u,`^^`).setParameterLength(2).setName(`xor`),Nu=E(_u,`&`).setParameterLength(2).setName(`bitAnd`),Pu=E(_u,`~`).setParameterLength(2).setName(`bitNot`),Fu=E(_u,`|`).setParameterLength(2).setName(`bitOr`),Iu=E(_u,`^`).setParameterLength(2).setName(`bitXor`),Lu=E(_u,`<<`).setParameterLength(2).setName(`shiftLeft`),Ru=E(_u,`>>`).setParameterLength(2).setName(`shiftRight`),zu=O(([e])=>(e.addAssign(1),e)),Bu=O(([e])=>(e.subAssign(1),e)),Vu=O(([e])=>{let t=A(e).toConst();return e.addAssign(1),t}),Hu=O(([e])=>{let t=A(e).toConst();return e.subAssign(1),t});w(`add`,vu),w(`sub`,yu),w(`mul`,bu),w(`div`,xu),w(`mod`,Su),w(`equal`,Cu),w(`notEqual`,wu),w(`lessThan`,Tu),w(`greaterThan`,Eu),w(`lessThanEqual`,Du),w(`greaterThanEqual`,Ou),w(`and`,ku),w(`or`,Au),w(`not`,ju),w(`xor`,Mu),w(`bitAnd`,Nu),w(`bitNot`,Pu),w(`bitOr`,Fu),w(`bitXor`,Iu),w(`shiftLeft`,Lu),w(`shiftRight`,Ru),w(`incrementBefore`,zu),w(`decrementBefore`,Bu),w(`increment`,Vu),w(`decrement`,Hu);const Uu=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),Su(e,t)),Wu=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),Su(A(e),A(t)));w(`remainder`,Uu),w(`modInt`,Wu);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=yu(1,n);else if(i===e.RECIPROCAL)a=xu(1,n);else if(i===e.DIFFERENCE)a=hd(yu(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=bu(e,i).xyz;a=sd(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 Gu=k(1e-6),Ku=k(1e6),qu=k(Math.PI),Ju=k(Math.PI*2),Yu=E(P,P.ALL).setParameterLength(1),Xu=E(P,P.ANY).setParameterLength(1),Zu=E(P,P.RADIANS).setParameterLength(1),Qu=E(P,P.DEGREES).setParameterLength(1),$u=E(P,P.EXP).setParameterLength(1),ed=E(P,P.EXP2).setParameterLength(1),td=E(P,P.LOG).setParameterLength(1),nd=E(P,P.LOG2).setParameterLength(1),rd=E(P,P.SQRT).setParameterLength(1),id=E(P,P.INVERSE_SQRT).setParameterLength(1),ad=E(P,P.FLOOR).setParameterLength(1),od=E(P,P.CEIL).setParameterLength(1),sd=E(P,P.NORMALIZE).setParameterLength(1),cd=E(P,P.FRACT).setParameterLength(1),ld=E(P,P.SIN).setParameterLength(1),ud=E(P,P.COS).setParameterLength(1),dd=E(P,P.TAN).setParameterLength(1),fd=E(P,P.ASIN).setParameterLength(1),pd=E(P,P.ACOS).setParameterLength(1),md=E(P,P.ATAN).setParameterLength(1,2),hd=E(P,P.ABS).setParameterLength(1),gd=E(P,P.SIGN).setParameterLength(1),_d=E(P,P.LENGTH).setParameterLength(1),vd=E(P,P.NEGATE).setParameterLength(1),yd=E(P,P.ONE_MINUS).setParameterLength(1),bd=E(P,P.DFDX).setParameterLength(1),xd=E(P,P.DFDY).setParameterLength(1),Sd=E(P,P.ROUND).setParameterLength(1),Cd=E(P,P.RECIPROCAL).setParameterLength(1),wd=E(P,P.TRUNC).setParameterLength(1),Td=E(P,P.FWIDTH).setParameterLength(1),Ed=E(P,P.TRANSPOSE).setParameterLength(1),Dd=E(P,P.BITCAST).setParameterLength(2),Od=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),Cu(e,t)),kd=E(P,P.MIN).setParameterLength(2,1/0),Ad=E(P,P.MAX).setParameterLength(2,1/0),jd=E(P,P.STEP).setParameterLength(2),Md=E(P,P.REFLECT).setParameterLength(2),Nd=E(P,P.DISTANCE).setParameterLength(2),Pd=E(P,P.DIFFERENCE).setParameterLength(2),Fd=E(P,P.DOT).setParameterLength(2),Id=E(P,P.CROSS).setParameterLength(2),Ld=E(P,P.POW).setParameterLength(2),Rd=E(P,P.POW,2).setParameterLength(1),zd=E(P,P.POW,3).setParameterLength(1),Bd=E(P,P.POW,4).setParameterLength(1),Vd=E(P,P.TRANSFORM_DIRECTION).setParameterLength(2),Hd=e=>bu(gd(e),Ld(hd(e),1/3)),Ud=e=>Fd(e,e),Wd=E(P,P.MIX).setParameterLength(3),Gd=(e,t=0,n=1)=>T(new P(P.CLAMP,T(e),T(t),T(n))),Kd=e=>Gd(e),qd=E(P,P.REFRACT).setParameterLength(3),Jd=E(P,P.SMOOTHSTEP).setParameterLength(3),Yd=E(P,P.FACEFORWARD).setParameterLength(3),Xd=O(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=Fd(e.xy,M(t,n)),a=Su(i,qu);return cd(ld(a).mul(r))}),Zd=(e,t,n)=>Wd(t,n,e),Qd=(e,t,n)=>Jd(t,n,e),$d=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),md(e,t)),ef=Yd,tf=id;w(`all`,Yu),w(`any`,Xu),w(`equals`,Od),w(`radians`,Zu),w(`degrees`,Qu),w(`exp`,$u),w(`exp2`,ed),w(`log`,td),w(`log2`,nd),w(`sqrt`,rd),w(`inverseSqrt`,id),w(`floor`,ad),w(`ceil`,od),w(`normalize`,sd),w(`fract`,cd),w(`sin`,ld),w(`cos`,ud),w(`tan`,dd),w(`asin`,fd),w(`acos`,pd),w(`atan`,md),w(`abs`,hd),w(`sign`,gd),w(`length`,_d),w(`lengthSq`,Ud),w(`negate`,vd),w(`oneMinus`,yd),w(`dFdx`,bd),w(`dFdy`,xd),w(`round`,Sd),w(`reciprocal`,Cd),w(`trunc`,wd),w(`fwidth`,Td),w(`atan2`,$d),w(`min`,kd),w(`max`,Ad),w(`step`,jd),w(`reflect`,Md),w(`distance`,Nd),w(`dot`,Fd),w(`cross`,Id),w(`pow`,Ld),w(`pow2`,Rd),w(`pow3`,zd),w(`pow4`,Bd),w(`transformDirection`,Vd),w(`mix`,Zd),w(`clamp`,Gd),w(`refract`,qd),w(`smoothstep`,Qd),w(`faceForward`,Yd),w(`difference`,Pd),w(`saturate`,Kd),w(`cbrt`,Hd),w(`transpose`,Ed),w(`rand`,Xd);var nf=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+`
|
|
40
|
+
`},r=new Ba(5,5,5),i=new Ga({name:`CubemapFromEquirect`,uniforms:Va(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:re,blending:ae});i.uniforms.tEquirect.value=t;let a=new La(r,i),o=t.minFilter;t.minFilter===at&&(t.minFilter=rt);let s=new $a(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)}},no=class extends zi{constructor(){super(),this.isGroup=!0,this.type=`Group`}};const ro={type:`move`};var io=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new no,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 no,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 no,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(ro)))}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 no;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},ao=class extends zi{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 Si,this.environmentIntensity=1,this.environmentRotation=new Si,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}},oo=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Un,this.updateRanges=[],this.version=0,this.uuid=Qn()}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=Qn()),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=Qn()),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 so=new C;var co=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++)so.fromBufferAttribute(this,t),so.applyMatrix4(e),this.setXYZ(t,so.x,so.y,so.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)so.fromBufferAttribute(this,t),so.applyNormalMatrix(e),this.setXYZ(t,so.x,so.y,so.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)so.fromBufferAttribute(this,t),so.transformDirection(e),this.setXYZ(t,so.x,so.y,so.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=sr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cr(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=cr(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=cr(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=cr(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=cr(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=sr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=sr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=sr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=sr(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=cr(t,this.array),n=cr(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=cr(t,this.array),n=cr(n,this.array),r=cr(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=cr(t,this.array),n=cr(n,this.array),r=cr(r,this.array),i=cr(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 pa(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}}},lo=class extends oa{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new ia(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}},uo=class extends Pr{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}},fo=class extends pa{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 po=new C,mo=new C,ho=new mr;var go=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=po.subVectors(n,t).cross(mo.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(po),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||ho.getNormalMatrix(e),r=this.coplanarPoint(po).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 _o=new ri,vo=new C;var yo=class{constructor(e=new go,t=new go,n=new go,r=new go,i=new go,a=new go){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=Gn){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===Gn)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===Kn)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(),_o.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),_o.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(_o)}intersectsSprite(e){return _o.center.set(0,0,0),_o.radius=.7071067811865476,_o.applyMatrix4(e.matrixWorld),this.intersectsSphere(_o)}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(vo.x=r.normal.x>0?e.max.x:e.min.x,vo.y=r.normal.y>0?e.max.y:e.min.y,vo.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(vo)<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 bo=new fi,xo=new yo;var So=class e{constructor(){this.coordinateSystem=Gn}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(bo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),xo.setFromProjectionMatrix(bo,this.coordinateSystem),xo.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(bo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),xo.setFromProjectionMatrix(bo,this.coordinateSystem),xo.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(bo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),xo.setFromProjectionMatrix(bo,this.coordinateSystem),xo.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(bo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),xo.setFromProjectionMatrix(bo,this.coordinateSystem),xo.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(bo.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),xo.setFromProjectionMatrix(bo,this.coordinateSystem),xo.containsPoint(e))return!0}return!1}clone(){return new e}},Co=class extends oa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new ia(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}},wo=class extends oa{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new ia(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}},To=class extends Pr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=et,this.minFilter=et,this.generateMipmaps=!1,this.needsUpdate=!0}},Eo=class extends Pr{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 Ar(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}},Do=class e extends Ta{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 _a(u,3)),this.setAttribute(`normal`,new _a(d,3)),this.setAttribute(`uv`,new _a(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 ur,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)}},Oo=class e extends Ta{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 _a(p,3)),this.setAttribute(`normal`,new _a(m,3)),this.setAttribute(`uv`,new _a(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)}},ko=class e extends Ta{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 _a(p,3)),this.setAttribute(`normal`,new _a(m,3)),this.setAttribute(`uv`,new _a(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)}},Ao=class extends oa{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new ia(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}},jo=class extends oa{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new ia(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 ia(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(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 Si,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}},Mo=class extends jo{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 ur(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,`reflectivity`,{get:function(){return $n(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 ia(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 ia(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ia(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}},No=class extends oa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type=`MeshPhongMaterial`,this.color=new ia(16777215),this.specular=new ia(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ia(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Si,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}},Po=class extends oa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:``},this.type=`MeshToonMaterial`,this.color=new ia(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ia(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(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}},Fo=class extends oa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type=`MeshNormalMaterial`,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(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}},Io=class extends oa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type=`MeshLambertMaterial`,this.color=new ia(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ia(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Si,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}},Lo=class extends oa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:``},this.type=`MeshMatcapMaterial`,this.color=new ia(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fn,this.normalScale=new ur(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}},Ro=class extends Co{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 zo(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Bo(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Vo=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_(){}},Ho=class extends Vo{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}},Uo=class extends Vo{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}},Wo=class extends Vo{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Go=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=zo(t,this.TimeBufferType),this.values=zo(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:zo(e.times,Array),values:zo(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Wo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Uo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ho(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&&Bo(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}};Go.prototype.ValueTypeName=``,Go.prototype.TimeBufferType=Float32Array,Go.prototype.ValueBufferType=Float32Array,Go.prototype.DefaultInterpolation=sn;var Ko=class extends Go{constructor(e,t,n){super(e,t,n)}};Ko.prototype.ValueTypeName=`bool`,Ko.prototype.ValueBufferType=Array,Ko.prototype.DefaultInterpolation=on,Ko.prototype.InterpolantFactoryMethodLinear=void 0,Ko.prototype.InterpolantFactoryMethodSmooth=void 0;var qo=class extends Go{constructor(e,t,n,r){super(e,t,n,r)}};qo.prototype.ValueTypeName=`color`;var Jo=class extends Go{constructor(e,t,n,r){super(e,t,n,r)}};Jo.prototype.ValueTypeName=`number`;var Yo=class extends Vo{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)dr.slerpFlat(i,0,a,c-o,a,c,s);return i}},Xo=class extends Go{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Yo(this.times,this.values,this.getValueSize(),e)}};Xo.prototype.ValueTypeName=`quaternion`,Xo.prototype.InterpolantFactoryMethodSmooth=void 0;var Zo=class extends Go{constructor(e,t,n){super(e,t,n)}};Zo.prototype.ValueTypeName=`string`,Zo.prototype.ValueBufferType=Array,Zo.prototype.DefaultInterpolation=on,Zo.prototype.InterpolantFactoryMethodLinear=void 0,Zo.prototype.InterpolantFactoryMethodSmooth=void 0;var Qo=class extends Go{constructor(e,t,n,r){super(e,t,n,r)}};Qo.prototype.ValueTypeName=`vector`;var $o=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 es=new $o;var ts=class{constructor(e){this.manager=e===void 0?es: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}};ts.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var ns=class extends zi{constructor(e,t=1){super(),this.isLight=!0,this.type=`Light`,this.color=new ia(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}},rs=class extends ns{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type=`HemisphereLight`,this.position.copy(zi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ia(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}};const os=new fi,ss=new C,cs=new C;var ls=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ur(512,512),this.mapType=st,this.map=null,this.mapPass=null,this.matrix=new fi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yo,this._frameExtents=new ur(1,1),this._viewportCount=1,this._viewports=[new Fr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;ss.setFromMatrixPosition(e.matrixWorld),t.position.copy(ss),cs.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cs),t.updateMatrixWorld(),os.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(os),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(os)}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}},us=class extends ls{constructor(){super(new Xa(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Zn*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}},ds=class extends ns{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(zi.DEFAULT_UP),this.updateMatrix(),this.target=new zi,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new us}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 fs=new fi,ps=new C,ms=new C;var hs=class extends ls{constructor(){super(new Xa(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ur(4,2),this._viewportCount=6,this._viewports=[new Fr(2,1,1,1),new Fr(0,1,1,1),new Fr(3,1,1,1),new Fr(1,1,1,1),new Fr(3,0,1,1),new Fr(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()),ps.setFromMatrixPosition(e.matrixWorld),n.position.copy(ps),ms.copy(n.position),ms.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ms),n.updateMatrixWorld(),r.makeTranslation(-ps.x,-ps.y,-ps.z),fs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fs)}},gs=class extends ns{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 hs}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}},_s=class extends Ka{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}},vs=class extends ls{constructor(){super(new _s(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ys=class extends ns{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type=`DirectionalLight`,this.position.copy(zi.DEFAULT_UP),this.updateMatrix(),this.target=new zi,this.shadow=new vs}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},bs=class extends ns{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type=`AmbientLight`}},xs=class extends ns{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}},Ss=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)}},Cs=class extends ns{constructor(e=new Ss,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}},ws=class extends Xa{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};const Ts=`\\[\\]\\.:\\/`,Es=RegExp(`[`+Ts+`]`,`g`),Ds=`[^`+Ts+`]`,Os=`[^`+Ts.replace(`\\.`,``)+`]`,ks=/((?:WC+[\/:])*)/.source.replace(`WC`,Ds),As=/(WCOD+)?/.source.replace(`WCOD`,Os),js=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,Ds),Ms=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,Ds),Ns=RegExp(`^`+ks+As+js+Ms+`$`),Ps=[`material`,`materials`,`bones`,`map`];var Fs=class{constructor(e,t,n){let r=n||Is.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()}},Is=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(Es,``)}static parseTrackName(e){let t=Ns.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);Ps.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}};Is.Composite=Fs,Is.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Is.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Is.prototype.GetterByBindingType=[Is.prototype._getValue_direct,Is.prototype._getValue_array,Is.prototype._getValue_arrayElement,Is.prototype._getValue_toArray],Is.prototype.SetterByBindingTypeAndVersioning=[[Is.prototype._setValue_direct,Is.prototype._setValue_direct_setNeedsUpdate,Is.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Is.prototype._setValue_array,Is.prototype._setValue_array_setNeedsUpdate,Is.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Is.prototype._setValue_arrayElement,Is.prototype._setValue_arrayElement_setNeedsUpdate,Is.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Is.prototype._setValue_fromArray,Is.prototype._setValue_fromArray_setNeedsUpdate,Is.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const hee=new Float32Array(1);var Ls=class extends oo{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}},Rs=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 zs=`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 Bs=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=zs,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 Vs(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 Hs=e=>Vs(e),Us=e=>Vs(e),Ws=(...e)=>Vs(e);function Gs(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of Ks(e))n.push(Vs(r.slice(0,-4)),i.getCacheKey(t));return Vs(n)}function*Ks(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 qs=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),Js=new WeakMap;function Ys(e){return qs.get(e)}function Xs(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 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 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function Qs(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 $s(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 ec(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 tc(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 ia(...t):n===`vec2`?new ur(...t):n===`vec3`?new C(...t):n===`vec4`?new Fr(...t):n===`mat2`?new Rs(...t):n===`mat3`?new mr(...t):n===`mat4`?new fi(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?ic(t[0]):null}function nc(e){let t=Js.get(e);return t===void 0&&(t={},Js.set(e,t)),t}function rc(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function ic(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const ac={VERTEX:`vertex`,FRAGMENT:`fragment`},oc={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},sc={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},cc={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},lc=[`fragment`,`vertex`],uc=[`setup`,`analyze`,`generate`],dc=[...lc,`compute`],fc=[`x`,`y`,`z`,`w`],pc={analyze:`setup`,generate:`analyze`};let mc=0;var hc=class extends qn{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=oc.NONE,this.updateBeforeType=oc.NONE,this.updateAfterType=oc.NONE,this.uuid=lr.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:mc++})}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,oc.FRAME)}onRenderUpdate(e){return this.onUpdate(e,oc.RENDER)}onObjectUpdate(e){return this.onUpdate(e,oc.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 Ks(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=Ws(Gs(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=pc[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 Ks(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}},gc=class extends hc{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} ]`}},_c=class extends hc{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)}},vc=class extends hc{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)}},yc=class extends vc{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 bc=fc.join(``);var xc=class extends hc{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(fc.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===bc.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}},Sc=class extends vc{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=fc[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},Cc=class extends vc{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=fc[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},wc=class extends hc{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?ec(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=ec(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=rc(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?tc(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 Tc=/float|u?int/;var Ec=class extends wc{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 Tc.test(n)&&Tc.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},Dc=class extends hc{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 Oc=null;const kc=new Map;function w(e,t){if(kc.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`);kc.set(e,t)}const Ac=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),jc=e=>Ac(e).split(``).sort().join(``),Mc={setup(e,t){let n=t.shift();return e(il(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(Oc.assign(n,...e),n);if(kc.has(t)){let r=kc.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`)&&kc.has(t.slice(0,t.length-6))){let r=kc.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=Ac(t),T(new xc(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=jc(t.slice(3).toLowerCase()),n=>T(new Sc(e,t,T(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=jc(t.slice(4).toLowerCase()),()=>T(new Cc(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 xc(e,t));else if(/^\d+$/.test(t)===!0)return T(new gc(n,new Ec(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>T(new Dc(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)}},Nc=new WeakMap,Pc=new WeakMap,Fc=function(e,t=null){let n=ec(e);if(n===`node`){let t=Nc.get(e);return t===void 0&&(t=new Proxy(e,Mc),Nc.set(e,t),Nc.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return T(Qc(e,t));else if(n===`shader`)return O(e);return e},Ic=function(e,t=null){for(let n in e)e[n]=T(e[n],t);return e},Lc=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=T(e[r],t);return e},Rc=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(...al(l(t)))):n===null?a=(...n)=>i(new e(t,...al(l(n)))):(n=T(n),a=(...r)=>i(new e(t,...al(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},zc=function(e,...t){return T(new e(...al(t)))};var Bc=class extends hc{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=Pc.get(e.constructor);r===void 0&&(r=new WeakMap,Pc.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}},Vc=class extends hc{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 il(e),T(new Bc(this,e))}setup(){return this.call()}};const Hc=[!1,!0],Uc=[0,1,2,3],Wc=[-1,-2],Gc=[.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],Kc=new Map;for(let e of Hc)Kc.set(e,new Ec(e));const qc=new Map;for(let e of Uc)qc.set(e,new Ec(e,`uint`));const Jc=new Map([...qc].map(e=>new Ec(e.value,`int`)));for(let e of Wc)Jc.set(e,new Ec(e,`int`));const Yc=new Map([...Jc].map(e=>new Ec(e.value)));for(let e of Gc)Yc.set(e,new Ec(e));for(let e of Gc)Yc.set(-e,new Ec(-e));const Xc={bool:Kc,uint:qc,ints:Jc,float:Yc},Zc=new Map([...Kc,...Yc]),Qc=(e,t)=>Zc.has(e)?Zc.get(e):e.isNode===!0?e:new Ec(e,t),$c=e=>{try{return e.getNodeType()}catch{return}},el=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[tc(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return T(t.get(n[0]));if(n.length===1){let t=Qc(n[0],e);return $c(t)===e?T(t):T(new _c(t,e))}let r=n.map(e=>Qc(e));return T(new yc(r,e))}},tl=e=>typeof e==`object`&&e?e.value:e,nl=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function rl(e,t){return new Proxy(new Vc(e,t),Mc)}const T=(e,t=null)=>Fc(e,t),il=(e,t=null)=>new Ic(e,t),al=(e,t=null)=>new Lc(e,t),E=(...e)=>new Rc(...e),D=(...e)=>new zc(...e);let ol=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 rl(e,n),i=(...e)=>{let t;il(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`+ ol++,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},sl=e=>{Oc=e},cl=()=>Oc,ll=(...e)=>Oc.If(...e),gee=(...e)=>Oc.Switch(...e);function ul(e){return Oc&&Oc.add(e),e}w(`toStack`,ul);const dl=new el(`color`),k=new el(`float`,Xc.float),A=new el(`int`,Xc.ints),j=new el(`uint`,Xc.uint),fl=new el(`bool`,Xc.bool),M=new el(`vec2`),pl=new el(`ivec2`),ml=new el(`uvec2`),hl=new el(`bvec2`),N=new el(`vec3`),gl=new el(`ivec3`),_l=new el(`uvec3`),vl=new el(`bvec3`),yl=new el(`vec4`),bl=new el(`ivec4`),xl=new el(`uvec4`),Sl=new el(`bvec4`),Cl=new el(`mat2`),wl=new el(`mat3`),Tl=new el(`mat4`),_ee=(e=``)=>T(new Ec(e,`string`)),vee=e=>T(new Ec(e,`ArrayBuffer`));w(`toColor`,dl),w(`toFloat`,k),w(`toInt`,A),w(`toUint`,j),w(`toBool`,fl),w(`toVec2`,M),w(`toIVec2`,pl),w(`toUVec2`,ml),w(`toBVec2`,hl),w(`toVec3`,N),w(`toIVec3`,gl),w(`toUVec3`,_l),w(`toBVec3`,vl),w(`toVec4`,yl),w(`toIVec4`,bl),w(`toUVec4`,xl),w(`toBVec4`,Sl),w(`toMat2`,Cl),w(`toMat3`,wl),w(`toMat4`,Tl);const El=E(gc).setParameterLength(2),Dl=(e,t)=>T(new _c(T(e),t)),yee=(e,t)=>T(new xc(T(e),t));w(`element`,El),w(`convert`,Dl);const bee=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),ul(e));w(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),ul(e)));const xee=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),O(...e));var Ol=class extends hc{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 kl=(e,t)=>T(new Ol(e,t)),Al=(e,t)=>T(new Ol(e,t,!0)),jl=D(Ol,`vec4`,`DiffuseColor`),Ml=D(Ol,`vec3`,`EmissiveColor`),Nl=D(Ol,`float`,`Roughness`),Pl=D(Ol,`float`,`Metalness`),Fl=D(Ol,`float`,`Clearcoat`),Il=D(Ol,`float`,`ClearcoatRoughness`),Ll=D(Ol,`vec3`,`Sheen`),Rl=D(Ol,`float`,`SheenRoughness`),zl=D(Ol,`float`,`Iridescence`),Bl=D(Ol,`float`,`IridescenceIOR`),Vl=D(Ol,`float`,`IridescenceThickness`),Hl=D(Ol,`float`,`AlphaT`),Ul=D(Ol,`float`,`Anisotropy`),Wl=D(Ol,`vec3`,`AnisotropyT`),Gl=D(Ol,`vec3`,`AnisotropyB`),Kl=D(Ol,`color`,`SpecularColor`),ql=D(Ol,`float`,`SpecularF90`),Jl=D(Ol,`float`,`Shininess`),Yl=D(Ol,`vec4`,`Output`),Xl=D(Ol,`float`,`dashSize`),Zl=D(Ol,`float`,`gapSize`),Ql=D(Ol,`float`,`pointWidth`),$l=D(Ol,`float`,`IOR`),eu=D(Ol,`float`,`Transmission`),tu=D(Ol,`float`,`Thickness`),nu=D(Ol,`float`,`AttenuationDistance`),ru=D(Ol,`color`,`AttenuationColor`),iu=D(Ol,`float`,`Dispersion`);var au=class extends hc{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 ou=e=>new au(e),su=(e,t=0)=>new au(e,!0,t),cu=su(`frame`),lu=su(`render`),uu=ou(`object`);var du=class extends wc{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=uu}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 fu=(e,t)=>{let n=nl(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return T(new du(r,n))};var pu=class extends vc{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 mu=(...e)=>{let t;if(e.length===1){let n=e[0];t=new pu(null,n.length,n)}else{let n=e[0],r=e[1];t=new pu(n,r)}return T(t)};w(`toArray`,(e,t)=>mu(Array(t).fill(e)));var hu=class extends vc{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=fc.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 gu=E(hu).setParameterLength(2);w(`assign`,gu);var See=class extends vc{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 _u=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?al(t):il(t[0]),T(new See(T(e),t)));w(`call`,_u);const vu={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var yu=class e extends vc{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(vu[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===Gn;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 bu=E(yu,`+`).setParameterLength(2,1/0).setName(`add`),xu=E(yu,`-`).setParameterLength(2,1/0).setName(`sub`),Su=E(yu,`*`).setParameterLength(2,1/0).setName(`mul`),Cu=E(yu,`/`).setParameterLength(2,1/0).setName(`div`),wu=E(yu,`%`).setParameterLength(2).setName(`mod`),Tu=E(yu,`==`).setParameterLength(2).setName(`equal`),Eu=E(yu,`!=`).setParameterLength(2).setName(`notEqual`),Du=E(yu,`<`).setParameterLength(2).setName(`lessThan`),Ou=E(yu,`>`).setParameterLength(2).setName(`greaterThan`),ku=E(yu,`<=`).setParameterLength(2).setName(`lessThanEqual`),Au=E(yu,`>=`).setParameterLength(2).setName(`greaterThanEqual`),ju=E(yu,`&&`).setParameterLength(2,1/0).setName(`and`),Mu=E(yu,`||`).setParameterLength(2,1/0).setName(`or`),Nu=E(yu,`!`).setParameterLength(1).setName(`not`),Pu=E(yu,`^^`).setParameterLength(2).setName(`xor`),Fu=E(yu,`&`).setParameterLength(2).setName(`bitAnd`),Iu=E(yu,`~`).setParameterLength(2).setName(`bitNot`),Lu=E(yu,`|`).setParameterLength(2).setName(`bitOr`),Ru=E(yu,`^`).setParameterLength(2).setName(`bitXor`),zu=E(yu,`<<`).setParameterLength(2).setName(`shiftLeft`),Bu=E(yu,`>>`).setParameterLength(2).setName(`shiftRight`),Vu=O(([e])=>(e.addAssign(1),e)),Hu=O(([e])=>(e.subAssign(1),e)),Uu=O(([e])=>{let t=A(e).toConst();return e.addAssign(1),t}),Wu=O(([e])=>{let t=A(e).toConst();return e.subAssign(1),t});w(`add`,bu),w(`sub`,xu),w(`mul`,Su),w(`div`,Cu),w(`mod`,wu),w(`equal`,Tu),w(`notEqual`,Eu),w(`lessThan`,Du),w(`greaterThan`,Ou),w(`lessThanEqual`,ku),w(`greaterThanEqual`,Au),w(`and`,ju),w(`or`,Mu),w(`not`,Nu),w(`xor`,Pu),w(`bitAnd`,Fu),w(`bitNot`,Iu),w(`bitOr`,Lu),w(`bitXor`,Ru),w(`shiftLeft`,zu),w(`shiftRight`,Bu),w(`incrementBefore`,Vu),w(`decrementBefore`,Hu),w(`increment`,Uu),w(`decrement`,Wu);const Gu=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),wu(e,t)),Ku=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),wu(A(e),A(t)));w(`remainder`,Gu),w(`modInt`,Ku);var P=class e extends vc{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=xu(1,n);else if(i===e.RECIPROCAL)a=Cu(1,n);else if(i===e.DIFFERENCE)a=_d(xu(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=yl(N(i),0):e=yl(N(e),0);let o=Su(e,i).xyz;a=ld(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===Gn&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===Gn&&(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===Kn&&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 qu=k(1e-6),Ju=k(1e6),Yu=k(Math.PI),Xu=k(Math.PI*2),Zu=E(P,P.ALL).setParameterLength(1),Qu=E(P,P.ANY).setParameterLength(1),$u=E(P,P.RADIANS).setParameterLength(1),ed=E(P,P.DEGREES).setParameterLength(1),td=E(P,P.EXP).setParameterLength(1),nd=E(P,P.EXP2).setParameterLength(1),rd=E(P,P.LOG).setParameterLength(1),id=E(P,P.LOG2).setParameterLength(1),ad=E(P,P.SQRT).setParameterLength(1),od=E(P,P.INVERSE_SQRT).setParameterLength(1),sd=E(P,P.FLOOR).setParameterLength(1),cd=E(P,P.CEIL).setParameterLength(1),ld=E(P,P.NORMALIZE).setParameterLength(1),ud=E(P,P.FRACT).setParameterLength(1),dd=E(P,P.SIN).setParameterLength(1),fd=E(P,P.COS).setParameterLength(1),pd=E(P,P.TAN).setParameterLength(1),md=E(P,P.ASIN).setParameterLength(1),hd=E(P,P.ACOS).setParameterLength(1),gd=E(P,P.ATAN).setParameterLength(1,2),_d=E(P,P.ABS).setParameterLength(1),vd=E(P,P.SIGN).setParameterLength(1),yd=E(P,P.LENGTH).setParameterLength(1),bd=E(P,P.NEGATE).setParameterLength(1),xd=E(P,P.ONE_MINUS).setParameterLength(1),Sd=E(P,P.DFDX).setParameterLength(1),Cd=E(P,P.DFDY).setParameterLength(1),wd=E(P,P.ROUND).setParameterLength(1),Td=E(P,P.RECIPROCAL).setParameterLength(1),Ed=E(P,P.TRUNC).setParameterLength(1),Dd=E(P,P.FWIDTH).setParameterLength(1),Od=E(P,P.TRANSPOSE).setParameterLength(1),kd=E(P,P.BITCAST).setParameterLength(2),Ad=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),Tu(e,t)),jd=E(P,P.MIN).setParameterLength(2,1/0),Md=E(P,P.MAX).setParameterLength(2,1/0),Nd=E(P,P.STEP).setParameterLength(2),Pd=E(P,P.REFLECT).setParameterLength(2),Fd=E(P,P.DISTANCE).setParameterLength(2),Id=E(P,P.DIFFERENCE).setParameterLength(2),Ld=E(P,P.DOT).setParameterLength(2),Rd=E(P,P.CROSS).setParameterLength(2),zd=E(P,P.POW).setParameterLength(2),Bd=E(P,P.POW,2).setParameterLength(1),Vd=E(P,P.POW,3).setParameterLength(1),Hd=E(P,P.POW,4).setParameterLength(1),Ud=E(P,P.TRANSFORM_DIRECTION).setParameterLength(2),Wd=e=>Su(vd(e),zd(_d(e),1/3)),Gd=e=>Ld(e,e),Kd=E(P,P.MIX).setParameterLength(3),qd=(e,t=0,n=1)=>T(new P(P.CLAMP,T(e),T(t),T(n))),Jd=e=>qd(e),Yd=E(P,P.REFRACT).setParameterLength(3),Xd=E(P,P.SMOOTHSTEP).setParameterLength(3),Zd=E(P,P.FACEFORWARD).setParameterLength(3),Qd=O(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=Ld(e.xy,M(t,n)),a=wu(i,Yu);return ud(dd(a).mul(r))}),$d=(e,t,n)=>Kd(t,n,e),ef=(e,t,n)=>Xd(t,n,e),tf=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),gd(e,t)),nf=Zd,rf=od;w(`all`,Zu),w(`any`,Qu),w(`equals`,Ad),w(`radians`,$u),w(`degrees`,ed),w(`exp`,td),w(`exp2`,nd),w(`log`,rd),w(`log2`,id),w(`sqrt`,ad),w(`inverseSqrt`,od),w(`floor`,sd),w(`ceil`,cd),w(`normalize`,ld),w(`fract`,ud),w(`sin`,dd),w(`cos`,fd),w(`tan`,pd),w(`asin`,md),w(`acos`,hd),w(`atan`,gd),w(`abs`,_d),w(`sign`,vd),w(`length`,yd),w(`lengthSq`,Gd),w(`negate`,bd),w(`oneMinus`,xd),w(`dFdx`,Sd),w(`dFdy`,Cd),w(`round`,wd),w(`reciprocal`,Td),w(`trunc`,Ed),w(`fwidth`,Dd),w(`atan2`,tf),w(`min`,jd),w(`max`,Md),w(`step`,Nd),w(`reflect`,Pd),w(`distance`,Fd),w(`dot`,Ld),w(`cross`,Rd),w(`pow`,zd),w(`pow2`,Bd),w(`pow3`,Vd),w(`pow4`,Hd),w(`transformDirection`,Ud),w(`mix`,$d),w(`clamp`,qd),w(`refract`,Yd),w(`smoothstep`,ef),w(`faceForward`,Zd),w(`difference`,Id),w(`saturate`,Jd),w(`cbrt`,Wd),w(`transpose`,Od),w(`rand`,Qd);var af=class extends hc{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?kl(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
41
|
|
|
42
42
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
43
43
|
|
|
@@ -47,22 +47,22 @@ import{computed as e,createElementBlock as t,createElementVNode as n,defineCompo
|
|
|
47
47
|
|
|
48
48
|
`)}else e.addFlowCode(`
|
|
49
49
|
|
|
50
|
-
`);return e.format(l,n,t)}};const rf=E(nf).setParameterLength(2,3);w(`select`,rf);const af=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),rf(...e));w(`cond`,af);var sf=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 cf=E(sf).setParameterLength(1,2),lf=(e,t)=>cf(e,{label:t});w(`context`,cf),w(`label`,lf);var uf=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 df=E(uf),ff=(e,t=null)=>df(e,t).toStack(),pf=(e,t=null)=>df(e,t,!0).toStack();w(`toVar`,ff),w(`toConst`,pf);const mf=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),df(e));w(`temp`,mf);var hf=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 gf=E(hf).setParameterLength(1,2),_f=e=>gf(e);w(`toVarying`,gf),w(`toVertexStage`,_f),w(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),gf(...e))),w(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),gf(...e)));const vf=O(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=Wd(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),yf=O(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=Wd(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),bf=`WorkingColorSpace`,xf=`OutputColorSpace`;var Sf=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===bf?Cr.workingColorSpace:t===xf?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(vf(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(yf(i.rgb),i.a)),i)}};const Cf=(e,t)=>T(new Sf(T(e),bf,t)),wf=(e,t)=>T(new Sf(T(e),t,bf)),Tf=(e,t,n)=>T(new Sf(T(e),t,n));w(`workingToColorSpace`,Cf),w(`colorSpaceToWorking`,wf);let Ef=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 Df=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 Ef(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 Of=(e,t,n)=>T(new Df(e,t,n));var kf=class extends Df{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 Af=(e,t,n=null)=>T(new kf(e,t,n));var jf=class extends _c{static get type(){return`ToneMappingNode`}constructor(e,t=Nf,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 Mf=(e,t,n)=>T(new jf(e,T(t),T(n))),Nf=Af(`toneMappingExposure`,`float`);w(`toneMapping`,(e,t,n)=>Mf(t,n,e));var Pf=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=gf(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 Ff=(e,t=null,n=0,r=0)=>T(new Pf(e,t,n,r)),If=(e,t=null,n=0,r=0)=>Ff(e,t,n,r).setUsage(Un),Lf=(e,t=null,n=0,r=0)=>Ff(e,t,n,r).setInstanced(!0),Rf=(e,t=null,n=0,r=0)=>If(e,t,n,r).setInstanced(!0);w(`toAttribute`,e=>Ff(e.value));var zf=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 Bf=(e,t,n)=>T(new zf(T(e),t,n));w(`compute`,Bf);var Vf=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 Hf=(e,t)=>T(new Vf(T(e),t)),Uf=(e,t)=>e.context({namespace:t});w(`cache`,Hf);var Wf=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 Gf=E(Wf).setParameterLength(2);w(`bypass`,Gf);var Kf=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 qf=E(Kf,null,null,{doClamp:!1}).setParameterLength(3,5),Jf=E(Kf).setParameterLength(3,5);w(`remap`,qf),w(`remapClamp`,Jf);var Yf=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 Xf=E(Yf).setParameterLength(1,2),Zf=e=>(e?rf(e,Xf(`discard`)):Xf(`discard`)).toStack(),Qf=()=>Xf(`return`).toStack();w(`discard`,Zf);var $f=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 ep=(e,t=null,n=null)=>T(new $f(T(e),t,n));w(`renderOutput`,ep);var tp=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+`#
|
|
50
|
+
`);return e.format(l,n,t)}};const sf=E(af).setParameterLength(2,3);w(`select`,sf);const cf=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),sf(...e));w(`cond`,cf);var lf=class extends hc{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 uf=E(lf).setParameterLength(1,2),df=(e,t)=>uf(e,{label:t});w(`context`,uf),w(`label`,df);var ff=class extends hc{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 pf=E(ff),mf=(e,t=null)=>pf(e,t).toStack(),hf=(e,t=null)=>pf(e,t,!0).toStack();w(`toVar`,mf),w(`toConst`,hf);const gf=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),pf(e));w(`temp`,gf);var _f=class extends hc{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(ac.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(ac.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,ac.VERTEX);e.flowNodeFromShaderStage(ac.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const vf=E(_f).setParameterLength(1,2),yf=e=>vf(e);w(`toVarying`,vf),w(`toVertexStage`,yf),w(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),vf(...e))),w(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),vf(...e)));const bf=O(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=Kd(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),xf=O(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=Kd(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),Sf=`WorkingColorSpace`,Cf=`OutputColorSpace`;var wf=class extends vc{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===Sf?wr.workingColorSpace:t===Cf?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 wr.enabled===!1||n===r||!n||!r?i:(wr.getTransfer(n)===vn&&(i=yl(bf(i.rgb),i.a)),wr.getPrimaries(n)!==wr.getPrimaries(r)&&(i=yl(wl(wr._getMatrix(new mr,n,r)).mul(i.rgb),i.a)),wr.getTransfer(r)===vn&&(i=yl(xf(i.rgb),i.a)),i)}};const Tf=(e,t)=>T(new wf(T(e),Sf,t)),Ef=(e,t)=>T(new wf(T(e),t,Sf)),Df=(e,t,n)=>T(new wf(T(e),t,n));w(`workingToColorSpace`,Tf),w(`colorSpaceToWorking`,Ef);let Of=class extends gc{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 kf=class extends hc{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=oc.OBJECT}setGroup(e){return this.group=e,this}element(e){return T(new Of(this,T(e)))}setNodeType(e){let t=fu(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 Af=(e,t,n)=>T(new kf(e,t,n));var jf=class extends kf{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(lu)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const Mf=(e,t,n=null)=>T(new jf(e,t,n));var Nf=class extends vc{static get type(){return`ToneMappingNode`}constructor(e,t=Ff,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return Ws(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=yl(i(t.rgb,this.exposureNode),t.a),r}};const Pf=(e,t,n)=>T(new Nf(e,T(t),T(n))),Ff=Mf(`toneMappingExposure`,`float`);w(`toneMapping`,(e,t,n)=>Pf(t,n,e));var If=class extends wc{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=Un,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 oo(n,i),s=new co(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=vf(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 Lf=(e,t=null,n=0,r=0)=>T(new If(e,t,n,r)),Rf=(e,t=null,n=0,r=0)=>Lf(e,t,n,r).setUsage(Wn),zf=(e,t=null,n=0,r=0)=>Lf(e,t,n,r).setInstanced(!0),Bf=(e,t=null,n=0,r=0)=>Rf(e,t,n,r).setInstanced(!0);w(`toAttribute`,e=>Lf(e.value));var Vf=class extends hc{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=oc.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 Hf=(e,t,n)=>T(new Vf(T(e),t,n));w(`compute`,Hf);var Uf=class extends hc{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 Wf=(e,t)=>T(new Uf(T(e),t)),Gf=(e,t)=>e.context({namespace:t});w(`cache`,Wf);var Kf=class extends hc{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 qf=E(Kf).setParameterLength(2);w(`bypass`,qf);var Jf=class extends hc{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 Yf=E(Jf,null,null,{doClamp:!1}).setParameterLength(3,5),Xf=E(Jf).setParameterLength(3,5);w(`remap`,Yf),w(`remapClamp`,Xf);var Zf=class extends hc{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 Qf=E(Zf).setParameterLength(1,2),$f=e=>(e?sf(e,Qf(`discard`)):Qf(`discard`)).toStack(),ep=()=>Qf(`return`).toStack();w(`discard`,$f);var tp=class extends vc{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!==wr.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const np=(e,t=null,n=null)=>T(new tp(T(e),t,n));w(`renderOutput`,np);var rp=class extends vc{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
51
|
`,a+=e.flow.code.replace(/^\t/gm,``)+`
|
|
52
52
|
`,a+=`/* ... */ `+n+` /* ... */
|
|
53
53
|
`,a+=`// #`+i+`#
|
|
54
|
-
`,t===null?console.log(a):t(e,a),n}};const np=(e,t=null)=>T(new tp(T(e),t));w(`debug`,np);function rp(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var ip=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=gf(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 ap=(e,t=null)=>T(new ip(e,t)),op=(e=0)=>ap(`uv`+(e>0?e:``),`vec2`);var sp=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 cp=E(sp).setParameterLength(1,2);var lp=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 up=E(lp).setParameterLength(1),dp=new Nr;var fp=class extends lu{static get type(){return`TextureNode`}constructor(e=dp,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 op(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(cp(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=wf(Xf(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(up(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 cp(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 pp=E(fp).setParameterLength(1,4).setName(`texture`),mp=(e=dp,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=pp(e,t,n,r),i},hp=(e=dp)=>mp(e),gp=(...e)=>mp(...e).setSampler(!1),_p=e=>(e.isNode===!0?e:mp(e)).convert(`sampler`),vp=e=>(e.isNode===!0?e:mp(e)).convert(`samplerComparison`);var yp=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 bp=(e,t,n)=>T(new yp(e,t,n));var xp=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)}},Sp=class extends yp{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 xp(this,T(e)))}};const Cp=(e,t)=>T(new Sp(e,t)),wp=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),T(new Sp(e,t)));var Tp=class extends mc{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const Ep=E(Tp).setParameterLength(1),Dp=uu(0,`uint`).label(`u_cameraIndex`).setGroup(au(`cameraIndex`)).toVarying(`v_cameraIndex`),Op=uu(`float`).label(`cameraNear`).setGroup(su).onRenderUpdate(({camera:e})=>e.near),kp=uu(`float`).label(`cameraFar`).setGroup(su).onRenderUpdate(({camera:e})=>e.far),Ap=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=Cp(n).setGroup(su).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?Ep(`gl_ViewID_OVR`):Dp).toVar(`cameraProjectionMatrix`)}else t=uu(`mat4`).label(`cameraProjectionMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),jp=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=Cp(n).setGroup(su).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?Ep(`gl_ViewID_OVR`):Dp).toVar(`cameraProjectionMatrixInverse`)}else t=uu(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(su).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);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.matrixWorldInverse);let r=Cp(n).setGroup(su).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?Ep(`gl_ViewID_OVR`):Dp).toVar(`cameraViewMatrix`)}else t=uu(`mat4`).label(`cameraViewMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Np=uu(`mat4`).label(`cameraWorldMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.matrixWorld),Pp=uu(`mat3`).label(`cameraNormalMatrix`).setGroup(su).onRenderUpdate(({camera:e})=>e.normalMatrix),Fp=uu(new C).label(`cameraPosition`).setGroup(su).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),Ip=new ni;var Lp=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(),Ip.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=Ip.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}};Lp.WORLD_MATRIX=`worldMatrix`,Lp.POSITION=`position`,Lp.SCALE=`scale`,Lp.VIEW_POSITION=`viewPosition`,Lp.DIRECTION=`direction`,Lp.RADIUS=`radius`;const Rp=E(Lp,Lp.DIRECTION).setParameterLength(1),zp=E(Lp,Lp.WORLD_MATRIX).setParameterLength(1),Bp=E(Lp,Lp.POSITION).setParameterLength(1),Vp=E(Lp,Lp.SCALE).setParameterLength(1),Hp=E(Lp,Lp.VIEW_POSITION).setParameterLength(1),Up=E(Lp,Lp.RADIUS).setParameterLength(1);var Wp=class extends Lp{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Gp=D(Wp,Wp.DIRECTION),Kp=D(Wp,Wp.WORLD_MATRIX),qp=D(Wp,Wp.POSITION),Jp=D(Wp,Wp.SCALE),Yp=D(Wp,Wp.VIEW_POSITION),Xp=D(Wp,Wp.RADIUS),Zp=uu(new pr).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Qp=uu(new di).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),$p=O(e=>e.renderer.overrideNodes.modelViewMatrix||em).once()().toVar(`modelViewMatrix`),em=Mp.mul(Kp),tm=O(e=>(e.context.isHighPrecisionModelViewMatrix=!0,uu(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),nm=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`),rm=ap(`position`,`vec3`),im=rm.toVarying(`positionLocal`),am=rm.toVarying(`positionPrevious`),om=O(e=>Kp.mul(im).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),sm=O(e=>{let t=im.transformDirection(Kp).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),cm=O(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),lm=cm.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var um=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 dm=D(um),fm=k(dm).mul(2).sub(1),pm=ap(`normal`,`vec3`),mm=O(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),N(0,1,0)):pm,`vec3`).once()().toVar(`normalLocal`),hm=cm.dFdx().cross(cm.dFdy()).normalize().toVar(`normalFlat`),gm=O(e=>{let t;return t=e.material.flatShading===!0?hm:gf(Sm(mm),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_m=O(e=>{let t=gm.transformDirection(Mp);return e.material.flatShading!==!0&&(t=gf(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),vm=O(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(fm)),t},`vec3`).once()().toVar(`transformedNormalView`),ym=vm.transformDirection(Mp).toVar(`transformedNormalWorld`),bm=O(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(fm)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),xm=O(([e,t=Kp])=>{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}),Sm=O(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=Zp.mul(e);return Mp.transformDirection(r)}),Cm=new xi,wm=new di,Tm=uu(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Em=uu(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Dm=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?(Cm.copy(n),wm.makeRotationFromEuler(Cm)):wm.identity(),wm}),Om=lm.negate().reflect(vm),km=lm.negate().refract(vm,Tm),Am=Om.transformDirection(Mp).toVar(`reflectVector`),jm=km.transformDirection(Mp).toVar(`reflectVector`),Mm=new $a;var Nm=class extends fp{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?Am:e.mapping===qe?jm:(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)),Dm.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const Pm=E(Nm).setParameterLength(1,4).setName(`cubeTexture`),Fm=(e=Mm,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=Pm(e,t,n,r),i},Im=(e=Mm)=>Pm(e);var Lm=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)}},Rm=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 Lm(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())?Cp(null,e):e===`texture`?mp(null):e===`cubeTexture`?Fm(null):uu(null,e):bp(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 zm=(e,t,n)=>T(new Rm(e,t,n)),Bm=(e,t,n,r)=>T(new Rm(e,t,r,n));var Vm=class extends Rm{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 Hm=(e,t,n=null)=>T(new Vm(e,t,n)),Um=O(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),ap(`tangent`,`vec4`)))(),Wm=Um.xyz.toVar(`tangentLocal`),Gm=$p.mul(_l(Wm,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),Km=Gm.transformDirection(Mp).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),qm=Gm.toVar(`transformedTangentView`),Jm=qm.transformDirection(Mp).normalize().toVar(`transformedTangentWorld`),Ym=O(([e,t],n)=>{let r=e.mul(Um.w).xyz;return n.material.flatShading!==!0&&(r=gf(r,t)),r}).once(),Xm=Ym(pm.cross(Um),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),Zm=Ym(mm.cross(Wm),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),Qm=Ym(gm.cross(Gm),`v_bitangentView`).normalize().toVar(`bitangentView`),$m=Ym(_m.cross(Km),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),eh=Ym(vm.cross(qm),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),th=eh.transformDirection(Mp).normalize().toVar(`transformedBitangentWorld`),nh=Sl(Gm,Qm,gm),rh=lm.mul(nh),ih=(e,t)=>e.sub(rh.mul(t)),ah=(()=>{let e=Ul.cross(lm);return e=e.cross(Ul).normalize(),e=Wd(e,vm,Vl.mul(jl.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),oh=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=fm.mul(m.inverseSqrt());return vu(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var sh=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=Sm(r);else if(t===fn){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?nh.mul(r).normalize():oh({eye_pos:cm,surf_norm:gm,mapN:r,uv:op()})}return i}};const ch=E(sh).setParameterLength(1,2),lh=O(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||op()),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)}),uh=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(fm),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var dh=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=lh({textureNode:this.textureNode,bumpScale:e});return uh({surf_pos:cm,surf_norm:gm,dHdxy:t})}};const fh=E(dh).setParameterLength(1,2),ph=new Map;var F=class e extends mc{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=ph.get(e);return n===void 0&&(n=Hm(e,t),ph.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=ch(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?fh(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):gm;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?ch(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):gm;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(Zh.x,Zh.y,Zh.y.negate(),Zh.x);i=t.mul(e.rg.mul(2).sub(M(1)).normalize().mul(e.b))}else i=Zh;else if(r===e.IRIDESCENCE_THICKNESS){let e=zm(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=zm(`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 mh=D(F,F.ALPHA_TEST),hh=D(F,F.COLOR),gh=D(F,F.SHININESS),_h=D(F,F.EMISSIVE),vh=D(F,F.OPACITY),yh=D(F,F.SPECULAR),bh=D(F,F.SPECULAR_INTENSITY),xh=D(F,F.SPECULAR_COLOR),Sh=D(F,F.SPECULAR_STRENGTH),Ch=D(F,F.REFLECTIVITY),wh=D(F,F.ROUGHNESS),Th=D(F,F.METALNESS),Eh=D(F,F.NORMAL),Dh=D(F,F.CLEARCOAT),Oh=D(F,F.CLEARCOAT_ROUGHNESS),kh=D(F,F.CLEARCOAT_NORMAL),Ah=D(F,F.ROTATION),jh=D(F,F.SHEEN),Mh=D(F,F.SHEEN_ROUGHNESS),Nh=D(F,F.ANISOTROPY),Ph=D(F,F.IRIDESCENCE),Fh=D(F,F.IRIDESCENCE_IOR),Ih=D(F,F.IRIDESCENCE_THICKNESS),Lh=D(F,F.TRANSMISSION),Rh=D(F,F.THICKNESS),zh=D(F,F.IOR),Bh=D(F,F.ATTENUATION_DISTANCE),Vh=D(F,F.ATTENUATION_COLOR),Hh=D(F,F.LINE_SCALE),Uh=D(F,F.LINE_DASH_SIZE),Wh=D(F,F.LINE_GAP_SIZE),Gh=D(F,F.LINE_WIDTH),Kh=D(F,F.LINE_DASH_OFFSET),qh=D(F,F.POINT_SIZE),Jh=D(F,F.DISPERSION),Yh=D(F,F.LIGHT_MAP),Xh=D(F,F.AO),Zh=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))}),Qh=O(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var $h=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=gf(this);a=e.build(t,n)}return a}};$h.VERTEX=`vertex`,$h.INSTANCE=`instance`,$h.SUBGROUP=`subgroup`,$h.INVOCATION_LOCAL=`invocationLocal`,$h.INVOCATION_SUBGROUP=`invocationSubgroup`,$h.DRAW=`draw`;const eg=D($h,$h.VERTEX),tg=D($h,$h.INSTANCE),ng=D($h,$h.SUBGROUP),rg=D($h,$h.INVOCATION_SUBGROUP),ig=D($h,$h.INVOCATION_LOCAL),ag=D($h,$h.DRAW);var og=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=bp(n.array,`mat4`,Math.max(t,1)).element(tg);else{let e=new Is(n.array,16,1);this.buffer=e;let t=n.usage===Un?Rf:Lf,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?Rf:Lf;this.bufferColor=e,a=N(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(im).xyz;if(im.assign(o),e.hasGeometryAttribute(`normal`)){let e=xm(mm,i);mm.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 sg=E(og).setParameterLength(2,3);var cg=class extends og{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const lg=E(cg).setParameterLength(1);var ug=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=tg:this.batchingIdNode=ag);let t=O(([e])=>{let t=A(cp(gp(this.batchMesh._indirectTexture),0).x),n=A(e).mod(t),r=A(e).div(t);return gp(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(cp(gp(r),0).x),a=k(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=Cl(gp(r,dl(o,s)),gp(r,dl(o.add(1),s)),gp(r,dl(o.add(2),s)),gp(r,dl(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=O(([e])=>{let t=A(cp(gp(l),0).x),n=e,r=n.mod(t),i=n.div(t);return gp(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);im.assign(c.mul(im));let d=mm.div(N(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;mm.assign(f),e.hasGeometryAttribute(`tangent`)&&Wm.mulAssign(u)}};const dg=E(ug).setParameterLength(1);var fg=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 pg=E(fg).setParameterLength(2);var mg=class extends yp{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 pg(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=Ff(this.value),this._varying=gf(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 hg=(e,t=null,n=0)=>T(new mg(e,t,n)),gg=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),hg(e,t,n).setPBO(!0)),_g=new WeakMap;var vg=class extends mc{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=ac.OBJECT,this.skinIndexNode=ap(`skinIndex`,`uvec4`),this.skinWeightNode=ap(`skinWeight`,`vec4`),this.bindMatrixNode=zm(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=zm(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=Bm(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=im,this.toPositionNode=im,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=vu(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=mm){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=vu(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=Bm(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,am)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||tc(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&am.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();mm.assign(t),e.hasGeometryAttribute(`tangent`)&&Wm.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;_g.get(t)!==e.frameId&&(_g.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const yg=e=>T(new vg(e)),bg=(e,t=null)=>{let n=new vg(e);return n.positionNode=hg(new uo(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(tg).toVar(),n.skinIndexNode=hg(new uo(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(tg).toVar(),n.skinWeightNode=hg(new uo(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(tg).toVar(),n.bindMatrixNode=uu(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=uu(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=bp(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,T(n)};var xg=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]=Xf(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?`
|
|
54
|
+
`,t===null?console.log(a):t(e,a),n}};const ip=(e,t=null)=>T(new rp(T(e),t));w(`debug`,ip);function ap(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var op=class extends hc{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=vf(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 sp=(e,t=null)=>T(new op(e,t)),cp=(e=0)=>sp(`uv`+(e>0?e:``),`vec2`);var lp=class extends hc{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 up=E(lp).setParameterLength(1,2);var dp=class extends du{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=oc.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 fp=E(dp).setParameterLength(1),pp=new Pr;var mp=class extends du{static get type(){return`TextureNode`}constructor(e=pp,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=oc.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 cp(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=fu(this.value.matrix)),this._matrixUniform.mul(N(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?oc.OBJECT:oc.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(up(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=Ef(Qf(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(fp(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 up(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 hp=E(mp).setParameterLength(1,4).setName(`texture`),gp=(e=pp,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=hp(e,t,n,r),i},_p=(e=pp)=>gp(e),vp=(...e)=>gp(...e).setSampler(!1),yp=e=>(e.isNode===!0?e:gp(e)).convert(`sampler`),bp=e=>(e.isNode===!0?e:gp(e)).convert(`samplerComparison`);var xp=class extends du{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 Sp=(e,t,n)=>T(new xp(e,t,n));var Cp=class extends gc{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)}},wp=class extends xp{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?ec(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=oc.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 Cp(this,T(e)))}};const Tp=(e,t)=>T(new wp(e,t)),Ep=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),T(new wp(e,t)));var Dp=class extends hc{constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const Op=E(Dp).setParameterLength(1),kp=fu(0,`uint`).label(`u_cameraIndex`).setGroup(su(`cameraIndex`)).toVarying(`v_cameraIndex`),Ap=fu(`float`).label(`cameraNear`).setGroup(lu).onRenderUpdate(({camera:e})=>e.near),jp=fu(`float`).label(`cameraFar`).setGroup(lu).onRenderUpdate(({camera:e})=>e.far),Mp=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=Tp(n).setGroup(lu).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?Op(`gl_ViewID_OVR`):kp).toVar(`cameraProjectionMatrix`)}else t=fu(`mat4`).label(`cameraProjectionMatrix`).setGroup(lu).onRenderUpdate(({camera:e})=>e.projectionMatrix);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.projectionMatrixInverse);let r=Tp(n).setGroup(lu).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?Op(`gl_ViewID_OVR`):kp).toVar(`cameraProjectionMatrixInverse`)}else t=fu(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(lu).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Pp=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=Tp(n).setGroup(lu).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?Op(`gl_ViewID_OVR`):kp).toVar(`cameraViewMatrix`)}else t=fu(`mat4`).label(`cameraViewMatrix`).setGroup(lu).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Fp=fu(`mat4`).label(`cameraWorldMatrix`).setGroup(lu).onRenderUpdate(({camera:e})=>e.matrixWorld),Ip=fu(`mat3`).label(`cameraNormalMatrix`).setGroup(lu).onRenderUpdate(({camera:e})=>e.normalMatrix),Lp=fu(new C).label(`cameraPosition`).setGroup(lu).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),Rp=new ri;var zp=class e extends hc{static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=oc.OBJECT,this.uniformNode=new du(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(),Rp.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=Rp.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}};zp.WORLD_MATRIX=`worldMatrix`,zp.POSITION=`position`,zp.SCALE=`scale`,zp.VIEW_POSITION=`viewPosition`,zp.DIRECTION=`direction`,zp.RADIUS=`radius`;const Bp=E(zp,zp.DIRECTION).setParameterLength(1),Vp=E(zp,zp.WORLD_MATRIX).setParameterLength(1),Hp=E(zp,zp.POSITION).setParameterLength(1),Up=E(zp,zp.SCALE).setParameterLength(1),Wp=E(zp,zp.VIEW_POSITION).setParameterLength(1),Gp=E(zp,zp.RADIUS).setParameterLength(1);var Kp=class extends zp{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const qp=D(Kp,Kp.DIRECTION),Jp=D(Kp,Kp.WORLD_MATRIX),Yp=D(Kp,Kp.POSITION),Xp=D(Kp,Kp.SCALE),Zp=D(Kp,Kp.VIEW_POSITION),Qp=D(Kp,Kp.RADIUS),$p=fu(new mr).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),em=fu(new fi).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),tm=O(e=>e.renderer.overrideNodes.modelViewMatrix||nm).once()().toVar(`modelViewMatrix`),nm=Pp.mul(Jp),rm=O(e=>(e.context.isHighPrecisionModelViewMatrix=!0,fu(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),im=O(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return fu(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),am=sp(`position`,`vec3`),om=am.toVarying(`positionLocal`),sm=am.toVarying(`positionPrevious`),cm=O(e=>Jp.mul(om).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),lm=O(e=>{let t=om.transformDirection(Jp).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),um=O(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),dm=um.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var fm=class extends hc{static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===Gn&&n.side===re?`false`:e.getFrontFacing()}};const pm=D(fm),mm=k(pm).mul(2).sub(1),hm=sp(`normal`,`vec3`),gm=O(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),N(0,1,0)):hm,`vec3`).once()().toVar(`normalLocal`),_m=um.dFdx().cross(um.dFdy()).normalize().toVar(`normalFlat`),vm=O(e=>{let t;return t=e.material.flatShading===!0?_m:vf(wm(gm),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),ym=O(e=>{let t=vm.transformDirection(Pp);return e.material.flatShading!==!0&&(t=vf(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),bm=O(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(mm)),t},`vec3`).once()().toVar(`transformedNormalView`),xm=bm.transformDirection(Pp).toVar(`transformedNormalWorld`),Sm=O(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(mm)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),Cm=O(([e,t=Jp])=>{let n=wl(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}),wm=O(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=$p.mul(e);return Pp.transformDirection(r)}),Tm=new Si,Em=new fi,Dm=fu(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Om=fu(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),km=fu(new fi).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?(Tm.copy(n),Em.makeRotationFromEuler(Tm)):Em.identity(),Em}),Am=dm.negate().reflect(bm),jm=dm.negate().refract(bm,Dm),Mm=Am.transformDirection(Pp).toVar(`reflectVector`),Nm=jm.transformDirection(Pp).toVar(`reflectVector`),Pm=new eo;var Fm=class extends mp{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?Mm:e.mapping===qe?Nm:(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===Kn||!n.isRenderTargetTexture)&&(t=N(t.x.negate(),t.yz)),km.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const Im=E(Fm).setParameterLength(1,4).setName(`cubeTexture`),Lm=(e=Pm,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=Im(e,t,n,r),i},Rm=(e=Pm)=>Im(e);var zm=class extends gc{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)}},Bm=class extends hc{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=oc.OBJECT}element(e){return T(new zm(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())?Tp(null,e):e===`texture`?gp(null):e===`cubeTexture`?Lm(null):fu(null,e):Sp(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 Vm=(e,t,n)=>T(new Bm(e,t,n)),Hm=(e,t,n,r)=>T(new Bm(e,t,r,n));var Um=class extends Bm{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 Wm=(e,t,n=null)=>T(new Um(e,t,n)),Gm=O(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),sp(`tangent`,`vec4`)))(),Km=Gm.xyz.toVar(`tangentLocal`),qm=tm.mul(yl(Km,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),Jm=qm.transformDirection(Pp).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),Ym=qm.toVar(`transformedTangentView`),Xm=Ym.transformDirection(Pp).normalize().toVar(`transformedTangentWorld`),Zm=O(([e,t],n)=>{let r=e.mul(Gm.w).xyz;return n.material.flatShading!==!0&&(r=vf(r,t)),r}).once(),Qm=Zm(hm.cross(Gm),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),$m=Zm(gm.cross(Km),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),eh=Zm(vm.cross(qm),`v_bitangentView`).normalize().toVar(`bitangentView`),th=Zm(ym.cross(Jm),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),nh=Zm(bm.cross(Ym),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),rh=nh.transformDirection(Pp).normalize().toVar(`transformedBitangentWorld`),ih=wl(qm,eh,vm),ah=dm.mul(ih),oh=(e,t)=>e.sub(ah.mul(t)),sh=(()=>{let e=Gl.cross(dm);return e=e.cross(Gl).normalize(),e=Kd(e,bm,Ul.mul(Nl.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),ch=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=mm.mul(m.inverseSqrt());return bu(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var lh=class extends vc{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=wm(r);else if(t===fn){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?ih.mul(r).normalize():ch({eye_pos:um,surf_norm:vm,mapN:r,uv:cp()})}return i}};const uh=E(lh).setParameterLength(1,2),dh=O(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||cp()),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)}),fh=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(mm),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var ph=class extends vc{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=dh({textureNode:this.textureNode,bumpScale:e});return fh({surf_pos:um,surf_norm:vm,dHdxy:t})}};const mh=E(ph).setParameterLength(1,2),hh=new Map;var F=class e extends hc{static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=hh.get(e);return n===void 0&&(n=Wm(e,t),hh.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=uh(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?mh(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):vm;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?uh(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):vm;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=Cl($h.x,$h.y,$h.y.negate(),$h.x);i=t.mul(e.rg.mul(2).sub(M(1)).normalize().mul(e.b))}else i=$h;else if(r===e.IRIDESCENCE_THICKNESS){let e=Vm(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=Vm(`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 gh=D(F,F.ALPHA_TEST),_h=D(F,F.COLOR),vh=D(F,F.SHININESS),yh=D(F,F.EMISSIVE),bh=D(F,F.OPACITY),xh=D(F,F.SPECULAR),Sh=D(F,F.SPECULAR_INTENSITY),Ch=D(F,F.SPECULAR_COLOR),wh=D(F,F.SPECULAR_STRENGTH),Th=D(F,F.REFLECTIVITY),Eh=D(F,F.ROUGHNESS),Dh=D(F,F.METALNESS),Oh=D(F,F.NORMAL),kh=D(F,F.CLEARCOAT),Ah=D(F,F.CLEARCOAT_ROUGHNESS),jh=D(F,F.CLEARCOAT_NORMAL),Mh=D(F,F.ROTATION),Nh=D(F,F.SHEEN),Ph=D(F,F.SHEEN_ROUGHNESS),Fh=D(F,F.ANISOTROPY),Ih=D(F,F.IRIDESCENCE),Lh=D(F,F.IRIDESCENCE_IOR),Rh=D(F,F.IRIDESCENCE_THICKNESS),zh=D(F,F.TRANSMISSION),Bh=D(F,F.THICKNESS),Vh=D(F,F.IOR),Hh=D(F,F.ATTENUATION_DISTANCE),Uh=D(F,F.ATTENUATION_COLOR),Wh=D(F,F.LINE_SCALE),Gh=D(F,F.LINE_DASH_SIZE),Kh=D(F,F.LINE_GAP_SIZE),qh=D(F,F.LINE_WIDTH),Jh=D(F,F.LINE_DASH_OFFSET),Yh=D(F,F.POINT_SIZE),Xh=D(F,F.DISPERSION),Zh=D(F,F.LIGHT_MAP),Qh=D(F,F.AO),$h=fu(new ur).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))}),eg=O(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var tg=class e extends hc{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=vf(this);a=e.build(t,n)}return a}};tg.VERTEX=`vertex`,tg.INSTANCE=`instance`,tg.SUBGROUP=`subgroup`,tg.INVOCATION_LOCAL=`invocationLocal`,tg.INVOCATION_SUBGROUP=`invocationSubgroup`,tg.DRAW=`draw`;const ng=D(tg,tg.VERTEX),rg=D(tg,tg.INSTANCE),ig=D(tg,tg.SUBGROUP),ag=D(tg,tg.INVOCATION_SUBGROUP),og=D(tg,tg.INVOCATION_LOCAL),sg=D(tg,tg.DRAW);var cg=class extends hc{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=oc.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=Sp(n.array,`mat4`,Math.max(t,1)).element(rg);else{let e=new Ls(n.array,16,1);this.buffer=e;let t=n.usage===Wn?Bf:zf,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=Tl(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new fo(r.array,3),t=r.usage===Wn?Bf:zf;this.bufferColor=e,a=N(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(om).xyz;if(om.assign(o),e.hasGeometryAttribute(`normal`)){let e=Cm(gm,i);gm.assign(e)}this.instanceColorNode!==null&&Al(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Wn&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Wn&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const lg=E(cg).setParameterLength(2,3);var ug=class extends cg{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const dg=E(ug).setParameterLength(1);var fg=class extends hc{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=rg:this.batchingIdNode=sg);let t=O(([e])=>{let t=A(up(vp(this.batchMesh._indirectTexture),0).x),n=A(e).mod(t),r=A(e).div(t);return vp(this.batchMesh._indirectTexture,pl(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(A(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=A(up(vp(r),0).x),a=k(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=Tl(vp(r,pl(o,s)),vp(r,pl(o.add(1),s)),vp(r,pl(o.add(2),s)),vp(r,pl(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=O(([e])=>{let t=A(up(vp(l),0).x),n=e,r=n.mod(t),i=n.div(t);return vp(l,pl(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);Al(`vec3`,`vBatchColor`).assign(t)}let u=wl(c);om.assign(c.mul(om));let d=gm.div(N(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;gm.assign(f),e.hasGeometryAttribute(`tangent`)&&Km.mulAssign(u)}};const pg=E(fg).setParameterLength(1);var mg=class extends gc{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 hg=E(mg).setParameterLength(2);var gg=class extends xp{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=Ys(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=cc.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 hg(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(cc.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Lf(this.value),this._varying=vf(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 _g=(e,t=null,n=0)=>T(new gg(e,t,n)),vg=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),_g(e,t,n).setPBO(!0)),yg=new WeakMap;var bg=class extends hc{static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=oc.OBJECT,this.skinIndexNode=sp(`skinIndex`,`uvec4`),this.skinWeightNode=sp(`skinWeight`,`vec4`),this.bindMatrixNode=Vm(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=Vm(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=Hm(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=om,this.toPositionNode=om,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=bu(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=gm){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=bu(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=Hm(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,sm)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||nc(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&sm.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();gm.assign(t),e.hasGeometryAttribute(`tangent`)&&Km.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;yg.get(t)!==e.frameId&&(yg.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const xg=e=>T(new bg(e)),Sg=(e,t=null)=>{let n=new bg(e);return n.positionNode=_g(new fo(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(rg).toVar(),n.skinIndexNode=_g(new fo(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(rg).toVar(),n.skinWeightNode=_g(new fo(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(rg).toVar(),n.bindMatrixNode=fu(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=fu(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=Sp(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,T(n)};var Cg=class extends hc{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]=Qf(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
55
|
`:``)+e.tab+f+` {
|
|
56
56
|
|
|
57
57
|
`).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
|
|
58
58
|
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
|
|
59
59
|
|
|
60
|
-
`).removeFlowTab();return e.addFlowTab(),a}};const Sg=(...e)=>T(new xg(il(e,`int`))).toStack(),Cg=()=>Xf(`continue`).toStack(),wg=()=>Xf(`break`).toStack(),Tg=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),Sg(...e)),Eg=new WeakMap,Dg=new Pr,Og=O(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=A(eg).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=gp(e,dl(c,s)).depth(i).xyz;return l.mul(t)});function kg(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=Eg.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&&(Dg.fromBufferAttribute(a,e),p[f+i+0]=Dg.x,p[f+i+1]=Dg.y,p[f+i+2]=Dg.z,p[f+i+3]=0),n===!0&&(Dg.fromBufferAttribute(o,e),p[f+i+4]=Dg.x,p[f+i+5]=Dg.y,p[f+i+6]=Dg.z,p[f+i+7]=0),r===!0&&(Dg.fromBufferAttribute(l,e),p[f+i+8]=Dg.x,p[f+i+9]=Dg.y,p[f+i+10]=Dg.z,p[f+i+11]=l.itemSize===4?Dg.w:1)}}o={count:a,texture:m,stride:l,size:new lr(u,d)},Eg.set(e,o);function g(){m.dispose(),Eg.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var Ag=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}=kg(t);n===!0&&im.mulAssign(this.morphBaseInfluence),r===!0&&mm.mulAssign(this.morphBaseInfluence);let l=A(c.width);Sg(a,({i:e})=>{let t=k(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(gp(this.mesh.morphTexture,dl(A(e).add(1),A(tg))).r):t.assign(zm(`morphTargetInfluences`,`float`).element(e).toVar()),sl(t.notEqual(0),()=>{n===!0&&im.addAssign(Og({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:A(0)})),r===!0&&mm.addAssign(Og({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 jg=E(Ag).setParameterLength(1);var Mg=class extends mc{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Ng=class extends Mg{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Pg=class extends sf{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 Fg=E(Pg);var Ig=class extends Mg{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let Lg,Rg;var zg=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(Rg),Rg.multiplyScalar(t.getPixelRatio())):Rg.copy(n.viewport):n===null?t.getDrawingBufferSize(Lg):(Lg.width=n.width,Lg.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?uu(Lg||=new lr):t===e.VIEWPORT?uu(Rg||=new Pr):M(Hg.div(Vg)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(Vg).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};zg.COORDINATE=`coordinate`,zg.VIEWPORT=`viewport`,zg.SIZE=`size`,zg.UV=`uv`;const Bg=D(zg,zg.UV),Vg=D(zg,zg.SIZE),Hg=D(zg,zg.COORDINATE),Ug=D(zg,zg.VIEWPORT),Wg=Ug.zw,Gg=Hg.sub(Ug.xy),Kg=Gg.div(Wg),qg=O(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),Vg),`vec2`).once()(),Jg=O(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),Bg),`vec2`).once()(),Yg=O(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),Bg.flipY()),`vec2`).once()(),Xg=new lr;var Zg=class extends fp{static get type(){return`ViewportTextureNode`}constructor(e=Bg,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(Xg);let n=this.value;(n.image.width!==Xg.width||n.image.height!==Xg.height)&&(n.image.width=Xg.width,n.image.height=Xg.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 Qg=E(Zg).setParameterLength(0,3),$g=E(Zg,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let e_=null;var t_=class extends Zg{static get type(){return`ViewportDepthTextureNode`}constructor(e=Bg,t=null){e_===null&&(e_=new To),super(e,t,e_)}};const n_=E(t_).setParameterLength(0,2);var r_=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=u_().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?o_(cm.z,Op,kp):i_(cm.z,Op,kp);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=s_(r,Op,kp);i=i_(e,Op,kp)}else i=r;else i=i_(cm.z,Op,kp);return i}};r_.DEPTH_BASE=`depthBase`,r_.DEPTH=`depth`,r_.LINEAR_DEPTH=`linearDepth`;const i_=(e,t,n)=>e.add(t).div(t.sub(n)),a_=(e,t,n)=>t.sub(n).mul(e).sub(t),o_=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),s_=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),c_=(e,t,n)=>{t=t.max(1e-6).toVar();let r=nd(e.negate().div(t)),i=nd(n.div(t));return r.div(i)},l_=(e,t,n)=>{let r=e.mul(td(n.div(t)));return k(Math.E).pow(r).mul(t).negate()},u_=E(r_,r_.DEPTH_BASE),d_=D(r_,r_.DEPTH),f_=E(r_,r_.LINEAR_DEPTH).setParameterLength(0,1),p_=f_(n_());d_.assign=e=>u_(e);var m_=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=Cp(t);Sg(a,({i:t})=>{let a=e.element(t);n.assign(cm.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Jd(r.negate(),r,n))})}let o=e.length;if(o>0){let t=Cp(e),a=k(1).toVar(`intersectionClipOpacity`);Sg(o,({i:e})=>{let i=t.element(e);n.assign(cm.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Jd(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=Cp(t);Sg(n,({i:t})=>{let n=e.element(t);cm.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=Cp(e),n=ul(!0).toVar(`clipped`);Sg(r,({i:e})=>{let r=t.element(e);n.assign(cm.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),O(()=>{let r=Cp(e),i=Ep(t.getClipDistance());Sg(n,({i:e})=>{let t=r.element(e),n=cm.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};m_.ALPHA_TO_COVERAGE=`alphaToCoverage`,m_.DEFAULT=`default`,m_.HARDWARE=`hardware`;const h_=()=>T(new m_),g_=()=>T(new m_(m_.ALPHA_TO_COVERAGE)),__=()=>T(new m_(m_.HARDWARE)),v_=.05,y_=O(([e])=>cd(bu(1e4,ld(bu(17,e.x).add(bu(.1,e.y)))).mul(vu(.1,hd(ld(bu(13,e.y).add(e.x))))))),b_=O(([e])=>y_(M(y_(e.xy),e.z))),x_=O(([e])=>{let t=Ad(_d(bd(e.xyz)),_d(xd(e.xyz))),n=k(1).div(k(v_).mul(t)).toVar(`pixScale`),r=M(ed(ad(nd(n))),ed(od(nd(n)))),i=M(b_(ad(r.x.mul(e.xyz))),b_(ad(r.y.mul(e.xyz)))),a=cd(nd(n)),o=vu(bu(a.oneMinus(),i.x),bu(a,i.y)),s=kd(a,a.oneMinus()),c=N(o.mul(o).div(bu(2,s).mul(yu(1,s))),o.sub(bu(.5,s)).div(yu(1,s)),yu(1,yu(1,o).mul(yu(1,o)).div(bu(2,s).mul(yu(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return Gd(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var S_=class extends ip{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 C_=(e=0)=>T(new S_(e));var w_=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=g_():e.stack.add(h_())}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(__()),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?c_(cm.z,Op,kp):i_(cm.z,Op,kp))}r!==null&&d_.assign(r).toStack()}setupPositionView(){return $p.mul(im).xyz}setupModelViewProjection(){return Ap.mul(cm)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Qh}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&jg(t).toStack(),t.isSkinnedMesh===!0&&yg(t).toStack(),this.displacementMap){let e=Hm(`displacementMap`,`texture`),t=Hm(`displacementScale`,`float`),n=Hm(`displacementBias`,`float`);im.addAssign(mm.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&dg(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&lg(t).toStack(),this.positionNode!==null&&im.assign(Uf(this.positionNode,`POSITION`)),im}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&ul(this.maskNode).not().discard();let n=this.colorNode?_l(this.colorNode):hh;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(C_())),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):vh;kl.a.assign(kl.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?mh:k(this.alphaTestNode),kl.a.lessThanEqual(i).discard()),this.alphaHash===!0&&kl.a.lessThan(x_(im)).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):Eh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Hm(`envMap`,`cubeTexture`):Hm(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Ig(Yh)),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?Xh:this.aoNode;t.push(new Ng(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=Fg(o,t,n,r)}else n!==null&&(s=N(r===null?n:Wd(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Al.assign(N(i||_h)),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 T_=new So;var E_=class extends w_{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(T_),this.setValues(e)}};const D_=new Lo;var O_=class extends w_{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(D_),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):Kh,t=this.dashScaleNode?k(this.dashScaleNode):Hh,n=this.dashSizeNode?k(this.dashSizeNode):Uh,r=this.gapSizeNode?k(this.gapSizeNode):Wh;Jl.assign(n),Yl.assign(r);let i=gf(ap(`lineDistance`).mul(t)),a=e?i.add(e):i;a.mod(Jl.add(Yl)).greaterThan(Jl).discard()}};let k_=null;var A_=class extends Zg{static get type(){return`ViewportSharedTextureNode`}constructor(e=Bg,t=null){k_===null&&(k_=new wo),super(e,t,k_)}updateReference(){return this}};const j_=E(A_).setParameterLength(0,2),M_=e=>T(e).mul(.5).add(.5),N_=e=>T(e).mul(2).sub(1),P_=new Po;var F_=class extends w_{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(P_),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?k(this.opacityNode):vh;kl.assign(wf(_l(M_(vm),e),hn))}},I_=class extends _c{static get type(){return`EquirectUVNode`}constructor(e=sm){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 L_=E(I_).setParameterLength(0,1);var R_=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=L_(sm),o=new w_;o.colorNode=mp(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 z_=new WeakMap;var B_=class extends _c{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Fm(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(z_.has(e)){let t=z_.get(e);U_(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(V_(n)){let r=new R_(n.height);r.fromEquirectangularTexture(t,e),U_(r.texture,e.mapping),this._cubeTexture=r.texture,z_.set(e,r.texture),e.addEventListener(`dispose`,H_)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function V_(e){return e==null?!1:e.height>0}function H_(e){let t=e.target;t.removeEventListener(`dispose`,H_);let n=z_.get(t);n!==void 0&&(z_.delete(t),n.dispose())}function U_(e,t){t===Je?e.mapping=Ke:t===Ye&&(e.mapping=qe)}const W_=E(B_).setParameterLength(1);var G_=class extends Mg{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=W_(this.envNode)}},K_=class extends Mg{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)}},q_=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},J_=class extends q_{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(Wd(r.rgb,r.rgb.mul(i.rgb),Sh.mul(Ch)));break;case Ie:r.rgb.assign(Wd(r.rgb,i.rgb,Sh.mul(Ch)));break;case Le:r.rgb.addAssign(i.rgb.mul(Sh.mul(Ch)));break;default:console.warn(`THREE.BasicLightingModel: Unsupported .combine value:`,t.combine);break}}};const Y_=new oa;var X_=class extends w_{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Y_),this.setValues(e)}setupNormal(){return gm}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new G_(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new K_(Yh)),t}setupOutgoingLight(){return kl.rgb}setupLightingModel(){return new J_}};const Z_=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))}),Q_=O(e=>e.diffuseColor.mul(1/Math.PI)),$_=()=>k(.25),ev=O(({dotNH:e})=>Kl.mul(k(.5)).add(1).mul(k(1/Math.PI)).mul(e.pow(Kl))),tv=O(({lightDirection:e})=>{let t=e.add(lm).normalize(),n=vm.dot(t).clamp(),r=lm.dot(t).clamp(),i=Z_({f0:Wl,f90:1,dotVH:r}),a=$_(),o=ev({dotNH:n});return i.mul(a).mul(o)});var nv=class extends J_{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=vm.dot(e).clamp(),i=r.mul(t);n.directDiffuse.addAssign(i.mul(Q_({diffuseColor:kl.rgb}))),this.specular===!0&&n.directSpecular.addAssign(i.mul(tv({lightDirection:e})).mul(Sh))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Q_({diffuseColor:kl}))),r.indirectDiffuse.mulAssign(t)}};const rv=new Fo;var iv=class extends w_{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rv),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new G_(t):null}setupLightingModel(){return new nv(!1)}};const av=new Mo;var ov=class extends w_{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(av),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new G_(t):null}setupLightingModel(){return new nv}setupVariants(){let e=(this.shininessNode?k(this.shininessNode):gh).max(1e-4);Kl.assign(e);let t=this.specularNode||yh;Wl.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}};const sv=O(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return k(0);let t=gm.dFdx().abs().max(gm.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),cv=O(e=>{let{roughness:t}=e,n=sv(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),lv=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 xu(.5,i.add(a).max(Gu))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),uv=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=xu(.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`}]}),dv=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`}]}),fv=k(1/Math.PI),pv=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 fv.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`}]}),mv=O(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||vm,l=i.pow2(),u=t.add(lm).normalize(),d=c.dot(t).clamp(),f=c.dot(lm).clamp(),p=c.dot(u).clamp(),m=lm.dot(u).clamp(),h=Z_({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(lm),r=Hl.dot(u),i=Ul.dot(t),a=Ul.dot(lm),o=Ul.dot(u);g=uv({alphaT:Bl,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=pv({alphaT:Bl,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=lv({alpha:l,dotNL:d,dotNV:f}),_=dv({alpha:l,dotNH:p});return h.mul(g).mul(_)}),hv=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`}]}),gv=O(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=hv({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),_v=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`}]}),vv=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`}]}),yv=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`}]}),bv=O(({lightDirection:e})=>{let t=e.add(lm).normalize(),n=vm.dot(e).clamp(),r=vm.dot(lm).clamp(),i=vm.dot(t).clamp(),a=vv({roughness:Il,dotNH:i}),o=yv({dotNV:r,dotNL:n});return Fl.mul(a).mul(o)}),xv=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`}]}),Sv=O(({f:e})=>{let t=e.length();return Ad(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),Cv=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,Ad(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`}]}),wv=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(Cv({v1:f,v2:p})),g.addAssign(Cv({v1:p,v2:m})),g.addAssign(Cv({v1:m,v2:h})),g.addAssign(Cv({v1:h,v2:f})),d.assign(N(Sv({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`}]}),Tv=1/6,Ev=e=>bu(Tv,bu(e,bu(e,e.negate().add(3)).sub(3)).add(1)),Dv=e=>bu(Tv,bu(e,bu(e,bu(3,e).sub(6))).add(4)),Ov=e=>bu(Tv,bu(e,bu(e,bu(-3,e).add(3)).add(3)).add(1)),kv=e=>bu(Tv,Ld(e,3)),Av=e=>Ev(e).add(Dv(e)),jv=e=>Ov(e).add(kv(e)),Mv=e=>vu(-1,Dv(e).div(Ev(e).add(Dv(e)))),Nv=e=>vu(1,kv(e).div(Ov(e).add(kv(e)))),Pv=(e,t,n)=>{let r=e.uvNode,i=bu(r,t.zw).add(.5),a=ad(i),o=cd(i),s=Av(o.x),c=jv(o.x),l=Mv(o.x),u=Nv(o.x),d=Mv(o.y),f=Nv(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),_=Av(o.y).mul(vu(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=jv(o.y).mul(vu(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Fv=O(([e,t=k(3)])=>{let n=M(e.size(A(t))),r=M(e.size(A(t.add(1)))),i=xu(1,n),a=xu(1,r),o=Pv(e,_l(i,n),ad(t)),s=Pv(e,_l(a,r),od(t));return cd(t).mix(o,s)}),Iv=O(([e,t,n,r,i])=>{let a=N(qd(t.negate(),sd(e),xu(1,r))),o=N(_d(i[0].xyz),_d(i[1].xyz),_d(i[2].xyz));return sd(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`}]}),Lv=O(([e,t])=>e.mul(Gd(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),Rv=$g(),zv=$g(),Bv=O(([e,t,n],{material:r})=>{let i=r.side===re?Rv:zv,a=i.sample(e),o=nd(Vg.x).mul(Lv(t,n));return Fv(a,o)}),Vv=O(([e,t,n])=>(sl(n.notEqual(0),()=>{let r=td(t).negate().div(n),i=$u(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`}]}),Hv=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));Sg({start:0,end:3},({i})=>{let u=a.element(i),m=Iv(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=Bv(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(Vv(_d(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Iv(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=Bv(_,n,u),g=r.mul(Vv(_d(i),f,p))}let _=g.rgb.mul(h.rgb),v=e.dot(t).clamp(),y=N(gv({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())}),Uv=Sl(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Wv=e=>{let t=e.sqrt();return N(1).add(t).div(N(1).sub(t))},Gv=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Kv=(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=Uv.mul(s);return c},qv=O(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=Wd(e,t,Jd(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=Gv(a,e),u=Z_({f0:l,f90:1,dotVH:n}),d=u.oneMinus(),f=a.lessThan(e).select(Math.PI,0),p=k(Math.PI).sub(f),m=Wv(i.clamp(0,.9999)),h=Gv(m,a.toVec3()),g=Z_({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 Sg({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{ne.mulAssign(x);let t=Kv(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`}]}),Jv=O(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.pow2(),a=rf(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=rf(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=rf(n.lessThan(.25),0,k(.1).mul(n).sub(.025)).add(a.mul(r).add(o).exp());return s.mul(1/Math.PI).saturate()}),Yv=N(.04),Xv=k(1);var Zv=class extends q_{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=vm.dot(lm).clamp();this.iridescenceFresnel=qv({outsideIOR:k(1),eta2:Rl,cosTheta1:e,thinFilmThickness:zl,baseF0:Wl}),this.iridescenceF0=_v({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(this.transmission===!0){let t=om,n=Fp.sub(om).normalize(),r=ym,i=e.context;i.backdrop=Hv(r,n,jl,kl,Wl,Gl,t,Kp,Mp,Ap,Zl,$l,tu,eu,this.dispersion?nu:null),i.backdropAlpha=Ql,kl.a.mulAssign(Wd(1,i.backdrop.a,Ql))}super.start(e)}computeMultiscattering(e,t,n){let r=vm.dot(lm).clamp(),i=hv({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=vm.dot(e).clamp(),i=r.mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(i.mul(bv({lightDirection:e}))),this.clearcoat===!0){let n=bm.dot(e).clamp(),r=n.mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(mv({lightDirection:e,f0:Yv,f90:Xv,roughness:Pl,normalView:bm})))}n.directDiffuse.addAssign(i.mul(Q_({diffuseColor:kl.rgb}))),n.directSpecular.addAssign(i.mul(mv({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=vm,f=lm,p=cm.toVar(),m=xv({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(wv({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(kl).mul(wv({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(Q_({diffuseColor:kl})))}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Fl,Jv({normal:vm,viewDir:lm,roughness:Il}))),this.clearcoat===!0){let e=bm.dot(lm).clamp(),t=gv({dotNV:e,specularColor:Yv,specularF90:Xv,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=vm.dot(lm).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=bm.dot(lm).clamp(),n=Z_({dotVH:e,f0:Yv,f90:Xv}),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 Qv=k(1),$v=k(-2),ey=k(.8),ty=k(-1),ny=k(.4),ry=k(2),iy=k(.305),ay=k(3),oy=k(.21),sy=k(4),cy=k(4),ly=k(16),uy=O(([e])=>{let t=N(hd(e)).toVar(),n=k(-1).toVar();return sl(t.x.greaterThan(t.z),()=>{sl(t.x.greaterThan(t.y),()=>{n.assign(rf(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(rf(e.y.greaterThan(0),1,4))})}).Else(()=>{sl(t.z.greaterThan(t.y),()=>{n.assign(rf(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(rf(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),dy=O(([e,t])=>{let n=M().toVar();return sl(t.equal(0),()=>{n.assign(M(e.z,e.y).div(hd(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(M(e.x.negate(),e.z.negate()).div(hd(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(M(e.x.negate(),e.y).div(hd(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(M(e.z.negate(),e.y).div(hd(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(M(e.x.negate(),e.z).div(hd(e.y)))}).Else(()=>{n.assign(M(e.x,e.y).div(hd(e.z)))}),bu(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),fy=O(([e])=>{let t=k(0).toVar();return sl(e.greaterThanEqual(ey),()=>{t.assign(Qv.sub(e).mul(ty.sub($v)).div(Qv.sub(ey)).add($v))}).ElseIf(e.greaterThanEqual(ny),()=>{t.assign(ey.sub(e).mul(ry.sub(ty)).div(ey.sub(ny)).add(ty))}).ElseIf(e.greaterThanEqual(iy),()=>{t.assign(ny.sub(e).mul(ay.sub(ry)).div(ny.sub(iy)).add(ry))}).ElseIf(e.greaterThanEqual(oy),()=>{t.assign(iy.sub(e).mul(sy.sub(ay)).div(iy.sub(oy)).add(ay))}).Else(()=>{t.assign(k(-2).mul(nd(bu(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),py=O(([e,t])=>{let n=e.toVar();n.assign(bu(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`}]}),my=O(([e,t,n,r,i,a])=>{let o=k(n),s=N(t),c=Gd(fy(o),$v,a),l=cd(c),u=ad(c),d=N(hy(e,s,u,r,i,a)).toVar();return sl(l.notEqual(0),()=>{let t=N(hy(e,s,u.add(1),r,i,a)).toVar();d.assign(Wd(d,t,l))}),d}),hy=O(([e,t,n,r,i,a])=>{let o=k(n).toVar(),s=N(t),c=k(uy(s)).toVar(),l=k(Ad(cy.sub(o),0)).toVar();o.assign(Ad(o,cy));let u=k(ed(o)).toVar(),d=M(dy(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(bu(3,ly))),d.y.addAssign(bu(4,ed(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(M(),M())}),gy=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=ud(r),l=n.mul(c).add(i.cross(n).mul(ld(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return hy(e,l,t,a,o,s)}),_y=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(rf(t,n,Id(n,r))).toVar();sl(f.equal(N(0)),()=>{f.assign(N(r.z,0,r.x.negate()))}),f.assign(sd(f));let p=N().toVar();return p.addAssign(i.element(0).mul(gy({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),Sg({start:A(1),end:e},({i:e})=>{sl(e.greaterThanEqual(a),()=>{wg()});let t=k(o.mul(k(e))).toVar();p.addAssign(i.element(e).mul(gy({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(gy({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)}),vy=4,yy=[.125,.215,.35,.446,.526,.582],by=20,xy=new gs(-1,1,1,-1,0,1),Sy=new Ya(90,1),Cy=new ra;let wy=null,Ty=0,Ey=0;const Dy=(1+Math.sqrt(5))/2,Oy=1/Dy,ky=[new C(-Dy,Oy,0),new C(Dy,Oy,0),new C(-Oy,0,Dy),new C(Oy,0,Dy),new C(0,Dy,-Oy),new C(0,Dy,Oy),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)],Tee=new C,Ay=new WeakMap,Eee=[3,1,5,0,4,2],jy=py(op(),ap(`faceIndex`)).normalize(),My=N(jy.x,jy.y,jy.z);var Dee=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=Tee,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}wy=this._renderer.getRenderTarget(),Ty=this._renderer.getActiveCubeFace(),Ey=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=Iy(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ly(),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(wy,Ty,Ey),e.scissorTest=!1,Py(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),wy=this._renderer.getRenderTarget(),Ty=this._renderer.getActiveCubeFace(),Ey=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=Ny(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=Ny(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=Oee(t)),this._blurMaterial=kee(t,e.width,e.height)}}async _compileMaterial(e){let t=new Ia(this._lodPlanes[0],e);await this._renderer.compile(t,xy)}_sceneToCubeUV(e,t,n,r,i){let a=Sy;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(Cy),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(Cy),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;Py(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=Iy(e)):this._equirectMaterial===null&&(this._equirectMaterial=Ly(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;Py(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,xy)}_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=ky[(r-t-1)%ky.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=Ay.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*by-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):by;h>by&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${by}`);let g=[],_=0;for(let e=0;e<by;++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-vy?r-v+vy:0),x=4*(this._cubeSize-y);Py(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,xy)}};function Oee(e){let t=[],n=[],r=[],i=[],a=e,o=e-vy+1+yy.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-vy?c=yy[s-e+vy-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=Eee[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>vy&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function Ny(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 Py(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Fy(e){let t=new w_;return t.depthTest=!1,t.depthWrite=!1,t.blending=ae,t.name=`PMREM_${e}`,t}function kee(e,t,n){let r=Cp(Array(by).fill(0)),i=uu(new C(0,1,0)),a=uu(0),o=k(by),s=uu(0),c=uu(1),l=mp(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:My,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=Fy(`blur`);return h.fragmentNode=_y({...m,latitudinal:s.equal(1)}),Ay.set(h,m),h}function Iy(e){let t=Fy(`cubemap`);return t.fragmentNode=Fm(e,My),t}function Ly(e){let t=Fy(`equirect`);return t.fragmentNode=mp(e,L_(My),0),t}const Ry=new WeakMap;function Aee(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 jee(e,t,n){let r=Mee(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(Pee(t))i=n.fromCubemap(e,i);else return null;else if(Fee(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function Mee(e){let t=Ry.get(e);return t===void 0&&(t=new WeakMap,Ry.set(e,t)),t}var Nee=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=mp(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=Aee(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:jee(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new Dee(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=Dm.mul(N(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),my(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function Pee(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 Fee(e){return e==null?!1:e.height>0}const zy=E(Nee).setParameterLength(1,3),By=new WeakMap;var Iee=class extends Mg{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=By.get(e);r===void 0&&(r=zy(e),By.set(e,r)),n=r}let r=t.useAnisotropy===!0||t.anisotropy>0,i=r?ah:vm,a=n.context(Vy(jl,i)).mul(Em),o=n.context(Lee(ym)).mul(Math.PI).mul(Em),s=Hf(a),c=Hf(o);e.context.radiance.addAssign(s),e.context.iblIrradiance.addAssign(c);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=n.context(Vy(Pl,bm)).mul(Em),t=Hf(e);l.addAssign(t)}}};const Vy=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=lm.negate().reflect(t),n=e.mul(e).mix(n,t).normalize(),n=n.transformDirection(Mp)),n),getTextureLevel:()=>e}},Lee=e=>({getUV:()=>e,getTextureLevel:()=>k(1)}),Ree=new Ao;var Hy=class extends w_{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(Ree),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new Iee(t):null}setupLightingModel(){return new Zv}setupSpecular(){let e=Wd(N(.04),kl.rgb,Ml);Wl.assign(e),Gl.assign(1)}setupVariants(){let e=this.metalnessNode?k(this.metalnessNode):Th;Ml.assign(e);let t=this.roughnessNode?k(this.roughnessNode):wh;t=cv({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 zee=new jo;var Bee=class extends Hy{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(zee),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):zh;Zl.assign(e),Wl.assign(Wd(kd(Rd(Zl.sub(1).div(Zl.add(1))).mul(xh),N(1)).mul(bh),kl.rgb,Ml)),Gl.assign(Wd(bh,1,Ml))}setupLightingModel(){return new Zv(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):Dh,t=this.clearcoatRoughnessNode?k(this.clearcoatRoughnessNode):Oh;Nl.assign(e),Pl.assign(cv({roughness:t}))}if(this.useSheen){let e=this.sheenNode?N(this.sheenNode):jh,t=this.sheenRoughnessNode?k(this.sheenRoughnessNode):Mh;Fl.assign(e),Il.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?k(this.iridescenceNode):Ph,t=this.iridescenceIORNode?k(this.iridescenceIORNode):Fh,n=this.iridescenceThicknessNode?k(this.iridescenceThicknessNode):Ih;Ll.assign(e),Rl.assign(t),zl.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?M(this.anisotropyNode):Nh).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(nh[0].mul(e.x).add(nh[1].mul(e.y))),Ul.assign(nh[1].mul(e.x).sub(nh[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?k(this.transmissionNode):Lh,t=this.thicknessNode?k(this.thicknessNode):Rh,n=this.attenuationDistanceNode?k(this.attenuationDistanceNode):Bh,r=this.attenuationColorNode?N(this.attenuationColorNode):Vh;if(Ql.assign(e),$l.assign(t),eu.assign(n),tu.assign(r),this.useDispersion){let e=this.dispersionNode?k(this.dispersionNode):Jh;nu.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?N(this.clearcoatNormalNode):kh}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 Vee=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=Hm(`gradientMap`,`texture`).context({getUV:()=>i});return N(e.r)}else{let e=i.fwidth().mul(.5);return Wd(N(.7),N(1),Jd(k(.7).sub(e.x),k(.7).add(e.x),i.x))}});var Hee=class extends q_{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=Vee({normal:pm,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(Q_({diffuseColor:kl.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Q_({diffuseColor:kl}))),r.indirectDiffuse.mulAssign(t)}};const Uee=new No;var Wee=class extends w_{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Uee),this.setValues(e)}setupLightingModel(){return new Hee}},Gee=class extends _c{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=N(lm.z,0,lm.x.negate()).normalize(),t=lm.cross(e);return M(e.dot(vm),t.dot(vm)).mul(.495).add(.5)}};const Uy=D(Gee),Kee=new Io;var qee=class extends w_{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Kee),this.setValues(e)}setupVariants(e){let t=Uy,n;n=e.material.matcap?Hm(`matcap`,`texture`).context({getUV:()=>t}):N(Wd(.2,.8,t.y)),kl.rgb.mulAssign(n.rgb)}},Jee=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,ud(e.x),ld(e.x).negate(),0),_l(0,ld(e.x),ud(e.x),0),_l(0,0,0,1)),i=Cl(_l(ud(e.y),0,ld(e.y),0),_l(0,1,0,0),_l(ld(e.y).negate(),0,ud(e.y),0),_l(0,0,0,1)),a=Cl(_l(ud(e.z),ld(e.z).negate(),0,0),_l(ld(e.z),ud(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 Wy=E(Jee).setParameterLength(2),Yee=new co;var Gy=class extends w_{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(Yee),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:i,rotationNode:a,scaleNode:o}=this,s=$p.mul(N(i||0)),c=M(Kp[0].xyz.length(),Kp[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(Ap.element(1).element(1));c=c.mul(e.mul(2))}let l=rm.xy;if(t.center&&t.center.isVector2===!0){let e=Of(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=k(a||Ah),d=Wy(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 Xee=new Co;var Zee=class extends Gy{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Xee),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return $p.mul(N(e||im)).xyz}setupVertex(e){let t=super.setupVertex(e);if(e.material.isNodeMaterial!==!0)return t;let{rotationNode:n,scaleNode:r,sizeNode:i}=this,a=rm.xy.toVar(),o=Ug.z.div(Ug.w);if(n&&n.isNode){let e=k(n);a.assign(Wy(a,e))}let s=i===null?qh:M(i);return this.sizeAttenuation===!0&&(s=s.mul(s.div(cm.z.negate()))),r&&r.isNode&&(s=s.mul(M(r))),a.mulAssign(s.mul(2)),a.assign(a.div(Ug.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)}},Qee=class extends q_{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 $ee=new ko;var ete=class extends w_{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues($ee),this.setValues(e)}setupLightingModel(){return new Qee}};const tte=Dl(`vec3`),nte=Dl(`vec3`),rte=Dl(`vec3`);var ite=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()}},Ky=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 ate=0;function ote(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 ste=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=ate++,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 ote(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 qy=[];var cte=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);qy[0]=e,qy[1]=t,qy[2]=a,qy[3]=i;let l=c.get(qy);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(qy,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)))),qy.length=0,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new Ky)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new ste(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}},Jy=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 Yy={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Xy=16,lte=211,ute=212;var dte=class extends Jy{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===Yy.VERTEX?this.backend.createAttribute(e):t===Yy.INDEX?this.backend.createIndexAttribute(e):t===Yy.STORAGE?this.backend.createStorageAttribute(e):t===Yy.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 Zy(e){return e.index===null?e.attributes.position.version:e.index.version}function Qy(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=Zy(e),i}var fte=class extends Jy{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,Yy.STORAGE):this.updateAttribute(e,Yy.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,Yy.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Yy.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=Qy(t),e.set(t,n)):n.version!==Zy(t)&&(this.attributes.delete(n),n=Qy(t),e.set(t,n)),r=n}return r}},pte=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}},$y=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},mte=class extends $y{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},hte=class extends $y{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}};let gte=0;var eb=class{constructor(e,t,n,r=null,i=null){this.id=gte++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},_te=class extends Jy{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 eb(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 eb(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 eb(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 hte(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 mte(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)}},vte=class extends Jy{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?Yy.INDIRECT:Yy.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?Yy.INDIRECT:Yy.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 yte(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 tb(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 nb(e){let t=e.transmission>0||e.transmissionNode;return t&&e.side===ie&&e.forceSinglePass===!1}var bte=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?(nb(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?(nb(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||yte),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||tb),this.transparent.length>1&&this.transparent.sort(t||tb)}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 rb=[];var xte=class{constructor(e){this.lighting=e,this.lists=new Ky}get(e,t){let n=this.lists;rb[0]=e,rb[1]=t;let r=n.get(rb);return r===void 0&&(r=new bte(this.lighting,e,t),n.set(rb,r)),rb.length=0,r}dispose(){this.lists=new Ky}};let Ste=0;var Cte=class{constructor(){this.id=Ste++,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 ib(this)}};function ib(e){let{textures:t,activeCubeFace:n}=e,r=[n];for(let e of t)r.push(e.id);return Hs(r)}const ab=[],wte=new io,Tte=new Ga;var Ete=class{constructor(){this.chainMaps={}}get(e,t,n=null){ab[0]=e,ab[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(ab);return a===void 0&&(a=new Cte,i.set(ab,a)),ab.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(wte,Tte,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Ky)}dispose(){this.chainMaps={}}};const Dte=new C;var Ote=class extends Jy{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=Dte){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--)}},ob=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)}},sb=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 kte=(e,t)=>T(new sb(e,t));var Ate=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=rf(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new nl(t),r=rf(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=rf(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 cb=E(Ate).setParameterLength(0,1);function jte(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 Mte=class extends mc{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=jte(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)}},Nte=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 Pte=(e,t=null)=>{let n=new Mte(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 Nte(n,r))};return r.layout=n,r.isStruct=!0,r};var lb=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 Fte=E(lb);function ub(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Ite=class extends lb{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 db(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=ub(i,e);r[n]=_l(t[e])}return this.members=r,super.setup(e)}};const db=E(Ite),Lte=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)}),fb=(e,t)=>Ld(bu(4,e.mul(yu(1,e))),t),Rte=(e,t)=>e.lessThan(.5)?fb(e.mul(2),t).div(2):yu(1,fb(bu(yu(1,e),2),t).div(2)),zte=(e,t,n)=>Ld(xu(Ld(e,t),vu(Ld(e,t),Ld(yu(1,e),n))),1/t),Bte=(e,t)=>ld(qu.mul(t.mul(e).sub(1))).div(qu.mul(t.mul(e).sub(1))),pb=O(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Vte=O(([e])=>N(pb(e.z.add(pb(e.y.mul(1)))),pb(e.z.add(pb(e.x.mul(1)))),pb(e.y.add(pb(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Hte=O(([e,t,n])=>{let r=N(e).toVar(),i=k(1.4).toVar(),a=k(0).toVar(),o=N(r).toVar();return Sg({start:k(0),end:k(3),type:`float`,condition:`<=`},()=>{let e=N(Vte(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(pb(r.z.add(pb(r.x.add(pb(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 Ute=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 Wte=E(Ute),mb=e=>(...t)=>Wte(e,...t),hb=uu(0).setGroup(su).onRenderUpdate(e=>e.time),gb=uu(0).setGroup(su).onRenderUpdate(e=>e.deltaTime),Gte=uu(0,`uint`).setGroup(su).onRenderUpdate(e=>e.frameId),Kte=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),hb.mul(e)),qte=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),hb.mul(e)),Jte=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),gb.mul(e)),Yte=(e=hb)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Xte=(e=hb)=>e.fract().round(),Zte=(e=hb)=>e.add(.5).fract().mul(2).sub(1).abs(),Qte=(e=hb)=>e.fract(),$te=O(([e,t,n=M(.5)])=>Wy(e.sub(n),t).add(n)),ene=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))}),tne=O(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=Kp:(r=Kp.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Mp.mul(r);return el(t)&&(i[0][0]=Kp[0].length(),i[0][1]=0,i[0][2]=0),el(n)&&(i[1][0]=0,i[1][1]=Kp[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Ap.mul(i).mul(im)}),nne=O(([e=null])=>{let t=f_(),n=f_(n_(e)).sub(t),r=n.lessThan(0).select(Bg,e);return r});var rne=class extends mc{static get type(){return`SpriteSheetUVNode`}constructor(e,t=op(),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 ine=E(rne).setParameterLength(3);var ane=class extends mc{static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=k(1),i=im,a=mm){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=mp(u,s).mul(o.x),m=mp(d,c).mul(o.y),h=mp(f,l).mul(o.z);return vu(p,m,h)}};const _b=E(ane).setParameterLength(1,6),one=(...e)=>_b(...e),vb=new ho,yb=new C,bb=new C,xb=new C,Sb=new di,Cb=new C(0,0,-1),wb=new Pr,Tb=new C,Eb=new C,Db=new Pr,Ob=new lr,kb=new Fr,sne=Bg.flipX();kb.depthTexture=new To(1,1);let Ab=!1;var cne=class e extends fp{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||kb.texture,sne),this._reflectorBaseNode=e.reflector||new lne(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:kb.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()}},lne=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(Ob),e.setSize(Math.round(Ob.width*n),Math.round(Ob.height*n))}setup(e){return this._updateResolution(kb,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&&Ab)return!1;Ab=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(Ob),this._updateResolution(s,r),bb.setFromMatrixPosition(a.matrixWorld),xb.setFromMatrixPosition(n.matrixWorld),Sb.extractRotation(a.matrixWorld),yb.set(0,0,1),yb.applyMatrix4(Sb),Tb.subVectors(bb,xb);let c=Tb.dot(yb)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Ab=!1;return}l=!0}Tb.reflect(yb).negate(),Tb.add(bb),Sb.extractRotation(n.matrixWorld),Cb.set(0,0,-1),Cb.applyMatrix4(Sb),Cb.add(xb),Eb.subVectors(bb,Cb),Eb.reflect(yb).negate(),Eb.add(bb),o.coordinateSystem=n.coordinateSystem,o.position.copy(Tb),o.up.set(0,1,0),o.up.applyMatrix4(Sb),o.up.reflect(yb),o.lookAt(Eb),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),vb.setFromNormalAndCoplanarPoint(yb,bb),vb.applyMatrix4(o.matrixWorldInverse),wb.set(vb.normal.x,vb.normal.y,vb.normal.z,vb.constant);let u=o.projectionMatrix;Db.x=(Math.sign(wb.x)+u.elements[8])/u.elements[0],Db.y=(Math.sign(wb.y)+u.elements[9])/u.elements[5],Db.z=-1,Db.w=(1+u.elements[10])/u.elements[14],wb.multiplyScalar(1/wb.dot(Db));let d=0;u.elements[2]=wb.x,u.elements[6]=wb.y,u.elements[10]=r.coordinateSystem===Gn?wb.z-d:wb.z+1-d,u.elements[14]=wb.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,Ab=!1,this.forceUpdate=!1}};const une=e=>T(new cne(e)),jb=new gs(-1,1,1,-1,0,1);var dne=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 fne=new dne;var Mb=class extends Ia{constructor(e=null){super(fne,e),this.camera=jb,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,jb)}render(e){e.render(this,jb)}};const pne=new lr;var mne=class extends fp{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:mt}){let i=new Fr(t,n,r);super(i.texture,op()),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 Mb(new w_),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(pne);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 fp(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const Nb=(e,...t)=>T(new mne(T(e),...t)),hne=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():Nb(e,...t),Pb=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)}),gne=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())}),_ne=O(([e,t,n])=>{let r=cp(gp(t)),i=dl(e.mul(r)).toVar(),a=gp(t,i).toVar(),o=gp(t,i.sub(dl(2,0))).toVar(),s=gp(t,i.sub(dl(1,0))).toVar(),c=gp(t,i.add(dl(1,0))).toVar(),l=gp(t,i.add(dl(2,0))).toVar(),u=gp(t,i.add(dl(0,2))).toVar(),d=gp(t,i.add(dl(0,1))).toVar(),f=gp(t,i.sub(dl(0,1))).toVar(),p=gp(t,i.sub(dl(0,2))).toVar(),m=hd(yu(k(2).mul(s).sub(o),a)).toVar(),h=hd(yu(k(2).mul(c).sub(l),a)).toVar(),g=hd(yu(k(2).mul(d).sub(u),a)).toVar(),_=hd(yu(k(2).mul(f).sub(p),a)).toVar(),v=Pb(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(Pb(e.sub(M(k(1).div(r.x),0)),s,n)),v.negate().add(Pb(e.add(M(k(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(Pb(e.add(M(0,k(1).div(r.y))),d,n)),v.negate().add(Pb(e.sub(M(0,k(1).div(r.y))),f,n)));return sd(Id(y,b))});var vne=class extends uo{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},yne=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 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 yne(e,n,r),a=hg(i,t,e);return a},xne=(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=hg(i,t,e);return a};var Sne=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 Cne=D(Sne),Fb=new xi,Ib=new di;var Lb=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=zm(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=zm(`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?(Fb.copy(r.backgroundRotation),Fb.x*=-1,Fb.y*=-1,Fb.z*=-1,Ib.makeRotationFromEuler(Fb)):Ib.identity(),Ib}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};Lb.BACKGROUND_BLURRINESS=`backgroundBlurriness`,Lb.BACKGROUND_INTENSITY=`backgroundIntensity`,Lb.BACKGROUND_ROTATION=`backgroundRotation`;const Rb=D(Lb,Lb.BACKGROUND_BLURRINESS),zb=D(Lb,Lb.BACKGROUND_INTENSITY),Bb=D(Lb,Lb.BACKGROUND_ROTATION);var wne=class extends fp{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 Vb=E(wne).setParameterLength(1,3),Tne=(e,t,n)=>{let r=Vb(e,t,n);return n!==null&&r.toStack(),r},Hb=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 Ub=class extends fp{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(cp(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return Hb({texture:this,uv:e})}};const Wb=E(Ub).setParameterLength(1,3);var Gb=class extends Rm{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 Kb=(e,t,n)=>T(new Gb(e,t,n)),qb=new WeakMap;var Ene=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=Yb(n);this.previousModelWorldMatrix.value.copy(r);let i=Jb(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}){Yb(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?Ap:uu(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul($p).mul(im),r=this.previousProjectionMatrix.mul(t).mul(am),i=n.xy.div(n.w),a=r.xy.div(r.w),o=yu(i,a);return o}};function Jb(e){let t=qb.get(e);return t===void 0&&(t={},qb.set(e,t)),t}function Yb(e,t=0){let n=Jb(e),r=n[t];return r===void 0&&(n[t]=r=new di,n[t].copy(e.matrixWorld)),r}const Xb=D(Ene),Zb=O(([e,t])=>kd(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Qb=O(([e,t])=>kd(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),$b=O(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),ex=O(([e,t])=>Wd(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),jd(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),tx=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`}]}),nx=O(([e])=>_l(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),rx=O(([e])=>(sl(e.a.equal(0),()=>_l(0)),_l(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),ix=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),Zb(e)),ax=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),Qb(e)),ox=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),$b(e)),sx=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),ex(e)),cx=O(([e])=>fx(e.rgb)),lx=O(([e,t=k(1)])=>t.mix(fx(e.rgb),e.rgb)),ux=O(([e,t=k(1)])=>{let n=vu(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 Wd(e.rgb,r,i)}),dx=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(Fd(n,e.rgb).mul(r.oneMinus())))))}),fx=(e,t=N(Cr.getLuminanceCoefficients(new C)))=>Fd(e,t),px=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=Ad(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 mx=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 hx=E(mx).setParameterLength(2),gx=new lr;var _x=class extends fp{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)}},vx=class extends _x{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)}},yx=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 vx(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 vx(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=s_(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=i_(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),gx.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(gx)),this._pixelRatio=i,this.setSize(gx.width,gx.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()}};yx.COLOR=`color`,yx.DEPTH=`depth`;const bx=(e,t,n)=>T(new yx(yx.COLOR,e,t,n)),xx=(e,t)=>T(new _x(e,t)),Sx=(e,t,n)=>T(new yx(yx.DEPTH,e,t,n));var Cx=class extends yx{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(yx.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 w_;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=re;let t=mm.negate(),n=Ap.mul($p),r=k(1),i=n.mul(_l(im,1)),a=n.mul(_l(im.add(t),1)),o=sd(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 wx=(e,t,n=new ra(0,0,0),r=.003,i=1)=>T(new Cx(e,t,T(n),T(r),T(i))),Tx=O(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Ex=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`}]}),Dx=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`}]}),Ox=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)}),kx=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=Ox(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Ax=Sl(N(1.6605,-.1246,-.0182),N(-.5876,1.1329,-.1006),N(-.0728,-.0083,1.1187)),jx=Sl(N(.6274,.0691,.0164),N(.3293,.9195,.088),N(.0433,.0113,.8956)),Mx=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(bu(40.14,r.mul(t))).add(bu(31.96,r).sub(bu(6.868,n.mul(t))).add(bu(.4298,n).add(bu(.1191,t).sub(.00232))))}),Nx=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(jx.mul(n)),n.assign(r.mul(n)),n.assign(Ad(n,1e-10)),n.assign(nd(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(Gd(n,0,1)),n.assign(Mx(n)),n.assign(i.mul(n)),n.assign(Ld(Ad(N(0),n),N(2.2))),n.assign(Ax.mul(n)),n.assign(Gd(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Px=O(([e,t])=>{let n=k(.76),r=k(.15);e=e.mul(t);let i=kd(e.r,kd(e.g,e.b)),a=rf(i.lessThan(.08),i.sub(bu(6.25,i.mul(i))),.04);e.subAssign(a);let o=Ad(e.r,Ad(e.g,e.b));sl(o.lessThan(n),()=>e);let s=yu(1,n),c=yu(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=yu(1,xu(1,r.mul(o.sub(c)).add(1)));return Wd(e,N(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var Fx=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 Ix=E(Fx).setParameterLength(1,3),Lx=(e,t)=>Ix(e,t,`js`),Rx=(e,t)=>Ix(e,t,`wgsl`),zx=(e,t)=>Ix(e,t,`glsl`);var Bx=class extends Fx{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
|
|
60
|
+
`).removeFlowTab();return e.addFlowTab(),a}};const wg=(...e)=>T(new Cg(al(e,`int`))).toStack(),Tg=()=>Qf(`continue`).toStack(),Eg=()=>Qf(`break`).toStack(),Dg=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),wg(...e)),Og=new WeakMap,kg=new Fr,Ag=O(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=A(ng).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=vp(e,pl(c,s)).depth(i).xyz;return l.mul(t)});function jg(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=Og.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 Rr(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&&(kg.fromBufferAttribute(a,e),p[f+i+0]=kg.x,p[f+i+1]=kg.y,p[f+i+2]=kg.z,p[f+i+3]=0),n===!0&&(kg.fromBufferAttribute(o,e),p[f+i+4]=kg.x,p[f+i+5]=kg.y,p[f+i+6]=kg.z,p[f+i+7]=0),r===!0&&(kg.fromBufferAttribute(l,e),p[f+i+8]=kg.x,p[f+i+9]=kg.y,p[f+i+10]=kg.z,p[f+i+11]=l.itemSize===4?kg.w:1)}}o={count:a,texture:m,stride:l,size:new ur(u,d)},Og.set(e,o);function g(){m.dispose(),Og.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var Mg=class extends hc{static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=fu(1),this.updateType=oc.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}=jg(t);n===!0&&om.mulAssign(this.morphBaseInfluence),r===!0&&gm.mulAssign(this.morphBaseInfluence);let l=A(c.width);wg(a,({i:e})=>{let t=k(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(vp(this.mesh.morphTexture,pl(A(e).add(1),A(rg))).r):t.assign(Vm(`morphTargetInfluences`,`float`).element(e).toVar()),ll(t.notEqual(0),()=>{n===!0&&om.addAssign(Ag({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:A(0)})),r===!0&&gm.addAssign(Ag({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 Ng=E(Mg).setParameterLength(1);var Pg=class extends hc{static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},Fg=class extends Pg{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},Ig=class extends lf{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 Lg=E(Ig);var Rg=class extends Pg{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let zg,Bg;var Vg=class e extends hc{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=oc.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=oc.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(Bg),Bg.multiplyScalar(t.getPixelRatio())):Bg.copy(n.viewport):n===null?t.getDrawingBufferSize(zg):(zg.width=n.width,zg.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?fu(zg||=new ur):t===e.VIEWPORT?fu(Bg||=new Fr):M(Wg.div(Ug)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(Ug).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};Vg.COORDINATE=`coordinate`,Vg.VIEWPORT=`viewport`,Vg.SIZE=`size`,Vg.UV=`uv`;const Hg=D(Vg,Vg.UV),Ug=D(Vg,Vg.SIZE),Wg=D(Vg,Vg.COORDINATE),Gg=D(Vg,Vg.VIEWPORT),Kg=Gg.zw,qg=Wg.sub(Gg.xy),Jg=qg.div(Kg),Yg=O(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),Ug),`vec2`).once()(),Xg=O(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),Hg),`vec2`).once()(),Zg=O(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),Hg.flipY()),`vec2`).once()(),Qg=new ur;var $g=class extends mp{static get type(){return`ViewportTextureNode`}constructor(e=Hg,t=null,n=null){n===null&&(n=new To,n.minFilter=at),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=oc.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(Qg);let n=this.value;(n.image.width!==Qg.width||n.image.height!==Qg.height)&&(n.image.width=Qg.width,n.image.height=Qg.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 e_=E($g).setParameterLength(0,3),t_=E($g,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let n_=null;var r_=class extends $g{static get type(){return`ViewportDepthTextureNode`}constructor(e=Hg,t=null){n_===null&&(n_=new Eo),super(e,t,n_)}};const i_=E(r_).setParameterLength(0,2);var a_=class e extends hc{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=f_().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?c_(um.z,Ap,jp):o_(um.z,Ap,jp);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=l_(r,Ap,jp);i=o_(e,Ap,jp)}else i=r;else i=o_(um.z,Ap,jp);return i}};a_.DEPTH_BASE=`depthBase`,a_.DEPTH=`depth`,a_.LINEAR_DEPTH=`linearDepth`;const o_=(e,t,n)=>e.add(t).div(t.sub(n)),s_=(e,t,n)=>t.sub(n).mul(e).sub(t),c_=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),l_=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),u_=(e,t,n)=>{t=t.max(1e-6).toVar();let r=id(e.negate().div(t)),i=id(n.div(t));return r.div(i)},d_=(e,t,n)=>{let r=e.mul(rd(n.div(t)));return k(Math.E).pow(r).mul(t).negate()},f_=E(a_,a_.DEPTH_BASE),p_=D(a_,a_.DEPTH),m_=E(a_,a_.LINEAR_DEPTH).setParameterLength(0,1),h_=m_(i_());p_.assign=e=>f_(e);var g_=class e extends hc{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=Tp(t);wg(a,({i:t})=>{let a=e.element(t);n.assign(um.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(Xd(r.negate(),r,n))})}let o=e.length;if(o>0){let t=Tp(e),a=k(1).toVar(`intersectionClipOpacity`);wg(o,({i:e})=>{let i=t.element(e);n.assign(um.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(Xd(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}jl.a.mulAssign(i),jl.a.equal(0).discard()})()}setupDefault(e,t){return O(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=Tp(t);wg(n,({i:t})=>{let n=e.element(t);um.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=Tp(e),n=fl(!0).toVar(`clipped`);wg(r,({i:e})=>{let r=t.element(e);n.assign(um.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),O(()=>{let r=Tp(e),i=Op(t.getClipDistance());wg(n,({i:e})=>{let t=r.element(e),n=um.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};g_.ALPHA_TO_COVERAGE=`alphaToCoverage`,g_.DEFAULT=`default`,g_.HARDWARE=`hardware`;const __=()=>T(new g_),v_=()=>T(new g_(g_.ALPHA_TO_COVERAGE)),y_=()=>T(new g_(g_.HARDWARE)),b_=.05,x_=O(([e])=>ud(Su(1e4,dd(Su(17,e.x).add(Su(.1,e.y)))).mul(bu(.1,_d(dd(Su(13,e.y).add(e.x))))))),S_=O(([e])=>x_(M(x_(e.xy),e.z))),C_=O(([e])=>{let t=Md(yd(Sd(e.xyz)),yd(Cd(e.xyz))),n=k(1).div(k(b_).mul(t)).toVar(`pixScale`),r=M(nd(sd(id(n))),nd(cd(id(n)))),i=M(S_(sd(r.x.mul(e.xyz))),S_(sd(r.y.mul(e.xyz)))),a=ud(id(n)),o=bu(Su(a.oneMinus(),i.x),Su(a,i.y)),s=jd(a,a.oneMinus()),c=N(o.mul(o).div(Su(2,s).mul(xu(1,s))),o.sub(Su(.5,s)).div(xu(1,s)),xu(1,xu(1,o).mul(xu(1,o)).div(Su(2,s).mul(xu(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return qd(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var w_=class extends op{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 Fr(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const T_=(e=0)=>T(new w_(e));var E_=class extends oa{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+Gs(this)}build(e){this.setup(e)}setupObserver(e){return new Bs(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=yl(r,jl.a).max(0);a=this.setupOutput(e,i),Yl.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&&Yl.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=yl(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=v_():e.stack.add(__())}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(y_()),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?u_(um.z,Ap,jp):o_(um.z,Ap,jp))}r!==null&&p_.assign(r).toStack()}setupPositionView(){return tm.mul(om).xyz}setupModelViewProjection(){return Mp.mul(um)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),eg}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&Ng(t).toStack(),t.isSkinnedMesh===!0&&xg(t).toStack(),this.displacementMap){let e=Wm(`displacementMap`,`texture`),t=Wm(`displacementScale`,`float`),n=Wm(`displacementBias`,`float`);om.addAssign(gm.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&pg(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&dg(t).toStack(),this.positionNode!==null&&om.assign(Gf(this.positionNode,`POSITION`)),om}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&fl(this.maskNode).not().discard();let n=this.colorNode?yl(this.colorNode):_h;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(T_())),e.instanceColor){let e=Al(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=Al(`vec3`,`vBatchColor`);n=e.mul(n)}jl.assign(n);let r=this.opacityNode?k(this.opacityNode):bh;jl.a.assign(jl.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?gh:k(this.alphaTestNode),jl.a.lessThanEqual(i).discard()),this.alphaHash===!0&&jl.a.lessThan(C_(om)).discard();let a=this.transparent===!1&&this.blending===oe&&this.alphaToCoverage===!1;a?jl.a.assign(1):i===null&&jl.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?N(0):jl.rgb}setupNormal(){return this.normalNode?N(this.normalNode):Oh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Wm(`envMap`,`cubeTexture`):Wm(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Rg(Zh)),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?Qh:this.aoNode;t.push(new Fg(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=Lg(o,t,n,r)}else n!==null&&(s=N(r===null?n:Kd(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Ml.assign(N(i||yh)),s=s.add(Ml)),s}setupFog(e,t){let n=e.fogNode;return n&&(Yl.assign(t),t=yl(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=oa.prototype.toJSON.call(this,e),r=Ks(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 D_=new Co;var O_=class extends E_{static get type(){return`LineBasicNodeMaterial`}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(D_),this.setValues(e)}};const k_=new Ro;var A_=class extends E_{static get type(){return`LineDashedNodeMaterial`}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(k_),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):Jh,t=this.dashScaleNode?k(this.dashScaleNode):Wh,n=this.dashSizeNode?k(this.dashSizeNode):Gh,r=this.gapSizeNode?k(this.gapSizeNode):Kh;Xl.assign(n),Zl.assign(r);let i=vf(sp(`lineDistance`).mul(t)),a=e?i.add(e):i;a.mod(Xl.add(Zl)).greaterThan(Xl).discard()}};let j_=null;var M_=class extends $g{static get type(){return`ViewportSharedTextureNode`}constructor(e=Hg,t=null){j_===null&&(j_=new To),super(e,t,j_)}updateReference(){return this}};const N_=E(M_).setParameterLength(0,2),P_=e=>T(e).mul(.5).add(.5),F_=e=>T(e).mul(2).sub(1),I_=new Fo;var L_=class extends E_{static get type(){return`MeshNormalNodeMaterial`}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(I_),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?k(this.opacityNode):bh;jl.assign(Ef(yl(P_(bm),e),hn))}},R_=class extends vc{static get type(){return`EquirectUVNode`}constructor(e=lm){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 z_=E(R_).setParameterLength(0,1);var B_=class extends to{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 Ba(5,5,5),a=z_(lm),o=new E_;o.colorNode=gp(t,a,0),o.side=re,o.blending=ae;let s=new La(i,o),c=new ao;c.add(s),t.minFilter===at&&(t.minFilter=rt);let l=new $a(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 V_=new WeakMap;var H_=class extends vc{static get type(){return`CubeMapNode`}constructor(e){super(`vec3`),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Lm(null);let t=new eo;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=oc.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(V_.has(e)){let t=V_.get(e);G_(t,e.mapping),this._cubeTexture=t}else{let n=e.image;if(U_(n)){let r=new B_(n.height);r.fromEquirectangularTexture(t,e),G_(r.texture,e.mapping),this._cubeTexture=r.texture,V_.set(e,r.texture),e.addEventListener(`dispose`,W_)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}};function U_(e){return e==null?!1:e.height>0}function W_(e){let t=e.target;t.removeEventListener(`dispose`,W_);let n=V_.get(t);n!==void 0&&(V_.delete(t),n.dispose())}function G_(e,t){t===Je?e.mapping=Ke:t===Ye&&(e.mapping=qe)}const K_=E(H_).setParameterLength(1);var q_=class extends Pg{static get type(){return`BasicEnvironmentNode`}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=K_(this.envNode)}},J_=class extends Pg{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)}},Y_=class{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}},X_=class extends Y_{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(yl(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(yl(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(jl.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(Kd(r.rgb,r.rgb.mul(i.rgb),wh.mul(Th)));break;case Ie:r.rgb.assign(Kd(r.rgb,i.rgb,wh.mul(Th)));break;case Le:r.rgb.addAssign(i.rgb.mul(wh.mul(Th)));break;default:console.warn(`THREE.BasicLightingModel: Unsupported .combine value:`,t.combine);break}}};const Z_=new sa;var Q_=class extends E_{static get type(){return`MeshBasicNodeMaterial`}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Z_),this.setValues(e)}setupNormal(){return vm}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new q_(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new J_(Zh)),t}setupOutgoingLight(){return jl.rgb}setupLightingModel(){return new X_}};const $_=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))}),ev=O(e=>e.diffuseColor.mul(1/Math.PI)),tv=()=>k(.25),nv=O(({dotNH:e})=>Jl.mul(k(.5)).add(1).mul(k(1/Math.PI)).mul(e.pow(Jl))),rv=O(({lightDirection:e})=>{let t=e.add(dm).normalize(),n=bm.dot(t).clamp(),r=dm.dot(t).clamp(),i=$_({f0:Kl,f90:1,dotVH:r}),a=tv(),o=nv({dotNH:n});return i.mul(a).mul(o)});var iv=class extends X_{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){let r=bm.dot(e).clamp(),i=r.mul(t);n.directDiffuse.addAssign(i.mul(ev({diffuseColor:jl.rgb}))),this.specular===!0&&n.directSpecular.addAssign(i.mul(rv({lightDirection:e})).mul(wh))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(ev({diffuseColor:jl}))),r.indirectDiffuse.mulAssign(t)}};const av=new Io;var ov=class extends E_{static get type(){return`MeshLambertNodeMaterial`}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(av),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new q_(t):null}setupLightingModel(){return new iv(!1)}};const sv=new No;var cv=class extends E_{static get type(){return`MeshPhongNodeMaterial`}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(sv),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new q_(t):null}setupLightingModel(){return new iv}setupVariants(){let e=(this.shininessNode?k(this.shininessNode):vh).max(1e-4);Jl.assign(e);let t=this.specularNode||xh;Kl.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}};const lv=O(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return k(0);let t=vm.dFdx().abs().max(vm.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),uv=O(e=>{let{roughness:t}=e,n=lv(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),dv=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 Cu(.5,i.add(a).max(qu))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),fv=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=Cu(.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`}]}),pv=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`}]}),mv=k(1/Math.PI),hv=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 mv.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`}]}),gv=O(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||bm,l=i.pow2(),u=t.add(dm).normalize(),d=c.dot(t).clamp(),f=c.dot(dm).clamp(),p=c.dot(u).clamp(),m=dm.dot(u).clamp(),h=$_({f0:n,f90:r,dotVH:m}),g,_;if(tl(o)&&(h=zl.mix(h,a)),tl(s)){let e=Wl.dot(t),n=Wl.dot(dm),r=Wl.dot(u),i=Gl.dot(t),a=Gl.dot(dm),o=Gl.dot(u);g=fv({alphaT:Hl,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=hv({alphaT:Hl,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=dv({alpha:l,dotNL:d,dotNV:f}),_=pv({alpha:l,dotNH:p});return h.mul(g).mul(_)}),_v=O(({roughness:e,dotNV:t})=>{let n=yl(-1,-.0275,-.572,.022),r=yl(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`}]}),vv=O(e=>{let{dotNV:t,specularColor:n,specularF90:r,roughness:i}=e,a=_v({dotNV:t,roughness:i});return n.mul(a.x).add(r.mul(a.y))}),yv=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`}]}),bv=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`}]}),xv=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`}]}),Sv=O(({lightDirection:e})=>{let t=e.add(dm).normalize(),n=bm.dot(e).clamp(),r=bm.dot(dm).clamp(),i=bm.dot(t).clamp(),a=bv({roughness:Rl,dotNH:i}),o=xv({dotNV:r,dotNL:n});return Ll.mul(a).mul(o)}),Cv=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`}]}),wv=O(({f:e})=>{let t=e.length();return Md(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:`LTC_ClippedSphereFormFactor`,type:`float`,inputs:[{name:`f`,type:`vec3`}]}),Tv=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,Md(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`}]}),Ev=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 ll(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(wl(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(Tv({v1:f,v2:p})),g.addAssign(Tv({v1:p,v2:m})),g.addAssign(Tv({v1:m,v2:h})),g.addAssign(Tv({v1:h,v2:f})),d.assign(N(wv({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`}]}),Dv=1/6,Ov=e=>Su(Dv,Su(e,Su(e,e.negate().add(3)).sub(3)).add(1)),kv=e=>Su(Dv,Su(e,Su(e,Su(3,e).sub(6))).add(4)),Av=e=>Su(Dv,Su(e,Su(e,Su(-3,e).add(3)).add(3)).add(1)),jv=e=>Su(Dv,zd(e,3)),Mv=e=>Ov(e).add(kv(e)),Nv=e=>Av(e).add(jv(e)),Pv=e=>bu(-1,kv(e).div(Ov(e).add(kv(e)))),Fv=e=>bu(1,jv(e).div(Av(e).add(jv(e)))),Iv=(e,t,n)=>{let r=e.uvNode,i=Su(r,t.zw).add(.5),a=sd(i),o=ud(i),s=Mv(o.x),c=Nv(o.x),l=Pv(o.x),u=Fv(o.x),d=Pv(o.y),f=Fv(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),_=Mv(o.y).mul(bu(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=Nv(o.y).mul(bu(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Lv=O(([e,t=k(3)])=>{let n=M(e.size(A(t))),r=M(e.size(A(t.add(1)))),i=Cu(1,n),a=Cu(1,r),o=Iv(e,yl(i,n),sd(t)),s=Iv(e,yl(a,r),cd(t));return ud(t).mix(o,s)}),Rv=O(([e,t,n,r,i])=>{let a=N(Yd(t.negate(),ld(e),Cu(1,r))),o=N(yd(i[0].xyz),yd(i[1].xyz),yd(i[2].xyz));return ld(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`}]}),zv=O(([e,t])=>e.mul(qd(t.mul(2).sub(2),0,1))).setLayout({name:`applyIorToRoughness`,type:`float`,inputs:[{name:`roughness`,type:`float`},{name:`ior`,type:`float`}]}),Bv=t_(),Vv=t_(),Hv=O(([e,t,n],{material:r})=>{let i=r.side===re?Bv:Vv,a=i.sample(e),o=id(Ug.x).mul(zv(t,n));return Lv(a,o)}),Uv=O(([e,t,n])=>(ll(n.notEqual(0),()=>{let r=rd(t).negate().div(n),i=td(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`}]}),Wv=O(([e,t,n,r,i,a,o,s,c,l,u,d,f,p,m])=>{let h,g;if(m){h=yl().toVar(),g=N().toVar();let i=u.sub(1).mul(m.mul(.025)),a=N(u.sub(i),u,u.add(i));wg({start:0,end:3},({i})=>{let u=a.element(i),m=Rv(e,t,d,u,s),_=o.add(m),v=l.mul(c.mul(yl(_,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=Hv(y,n,u);h.element(i).assign(b.element(i)),h.a.addAssign(b.a),g.element(i).assign(r.element(i).mul(Uv(yd(m),f,p).element(i)))}),h.a.divAssign(3)}else{let i=Rv(e,t,d,u,s),a=o.add(i),m=l.mul(c.mul(yl(a,1))),_=M(m.xy.div(m.w)).toVar();_.addAssign(1),_.divAssign(2),_.assign(M(_.x,_.y.oneMinus())),h=Hv(_,n,u),g=r.mul(Uv(yd(i),f,p))}let _=g.rgb.mul(h.rgb),v=e.dot(t).clamp(),y=N(vv({dotNV:v,specularColor:i,specularF90:a,roughness:n})),b=g.r.add(g.g,g.b).div(3);return yl(y.oneMinus().mul(_),h.a.oneMinus().mul(b).oneMinus())}),Gv=wl(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Kv=e=>{let t=e.sqrt();return N(1).add(t).div(N(1).sub(t))},qv=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Jv=(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=Gv.mul(s);return c},Yv=O(({outsideIOR:e,eta2:t,cosTheta1:n,thinFilmThickness:r,baseF0:i})=>{let a=Kd(e,t,Xd(0,.03,r)),o=e.div(a).pow2().mul(n.pow2().oneMinus()),s=o.oneMinus();ll(s.lessThan(0),()=>N(1));let c=s.sqrt(),l=qv(a,e),u=$_({f0:l,f90:1,dotVH:n}),d=u.oneMinus(),f=a.lessThan(e).select(Math.PI,0),p=k(Math.PI).sub(f),m=Kv(i.clamp(0,.9999)),h=qv(m,a.toVec3()),g=$_({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 wg({start:1,end:2,condition:`<=`,name:`m`},({m:e})=>{ne.mulAssign(x);let t=Jv(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`}]}),Xv=O(({normal:e,viewDir:t,roughness:n})=>{let r=e.dot(t).saturate(),i=n.pow2(),a=sf(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=sf(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=sf(n.lessThan(.25),0,k(.1).mul(n).sub(.025)).add(a.mul(r).add(o).exp());return s.mul(1/Math.PI).saturate()}),Zv=N(.04),Qv=k(1);var $v=class extends Y_{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=bm.dot(dm).clamp();this.iridescenceFresnel=Yv({outsideIOR:k(1),eta2:Bl,cosTheta1:e,thinFilmThickness:Vl,baseF0:Kl}),this.iridescenceF0=yv({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(this.transmission===!0){let t=cm,n=Lp.sub(cm).normalize(),r=xm,i=e.context;i.backdrop=Wv(r,n,Nl,jl,Kl,ql,t,Jp,Pp,Mp,$l,tu,ru,nu,this.dispersion?iu:null),i.backdropAlpha=eu,jl.a.mulAssign(Kd(1,i.backdrop.a,eu))}super.start(e)}computeMultiscattering(e,t,n){let r=bm.dot(dm).clamp(),i=_v({roughness:Nl,dotNV:r}),a=this.iridescenceF0?zl.mix(Kl,this.iridescenceF0):Kl,o=a.mul(i.x).add(n.mul(i.y)),s=i.x.add(i.y),c=s.oneMinus(),l=Kl.add(Kl.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=bm.dot(e).clamp(),i=r.mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(i.mul(Sv({lightDirection:e}))),this.clearcoat===!0){let n=Sm.dot(e).clamp(),r=n.mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(gv({lightDirection:e,f0:Zv,f90:Qv,roughness:Il,normalView:Sm})))}n.directDiffuse.addAssign(i.mul(ev({diffuseColor:jl.rgb}))),n.directSpecular.addAssign(i.mul(gv({lightDirection:e,f0:Kl,f90:1,roughness:Nl,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=bm,f=dm,p=um.toVar(),m=Cv({N:d,V:f,roughness:Nl}),h=a.sample(m).toVar(),g=o.sample(m).toVar(),_=wl(N(h.x,0,h.y),N(0,1,0),N(h.z,0,h.w)).toVar(),v=Kl.mul(g.x).add(Kl.oneMinus().mul(g.y)).toVar();i.directSpecular.addAssign(e.mul(v).mul(Ev({N:d,V:f,P:p,mInv:_,p0:s,p1:c,p2:l,p3:u}))),i.directDiffuse.addAssign(e.mul(jl).mul(Ev({N:d,V:f,P:p,mInv:wl(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(ev({diffuseColor:jl})))}indirectSpecular(e){let{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Ll,Xv({normal:bm,viewDir:dm,roughness:Rl}))),this.clearcoat===!0){let e=Sm.dot(dm).clamp(),t=vv({dotNV:e,specularColor:Zv,specularF90:Qv,roughness:Il});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,ql);let s=i.add(a),c=jl.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=bm.dot(dm).clamp(),i=r.add(t),a=Nl.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=Sm.dot(dm).clamp(),n=$_({dotVH:e,f0:Zv,f90:Qv}),r=t.mul(Fl.mul(n).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Fl));t.assign(r)}if(this.sheen===!0){let e=Ll.r.max(Ll.g).max(Ll.b).mul(.157).oneMinus(),n=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(n)}}};const ey=k(1),ty=k(-2),ny=k(.8),ry=k(-1),iy=k(.4),ay=k(2),oy=k(.305),sy=k(3),cy=k(.21),ly=k(4),uy=k(4),dy=k(16),fy=O(([e])=>{let t=N(_d(e)).toVar(),n=k(-1).toVar();return ll(t.x.greaterThan(t.z),()=>{ll(t.x.greaterThan(t.y),()=>{n.assign(sf(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(sf(e.y.greaterThan(0),1,4))})}).Else(()=>{ll(t.z.greaterThan(t.y),()=>{n.assign(sf(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(sf(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),py=O(([e,t])=>{let n=M().toVar();return ll(t.equal(0),()=>{n.assign(M(e.z,e.y).div(_d(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(M(e.x.negate(),e.z.negate()).div(_d(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(M(e.x.negate(),e.y).div(_d(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(M(e.z.negate(),e.y).div(_d(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(M(e.x.negate(),e.z).div(_d(e.y)))}).Else(()=>{n.assign(M(e.x,e.y).div(_d(e.z)))}),Su(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),my=O(([e])=>{let t=k(0).toVar();return ll(e.greaterThanEqual(ny),()=>{t.assign(ey.sub(e).mul(ry.sub(ty)).div(ey.sub(ny)).add(ty))}).ElseIf(e.greaterThanEqual(iy),()=>{t.assign(ny.sub(e).mul(ay.sub(ry)).div(ny.sub(iy)).add(ry))}).ElseIf(e.greaterThanEqual(oy),()=>{t.assign(iy.sub(e).mul(sy.sub(ay)).div(iy.sub(oy)).add(ay))}).ElseIf(e.greaterThanEqual(cy),()=>{t.assign(oy.sub(e).mul(ly.sub(sy)).div(oy.sub(cy)).add(sy))}).Else(()=>{t.assign(k(-2).mul(id(Su(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),hy=O(([e,t])=>{let n=e.toVar();n.assign(Su(2,n).sub(1));let r=N(n,1).toVar();return ll(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`}]}),gy=O(([e,t,n,r,i,a])=>{let o=k(n),s=N(t),c=qd(my(o),ty,a),l=ud(c),u=sd(c),d=N(_y(e,s,u,r,i,a)).toVar();return ll(l.notEqual(0),()=>{let t=N(_y(e,s,u.add(1),r,i,a)).toVar();d.assign(Kd(d,t,l))}),d}),_y=O(([e,t,n,r,i,a])=>{let o=k(n).toVar(),s=N(t),c=k(fy(s)).toVar(),l=k(Md(uy.sub(o),0)).toVar();o.assign(Md(o,uy));let u=k(nd(o)).toVar(),d=M(py(s,c).mul(u.sub(2)).add(1)).toVar();return ll(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(Su(3,dy))),d.y.addAssign(Su(4,nd(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(M(),M())}),vy=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=fd(r),l=n.mul(c).add(i.cross(n).mul(dd(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return _y(e,l,t,a,o,s)}),yy=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(sf(t,n,Rd(n,r))).toVar();ll(f.equal(N(0)),()=>{f.assign(N(r.z,0,r.x.negate()))}),f.assign(ld(f));let p=N().toVar();return p.addAssign(i.element(0).mul(vy({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),wg({start:A(1),end:e},({i:e})=>{ll(e.greaterThanEqual(a),()=>{Eg()});let t=k(o.mul(k(e))).toVar();p.addAssign(i.element(e).mul(vy({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(vy({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),yl(p,1)}),by=4,xy=[.125,.215,.35,.446,.526,.582],Sy=20,Cy=new _s(-1,1,1,-1,0,1),wy=new Xa(90,1),Ty=new ia;let Ey=null,Dy=0,Oy=0;const ky=(1+Math.sqrt(5))/2,Ay=1/ky,jy=[new C(-ky,Ay,0),new C(ky,Ay,0),new C(-Ay,0,ky),new C(Ay,0,ky),new C(0,ky,-Ay),new C(0,ky,Ay),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)],My=new C,Ny=new WeakMap,Py=[3,1,5,0,4,2],Fy=hy(cp(),sp(`faceIndex`)).normalize(),Iy=N(Fy.x,Fy.y,Fy.z);var Cee=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=My,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}Ey=this._renderer.getRenderTarget(),Dy=this._renderer.getActiveCubeFace(),Oy=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=By(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vy(),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(Ey,Dy,Oy),e.scissorTest=!1,Ry(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Ey=this._renderer.getRenderTarget(),Dy=this._renderer.getActiveCubeFace(),Oy=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=Ly(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=Ly(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=wee(t)),this._blurMaterial=Tee(t,e.width,e.height)}}async _compileMaterial(e){let t=new La(this._lodPlanes[0],e);await this._renderer.compile(t,Cy)}_sceneToCubeUV(e,t,n,r,i){let a=wy;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(Ty),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new sa({name:`PMREM.Background`,side:re,depthWrite:!1,depthTest:!1});u=new La(new Ba,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(Ty),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;Ry(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=By(e)):this._equirectMaterial===null&&(this._equirectMaterial=Vy(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;Ry(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Cy)}_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=jy[(r-t-1)%jy.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=Ny.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*Sy-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):Sy;h>Sy&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${Sy}`);let g=[],_=0;for(let e=0;e<Sy;++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-by?r-v+by:0),x=4*(this._cubeSize-y);Ry(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,Cy)}};function wee(e){let t=[],n=[],r=[],i=[],a=e,o=e-by+1+xy.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-by?c=xy[s-e+by-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=Py[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 Ta;x.setAttribute(`position`,new pa(v,h)),x.setAttribute(`uv`,new pa(y,g)),x.setAttribute(`faceIndex`,new pa(b,_)),t.push(x),i.push(new La(x,null)),a>by&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function Ly(e,t){let n={magFilter:rt,minFilter:rt,generateMipmaps:!1,type:mt,format:bt,colorSpace:gn},r=new Ir(e,t,n);return r.texture.mapping=Xe,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function Ry(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function zy(e){let t=new E_;return t.depthTest=!1,t.depthWrite=!1,t.blending=ae,t.name=`PMREM_${e}`,t}function Tee(e,t,n){let r=Tp(Array(Sy).fill(0)),i=fu(new C(0,1,0)),a=fu(0),o=k(Sy),s=fu(0),c=fu(1),l=gp(null),u=fu(0),d=k(1/t),f=k(1/n),p=k(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:Iy,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=zy(`blur`);return h.fragmentNode=yy({...m,latitudinal:s.equal(1)}),Ny.set(h,m),h}function By(e){let t=zy(`cubemap`);return t.fragmentNode=Lm(e,Iy),t}function Vy(e){let t=zy(`equirect`);return t.fragmentNode=gp(e,z_(Iy),0),t}const Hy=new WeakMap;function Eee(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 Dee(e,t,n){let r=Oee(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(Aee(t))i=n.fromCubemap(e,i);else return null;else if(jee(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function Oee(e){let t=Hy.get(e);return t===void 0&&(t=new WeakMap,Hy.set(e,t)),t}var kee=class extends vc{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 Pr;r.isRenderTargetTexture=!0,this._texture=gp(r),this._width=fu(0),this._height=fu(0),this._maxMip=fu(0),this.updateBeforeType=oc.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=Eee(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:Dee(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new Cee(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=km.mul(N(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),gy(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function Aee(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 jee(e){return e==null?!1:e.height>0}const Uy=E(kee).setParameterLength(1,3),Wy=new WeakMap;var Mee=class extends Pg{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=Wy.get(e);r===void 0&&(r=Uy(e),Wy.set(e,r)),n=r}let r=t.useAnisotropy===!0||t.anisotropy>0,i=r?sh:bm,a=n.context(Gy(Nl,i)).mul(Om),o=n.context(Nee(xm)).mul(Math.PI).mul(Om),s=Wf(a),c=Wf(o);e.context.radiance.addAssign(s),e.context.iblIrradiance.addAssign(c);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=n.context(Gy(Il,Sm)).mul(Om),t=Wf(e);l.addAssign(t)}}};const Gy=(e,t)=>{let n=null;return{getUV:()=>(n===null&&(n=dm.negate().reflect(t),n=e.mul(e).mix(n,t).normalize(),n=n.transformDirection(Pp)),n),getTextureLevel:()=>e}},Nee=e=>({getUV:()=>e,getTextureLevel:()=>k(1)}),Pee=new jo;var Ky=class extends E_{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(Pee),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new Mee(t):null}setupLightingModel(){return new $v}setupSpecular(){let e=Kd(N(.04),jl.rgb,Pl);Kl.assign(e),ql.assign(1)}setupVariants(){let e=this.metalnessNode?k(this.metalnessNode):Dh;Pl.assign(e);let t=this.roughnessNode?k(this.roughnessNode):Eh;t=uv({roughness:t}),Nl.assign(t),this.setupSpecular(),jl.assign(yl(jl.rgb.mul(e.oneMinus()),jl.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}};const Fee=new Mo;var Iee=class extends Ky{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(Fee),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):Vh;$l.assign(e),Kl.assign(Kd(jd(Bd($l.sub(1).div($l.add(1))).mul(Ch),N(1)).mul(Sh),jl.rgb,Pl)),ql.assign(Kd(Sh,1,Pl))}setupLightingModel(){return new $v(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):kh,t=this.clearcoatRoughnessNode?k(this.clearcoatRoughnessNode):Ah;Fl.assign(e),Il.assign(uv({roughness:t}))}if(this.useSheen){let e=this.sheenNode?N(this.sheenNode):Nh,t=this.sheenRoughnessNode?k(this.sheenRoughnessNode):Ph;Ll.assign(e),Rl.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?k(this.iridescenceNode):Ih,t=this.iridescenceIORNode?k(this.iridescenceIORNode):Lh,n=this.iridescenceThicknessNode?k(this.iridescenceThicknessNode):Rh;zl.assign(e),Bl.assign(t),Vl.assign(n)}if(this.useAnisotropy){let e=(this.anisotropyNode?M(this.anisotropyNode):Fh).toVar();Ul.assign(e.length()),ll(Ul.equal(0),()=>{e.assign(M(1,0))}).Else(()=>{e.divAssign(M(Ul)),Ul.assign(Ul.saturate())}),Hl.assign(Ul.pow2().mix(Nl.pow2(),1)),Wl.assign(ih[0].mul(e.x).add(ih[1].mul(e.y))),Gl.assign(ih[1].mul(e.x).sub(ih[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?k(this.transmissionNode):zh,t=this.thicknessNode?k(this.thicknessNode):Bh,n=this.attenuationDistanceNode?k(this.attenuationDistanceNode):Hh,r=this.attenuationColorNode?N(this.attenuationColorNode):Uh;if(eu.assign(e),tu.assign(t),nu.assign(n),ru.assign(r),this.useDispersion){let e=this.dispersionNode?k(this.dispersionNode):Xh;iu.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?N(this.clearcoatNormalNode):jh}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 Lee=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=Wm(`gradientMap`,`texture`).context({getUV:()=>i});return N(e.r)}else{let e=i.fwidth().mul(.5);return Kd(N(.7),N(1),Xd(k(.7).sub(e.x),k(.7).add(e.x),i.x))}});var Ree=class extends Y_{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){let i=Lee({normal:hm,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(i.mul(ev({diffuseColor:jl.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(ev({diffuseColor:jl}))),r.indirectDiffuse.mulAssign(t)}};const zee=new Po;var Bee=class extends E_{static get type(){return`MeshToonNodeMaterial`}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(zee),this.setValues(e)}setupLightingModel(){return new Ree}},Vee=class extends vc{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=N(dm.z,0,dm.x.negate()).normalize(),t=dm.cross(e);return M(e.dot(bm),t.dot(bm)).mul(.495).add(.5)}};const qy=D(Vee),Hee=new Lo;var Uee=class extends E_{static get type(){return`MeshMatcapNodeMaterial`}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Hee),this.setValues(e)}setupVariants(e){let t=qy,n;n=e.material.matcap?Wm(`matcap`,`texture`).context({getUV:()=>t}):N(Kd(.2,.8,t.y)),jl.rgb.mulAssign(n.rgb)}},Wee=class extends vc{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=Cl(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=Tl(yl(1,0,0,0),yl(0,fd(e.x),dd(e.x).negate(),0),yl(0,dd(e.x),fd(e.x),0),yl(0,0,0,1)),i=Tl(yl(fd(e.y),0,dd(e.y),0),yl(0,1,0,0),yl(dd(e.y).negate(),0,fd(e.y),0),yl(0,0,0,1)),a=Tl(yl(fd(e.z),dd(e.z).negate(),0,0),yl(dd(e.z),fd(e.z),0,0),yl(0,0,1,0),yl(0,0,0,1));return r.mul(i).mul(a).mul(yl(n,1)).xyz}}};const Jy=E(Wee).setParameterLength(2),Gee=new lo;var Yy=class extends E_{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(Gee),this.setValues(e)}setupPositionView(e){let{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:i,rotationNode:a,scaleNode:o}=this,s=tm.mul(N(i||0)),c=M(Jp[0].xyz.length(),Jp[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(Mp.element(1).element(1));c=c.mul(e.mul(2))}let l=am.xy;if(t.center&&t.center.isVector2===!0){let e=Af(`center`,`vec2`,t);l=l.sub(e.sub(.5))}l=l.mul(c);let u=k(a||Mh),d=Jy(l,u);return yl(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 Kee=new wo;var qee=class extends Yy{static get type(){return`PointsNodeMaterial`}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Kee),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return tm.mul(N(e||om)).xyz}setupVertex(e){let t=super.setupVertex(e);if(e.material.isNodeMaterial!==!0)return t;let{rotationNode:n,scaleNode:r,sizeNode:i}=this,a=am.xy.toVar(),o=Gg.z.div(Gg.w);if(n&&n.isNode){let e=k(n);a.assign(Jy(a,e))}let s=i===null?Yh:M(i);return this.sizeAttenuation===!0&&(s=s.mul(s.div(um.z.negate()))),r&&r.isNode&&(s=s.mul(M(r))),a.mulAssign(s.mul(2)),a.assign(a.div(Gg.z)),a.y.assign(a.y.mul(o)),a.assign(a.mul(t.w)),t.addAssign(yl(a,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}},Jee=class extends Y_{constructor(){super(),this.shadowNode=k(1).toVar(`shadowMask`)}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){jl.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(jl.rgb)}};const Yee=new Ao;var Xee=class extends E_{static get type(){return`ShadowNodeMaterial`}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Yee),this.setValues(e)}setupLightingModel(){return new Jee}};const Zee=kl(`vec3`),Qee=kl(`vec3`),$ee=kl(`vec3`);var ete=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()}},Xy=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 tte=0;function nte(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 rte=class{constructor(e,t,n,r,i,a,o,s,c,l){this.id=tte++,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 nte(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+`,`,Hs(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=Ws(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ws(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener(`dispose`,this.onMaterialDispose),this.onDispose()}};const Zy=[];var ite=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);Zy[0]=e,Zy[1]=t,Zy[2]=a,Zy[3]=i;let l=c.get(Zy);return l===void 0?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,i,a,o,s),c.set(Zy,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)))),Zy.length=0,l}getChainMap(e=`default`){return this.chainMaps[e]||(this.chainMaps[e]=new Xy)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,i,a,o,s,c,l,u){let d=this.getChainMap(u),f=new rte(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}},Qy=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 $y={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},eb=16,ate=211,ote=212;var ste=class extends Qy{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===$y.VERTEX?this.backend.createAttribute(e):t===$y.INDEX?this.backend.createIndexAttribute(e):t===$y.STORAGE?this.backend.createStorageAttribute(e):t===$y.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(n.version<t.version||t.usage===Wn)&&(this.backend.updateAttribute(e),n.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}};function tb(e){return e.index===null?e.attributes.position.version:e.index.version}function nb(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(gr(t)?ha:ma)(t,1);return i.version=tb(e),i}var cte=class extends Qy{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,$y.STORAGE):this.updateAttribute(e,$y.VERTEX);let n=this.getIndex(e);n!==null&&this.updateAttribute(n,$y.INDEX);let r=e.geometry.indirect;r!==null&&this.updateAttribute(r,$y.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=nb(t),e.set(t,n)):n.version!==tb(t)&&(this.attributes.delete(n),n=nb(t),e.set(t,n)),r=n}return r}},lte=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}},rb=class{constructor(e){this.cacheKey=e,this.usedTimes=0}},ute=class extends rb{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}},dte=class extends rb{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}};let fte=0;var ib=class{constructor(e,t,n,r=null,i=null){this.id=fte++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=i,this.usedTimes=0}},pte=class extends Qy{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 ib(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 ib(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 ib(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 dte(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 ute(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)}},mte=class extends Qy{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?$y.INDIRECT:$y.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?$y.INDIRECT:$y.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 hte(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 ab(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 ob(e){let t=e.transmission>0||e.transmissionNode;return t&&e.side===ie&&e.forceSinglePass===!1}var gte=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?(ob(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?(ob(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||hte),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||ab),this.transparent.length>1&&this.transparent.sort(t||ab)}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 sb=[];var _te=class{constructor(e){this.lighting=e,this.lists=new Xy}get(e,t){let n=this.lists;sb[0]=e,sb[1]=t;let r=n.get(sb);return r===void 0&&(r=new gte(this.lighting,e,t),n.set(sb,r)),sb.length=0,r}dispose(){this.lists=new Xy}};let vte=0;var yte=class{constructor(){this.id=vte++,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 Fr,this.scissor=!1,this.scissorValue=new Fr,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 cb(this)}};function cb(e){let{textures:t,activeCubeFace:n}=e,r=[n];for(let e of t)r.push(e.id);return Us(r)}const lb=[],bte=new ao,xte=new Ka;var Ste=class{constructor(){this.chainMaps={}}get(e,t,n=null){lb[0]=e,lb[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(lb);return a===void 0&&(a=new yte,i.set(lb,a)),lb.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(bte,xte,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Xy)}dispose(){this.chainMaps={}}};const Cte=new C;var wte=class extends Qy{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 Eo,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=Cte){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--)}},ub=class extends ia{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)}},db=class extends Ol{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const Tte=(e,t)=>T(new db(e,t));var Ete=class extends hc{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 rl(t);return this._currentCond=sf(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new rl(t),r=sf(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new rl(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 rl(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=sf(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=cl();sl(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 sl(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 fb=E(Ete).setParameterLength(0,1);function Dte(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 Ote=class extends hc{static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=Dte(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=Qs(i)*t,o=$s(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)}},kte=class extends hc{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 Ate=(e,t=null)=>{let n=new Ote(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 kte(n,r))};return r.layout=n,r.isStruct=!0,r};var pb=class extends hc{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 jte=E(pb);function mb(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Mte=class extends pb{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 hb(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=mb(i,e);r[n]=yl(t[e])}return this.members=r,super.setup(e)}};const hb=E(Mte),Nte=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)}),gb=(e,t)=>zd(Su(4,e.mul(xu(1,e))),t),Pte=(e,t)=>e.lessThan(.5)?gb(e.mul(2),t).div(2):xu(1,gb(Su(xu(1,e),2),t).div(2)),Fte=(e,t,n)=>zd(Cu(zd(e,t),bu(zd(e,t),zd(xu(1,e),n))),1/t),Ite=(e,t)=>dd(Yu.mul(t.mul(e).sub(1))).div(Yu.mul(t.mul(e).sub(1))),_b=O(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Lte=O(([e])=>N(_b(e.z.add(_b(e.y.mul(1)))),_b(e.z.add(_b(e.x.mul(1)))),_b(e.y.add(_b(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Rte=O(([e,t,n])=>{let r=N(e).toVar(),i=k(1.4).toVar(),a=k(0).toVar(),o=N(r).toVar();return wg({start:k(0),end:k(3),type:`float`,condition:`<=`},()=>{let e=N(Lte(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(_b(r.z.add(_b(r.x.add(_b(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 zte=class extends hc{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 Bte=E(zte),vb=e=>(...t)=>Bte(e,...t),yb=fu(0).setGroup(lu).onRenderUpdate(e=>e.time),bb=fu(0).setGroup(lu).onRenderUpdate(e=>e.deltaTime),Vte=fu(0,`uint`).setGroup(lu).onRenderUpdate(e=>e.frameId),Hte=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),yb.mul(e)),Ute=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),yb.mul(e)),Wte=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),bb.mul(e)),Gte=(e=yb)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Kte=(e=yb)=>e.fract().round(),qte=(e=yb)=>e.add(.5).fract().mul(2).sub(1).abs(),Jte=(e=yb)=>e.fract(),Yte=O(([e,t,n=M(.5)])=>Jy(e.sub(n),t).add(n)),Xte=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))}),Zte=O(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=Jp:(r=Jp.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Pp.mul(r);return tl(t)&&(i[0][0]=Jp[0].length(),i[0][1]=0,i[0][2]=0),tl(n)&&(i[1][0]=0,i[1][1]=Jp[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Mp.mul(i).mul(om)}),Qte=O(([e=null])=>{let t=m_(),n=m_(i_(e)).sub(t),r=n.lessThan(0).select(Hg,e);return r});var $te=class extends hc{static get type(){return`SpriteSheetUVNode`}constructor(e,t=cp(),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 ene=E($te).setParameterLength(3);var tne=class extends hc{static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=k(1),i=om,a=gm){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=gp(u,s).mul(o.x),m=gp(d,c).mul(o.y),h=gp(f,l).mul(o.z);return bu(p,m,h)}};const xb=E(tne).setParameterLength(1,6),nne=(...e)=>xb(...e),Sb=new go,Cb=new C,wb=new C,Tb=new C,Eb=new fi,Db=new C(0,0,-1),Ob=new Fr,kb=new C,Ab=new C,jb=new Fr,Mb=new ur,Nb=new Ir,rne=Hg.flipX();Nb.depthTexture=new Eo(1,1);let Pb=!1;var ine=class e extends mp{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||Nb.texture,rne),this._reflectorBaseNode=e.reflector||new ane(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:Nb.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()}},ane=class extends hc{static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new zi,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?oc.RENDER:oc.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(Mb),e.setSize(Math.round(Mb.width*n),Math.round(Mb.height*n))}setup(e){return this._updateResolution(Nb,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 Ir(0,0,{type:mt}),this.generateMipmaps===!0&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Eo),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Pb)return!1;Pb=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(Mb),this._updateResolution(s,r),wb.setFromMatrixPosition(a.matrixWorld),Tb.setFromMatrixPosition(n.matrixWorld),Eb.extractRotation(a.matrixWorld),Cb.set(0,0,1),Cb.applyMatrix4(Eb),kb.subVectors(wb,Tb);let c=kb.dot(Cb)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Pb=!1;return}l=!0}kb.reflect(Cb).negate(),kb.add(wb),Eb.extractRotation(n.matrixWorld),Db.set(0,0,-1),Db.applyMatrix4(Eb),Db.add(Tb),Ab.subVectors(wb,Db),Ab.reflect(Cb).negate(),Ab.add(wb),o.coordinateSystem=n.coordinateSystem,o.position.copy(kb),o.up.set(0,1,0),o.up.applyMatrix4(Eb),o.up.reflect(Cb),o.lookAt(Ab),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),Sb.setFromNormalAndCoplanarPoint(Cb,wb),Sb.applyMatrix4(o.matrixWorldInverse),Ob.set(Sb.normal.x,Sb.normal.y,Sb.normal.z,Sb.constant);let u=o.projectionMatrix;jb.x=(Math.sign(Ob.x)+u.elements[8])/u.elements[0],jb.y=(Math.sign(Ob.y)+u.elements[9])/u.elements[5],jb.z=-1,jb.w=(1+u.elements[10])/u.elements[14],Ob.multiplyScalar(1/Ob.dot(jb));let d=0;u.elements[2]=Ob.x,u.elements[6]=Ob.y,u.elements[10]=r.coordinateSystem===Kn?Ob.z-d:Ob.z+1-d,u.elements[14]=Ob.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,Pb=!1,this.forceUpdate=!1}};const one=e=>T(new ine(e)),Fb=new _s(-1,1,1,-1,0,1);var sne=class extends Ta{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new _a([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new _a(t,2))}};const cne=new sne;var Ib=class extends La{constructor(e=null){super(cne,e),this.camera=Fb,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Fb)}render(e){e.render(this,Fb)}};const lne=new ur;var une=class extends mp{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:mt}){let i=new Ir(t,n,r);super(i.texture,cp()),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 Ib(new E_),this.updateBeforeType=oc.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(lne);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 mp(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const Lb=(e,...t)=>T(new une(T(e),...t)),dne=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():Lb(e,...t),Rb=O(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===Kn?(e=M(e.x,e.y.oneMinus()).mul(2).sub(1),i=yl(N(e,t),1)):i=yl(N(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=yl(n.mul(i));return a.xyz.div(a.w)}),fne=O(([e,t])=>{let n=t.mul(yl(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return M(r.x,r.y.oneMinus())}),pne=O(([e,t,n])=>{let r=up(vp(t)),i=pl(e.mul(r)).toVar(),a=vp(t,i).toVar(),o=vp(t,i.sub(pl(2,0))).toVar(),s=vp(t,i.sub(pl(1,0))).toVar(),c=vp(t,i.add(pl(1,0))).toVar(),l=vp(t,i.add(pl(2,0))).toVar(),u=vp(t,i.add(pl(0,2))).toVar(),d=vp(t,i.add(pl(0,1))).toVar(),f=vp(t,i.sub(pl(0,1))).toVar(),p=vp(t,i.sub(pl(0,2))).toVar(),m=_d(xu(k(2).mul(s).sub(o),a)).toVar(),h=_d(xu(k(2).mul(c).sub(l),a)).toVar(),g=_d(xu(k(2).mul(d).sub(u),a)).toVar(),_=_d(xu(k(2).mul(f).sub(p),a)).toVar(),v=Rb(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(Rb(e.sub(M(k(1).div(r.x),0)),s,n)),v.negate().add(Rb(e.add(M(k(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(Rb(e.add(M(0,k(1).div(r.y))),d,n)),v.negate().add(Rb(e.sub(M(0,k(1).div(r.y))),f,n)));return ld(Rd(y,b))});var mne=class extends fo{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},hne=class extends pa{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const gne=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=Xs(`float`)):(n=Zs(t),r=Xs(t));let i=new hne(e,n,r),a=_g(i,t,e);return a},_ne=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=Xs(`float`)):(n=Zs(t),r=Xs(t));let i=new mne(e,n,r),a=_g(i,t,e);return a};var vne=class extends hc{static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const yne=D(vne),zb=new Si,Bb=new fi;var Vb=class e extends hc{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=Vm(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=Vm(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=fu(`mat4`).label(`backgroundRotation`).setGroup(lu).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==Ge?(zb.copy(r.backgroundRotation),zb.x*=-1,zb.y*=-1,zb.z*=-1,Bb.makeRotationFromEuler(zb)):Bb.identity(),Bb}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};Vb.BACKGROUND_BLURRINESS=`backgroundBlurriness`,Vb.BACKGROUND_INTENSITY=`backgroundIntensity`,Vb.BACKGROUND_ROTATION=`backgroundRotation`;const Hb=D(Vb,Vb.BACKGROUND_BLURRINESS),Ub=D(Vb,Vb.BACKGROUND_INTENSITY),Wb=D(Vb,Vb.BACKGROUND_ROTATION);var bne=class extends mp{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=cc.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(cc.READ_WRITE)}toReadOnly(){return this.setAccess(cc.READ_ONLY)}toWriteOnly(){return this.setAccess(cc.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 Gb=E(bne).setParameterLength(1,3),xne=(e,t,n)=>{let r=Gb(e,t,n);return n!==null&&r.toStack(),r},Sne=O(({texture:e,uv:t})=>{let n=1e-4,r=N().toVar();return ll(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 Cne=class extends mp{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(up(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return Sne({texture:this,uv:e})}};const Kb=E(Cne).setParameterLength(1,3);var wne=class extends Bm{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 qb=(e,t,n)=>T(new wne(e,t,n)),Jb=new WeakMap;var Yb=class extends vc{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=oc.OBJECT,this.updateAfterType=oc.OBJECT,this.previousModelWorldMatrix=fu(new fi),this.previousProjectionMatrix=fu(new fi).setGroup(lu),this.previousCameraViewMatrix=fu(new fi)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=Zb(n);this.previousModelWorldMatrix.value.copy(r);let i=Xb(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new fi,i.previousCameraViewMatrix=new fi,i.currentProjectionMatrix=new fi,i.currentCameraViewMatrix=new fi,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}){Zb(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?Mp:fu(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(tm).mul(om),r=this.previousProjectionMatrix.mul(t).mul(sm),i=n.xy.div(n.w),a=r.xy.div(r.w),o=xu(i,a);return o}};function Xb(e){let t=Jb.get(e);return t===void 0&&(t={},Jb.set(e,t)),t}function Zb(e,t=0){let n=Xb(e),r=n[t];return r===void 0&&(n[t]=r=new fi,n[t].copy(e.matrixWorld)),r}const Qb=D(Yb),$b=O(([e,t])=>jd(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),ex=O(([e,t])=>jd(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),tx=O(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),nx=O(([e,t])=>Kd(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Nd(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),rx=O(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return yl(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`}]}),ix=O(([e])=>yl(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),ax=O(([e])=>(ll(e.a.equal(0),()=>yl(0)),yl(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),ox=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),$b(e)),sx=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),ex(e)),cx=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),tx(e)),lx=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),nx(e)),ux=O(([e])=>mx(e.rgb)),dx=O(([e,t=k(1)])=>t.mix(mx(e.rgb),e.rgb)),fx=O(([e,t=k(1)])=>{let n=bu(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 Kd(e.rgb,r,i)}),px=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(Ld(n,e.rgb).mul(r.oneMinus())))))}),mx=(e,t=N(wr.getLuminanceCoefficients(new C)))=>Ld(e,t),hx=O(([e,t=N(1),n=N(0),r=N(1),i=k(1),a=N(wr.getLuminanceCoefficients(new C,gn))])=>{let o=e.rgb.dot(N(a)),s=Md(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return ll(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),ll(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),ll(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),yl(s.rgb,e.a)});var gx=class extends vc{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 _x=E(gx).setParameterLength(2),vx=new ur;var yx=class extends mp{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)}},bx=class extends yx{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)}},xx=class e extends vc{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 Eo;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new Ir(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=fu(0),this._cameraFar=fu(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=oc.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 bx(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 bx(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=l_(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=o_(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),vx.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(vx)),this._pixelRatio=i,this.setSize(vx.width,vx.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()}};xx.COLOR=`color`,xx.DEPTH=`depth`;const Sx=(e,t,n)=>T(new xx(xx.COLOR,e,t,n)),Cx=(e,t)=>T(new yx(e,t)),wx=(e,t,n)=>T(new xx(xx.DEPTH,e,t,n));var Tx=class extends xx{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(xx.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 E_;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=re;let t=gm.negate(),n=Mp.mul(tm),r=k(1),i=n.mul(yl(om,1)),a=n.mul(yl(om.add(t),1)),o=ld(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=yl(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 Ex=(e,t,n=new ia(0,0,0),r=.003,i=1)=>T(new Tx(e,t,T(n),T(r),T(i))),Dx=O(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Ox=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`}]}),kx=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`}]}),Ax=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)}),jx=O(([e,t])=>{let n=wl(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=wl(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Ax(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Mx=wl(N(1.6605,-.1246,-.0182),N(-.5876,1.1329,-.1006),N(-.0728,-.0083,1.1187)),Nx=wl(N(.6274,.0691,.0164),N(.3293,.9195,.088),N(.0433,.0113,.8956)),Px=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(Su(40.14,r.mul(t))).add(Su(31.96,r).sub(Su(6.868,n.mul(t))).add(Su(.4298,n).add(Su(.1191,t).sub(.00232))))}),Fx=O(([e,t])=>{let n=N(e).toVar(),r=wl(N(.856627153315983,.137318972929847,.11189821299995),N(.0951212405381588,.761241990602591,.0767994186031903),N(.0482516061458583,.101439036467562,.811302368396859)),i=wl(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(Nx.mul(n)),n.assign(r.mul(n)),n.assign(Md(n,1e-10)),n.assign(id(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(qd(n,0,1)),n.assign(Px(n)),n.assign(i.mul(n)),n.assign(zd(Md(N(0),n),N(2.2))),n.assign(Mx.mul(n)),n.assign(qd(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Ix=O(([e,t])=>{let n=k(.76),r=k(.15);e=e.mul(t);let i=jd(e.r,jd(e.g,e.b)),a=sf(i.lessThan(.08),i.sub(Su(6.25,i.mul(i))),.04);e.subAssign(a);let o=Md(e.r,Md(e.g,e.b));ll(o.lessThan(n),()=>e);let s=xu(1,n),c=xu(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=xu(1,Cu(1,r.mul(o.sub(c)).add(1)));return Kd(e,N(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var Lx=class extends hc{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 Rx=E(Lx).setParameterLength(1,3),zx=(e,t)=>Rx(e,t,`js`),Bx=(e,t)=>Rx(e,t,`wgsl`),Vx=(e,t)=>Rx(e,t,`glsl`);var Hx=class extends Lx{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 Ux=(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 Hx(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},Wx=(e,t)=>Ux(e,t,`glsl`),Gx=(e,t)=>Ux(e,t,`wgsl`);var Kx=class extends hc{static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new qn,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=rc(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`?ic(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 qx=E(Kx).setParameterLength(1);var Jx=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}}},Yx=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 Jx;var Zx=class extends hc{static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Jx,this._output=qx(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]=qx(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]=qx(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 Yx(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
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 Xx=E(Yx).setParameterLength(1,2);function Zx(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||cm.z).negate()}const Qx=O(([e,t],n)=>{let r=Zx(n);return Jd(e,t,r)}),$x=O(([e],t)=>{let n=Zx(t);return e.mul(e,n,n).negate().exp().oneMinus()}),eS=O(([e,t])=>_l(t.toFloat().mix(ql.rgb,e.toVec3()),ql.a));function tS(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),eS(e,Qx(t,n))}function nS(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),eS(e,$x(t))}let rS=null,iS=null;var aS=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));rS||=new Pr,iS||=new Pr,rS.setScalar(0),iS.setScalar(0),a===1?rS.setScalar(r):r.isColor?rS.set(r.r,r.g,r.b,1):rS.set(r.x,r.y,r.z||0,r.w||0),o===1?iS.setScalar(i):i.isColor?iS.set(i.r,i.g,i.b,1):iS.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=rS.getComponent(t),r=iS.getComponent(t);l[e]=cr.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=bp(l,`vec4`,t.count).element(tg).convert(u);else{let t=new uo(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=Lf(t).convert(u)}}else n=k(0);return n}};const oS=E(aS).setParameterLength(2);var sS=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 cS=(e,t)=>T(new sS(e,t)),lS=cS(`numWorkgroups`,`uvec3`),uS=cS(`workgroupId`,`uvec3`),dS=cS(`globalId`,`uvec3`),fS=cS(`localId`,`uvec3`),pS=cS(`subgroupSize`,`uint`);var mS=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 hS=E(mS),gS=()=>hS(`workgroup`).toStack(),_S=()=>hS(`storage`).toStack(),vS=()=>hS(`texture`).toStack();var yS=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}},bS=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 yS(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const xS=(e,t)=>T(new bS(`Workgroup`,e,t));var SS=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=Xf(l,i).toConst()),t.constNode.build(e)}};SS.ATOMIC_LOAD=`atomicLoad`,SS.ATOMIC_STORE=`atomicStore`,SS.ATOMIC_ADD=`atomicAdd`,SS.ATOMIC_SUB=`atomicSub`,SS.ATOMIC_MAX=`atomicMax`,SS.ATOMIC_MIN=`atomicMin`,SS.ATOMIC_AND=`atomicAnd`,SS.ATOMIC_OR=`atomicOr`,SS.ATOMIC_XOR=`atomicXor`;const CS=E(SS),wS=(e,t,n)=>CS(e,t,n).toStack(),TS=e=>wS(SS.ATOMIC_LOAD,e,null),ES=(e,t)=>wS(SS.ATOMIC_STORE,e,t),DS=(e,t)=>wS(SS.ATOMIC_ADD,e,t),OS=(e,t)=>wS(SS.ATOMIC_SUB,e,t),kS=(e,t)=>wS(SS.ATOMIC_MAX,e,t),AS=(e,t)=>wS(SS.ATOMIC_MIN,e,t),jS=(e,t)=>wS(SS.ATOMIC_AND,e,t),MS=(e,t)=>wS(SS.ATOMIC_OR,e,t),NS=(e,t)=>wS(SS.ATOMIC_XOR,e,t);let PS;function FS(e){PS||=new WeakMap;let t=PS.get(e);return t===void 0&&PS.set(e,t={}),t}function IS(e){let t=FS(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 LS(e,t=om){let n=IS(e).mul(t),r=n.xyz.div(n.w);return r}function RS(e){let t=FS(e);return t.position||=uu(new C).setGroup(su).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function zS(e){let t=FS(e);return t.targetPosition||=uu(new C).setGroup(su).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function BS(e){let t=FS(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 VS=e=>Mp.transformDirection(RS(e).sub(zS(e))),HS=e=>e.sort((e,t)=>e.id-t.id),US=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},WS=new WeakMap,GS=[];var KS=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(GS.push(n.id),GS.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;GS.push(e,t)}}let t=Hs(GS);return GS.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=HS(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=US(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;WS.has(e)?r=WS.get(e):(r=T(new n(e)),WS.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 qS=(e=[])=>T(new KS).setLights(e);var JS=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}){YS.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||om)}};const YS=Dl(`vec3`,`shadowPositionWorld`);function XS(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 ZS(e,t){return t=XS(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function QS(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 $S(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function eC(e,t){return t=$S(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function tC(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function nC(e,t,n){return n=ZS(e,n),n=eC(t,n),n}function rC(e,t,n){QS(e,n),tC(t,n)}const iC=new WeakMap,aC=O(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=mp(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),oC=O(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=mp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=zm(`mapSize`,`vec2`,n).setGroup(su),o=zm(`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 vu(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)}),sC=O(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=mp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=zm(`mapSize`,`vec2`,n).setGroup(su),o=M(1).div(a),s=o.x,c=o.y,l=t.xy,u=cd(l.mul(a).add(.5));return l.subAssign(u.mul(o)),vu(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),Wd(i(l.add(M(s.negate(),0)),t.z),i(l.add(M(s.mul(2),0)),t.z),u.x),Wd(i(l.add(M(s.negate(),c)),t.z),i(l.add(M(s.mul(2),c)),t.z),u.x),Wd(i(l.add(M(0,c.negate())),t.z),i(l.add(M(0,c.mul(2))),t.z),u.y),Wd(i(l.add(M(s,c.negate())),t.z),i(l.add(M(s,c.mul(2))),t.z),u.y),Wd(Wd(i(l.add(M(s.negate(),c.negate())),t.z),i(l.add(M(s.mul(2),c.negate())),t.z),u.x),Wd(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)}),cC=O(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=k(1).toVar(),i=mp(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=jd(t.z,i.x);return sl(a.notEqual(k(1)),()=>{let e=t.z.sub(i.x),n=Ad(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=Gd(yu(o,.3).div(.6499999999999999)),r.assign(Gd(Ad(a,o)))}),r}),lC=O(([e,t,n])=>{let r=om.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),uC=e=>{let t=e.shadow.camera,n=zm(`near`,`float`,t).setGroup(su),r=zm(`far`,`float`,t).setGroup(su),i=Bp(e);return lC(i,n,r)},dC=e=>{let t=iC.get(e);if(t===void 0){let n=e.isPointLight?uC(e):null;t=new w_,t.colorNode=_l(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,iC.set(e,t)}return t},fC=new Ky,pC=[],mC=(e,t,n,r)=>{pC[0]=e,pC[1]=t;let i=fC.get(pC);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,fC.set(pC,i)),pC[0]=null,pC[1]=null,i},hC=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));Sg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(vu(Hg.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=rd(o.sub(a.mul(a)));return M(a,l)}),gC=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));Sg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(vu(Hg.xy,M(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(vu(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=rd(o.sub(a.mul(a)));return M(a,l)}),_C=[aC,oC,sC,cC];let vC;const yC=new Mb;var bC=class extends JS{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=zm(`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=zm(`near`,`float`,n.camera).setGroup(su),r=zm(`far`,`float`,n.camera).setGroup(su);o=c_(e.negate(),t,r)}return a=N(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return _C[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=mp(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=mp(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=zm(`blurSamples`,`float`,r).setGroup(su),s=zm(`radius`,`float`,r).setGroup(su),c=zm(`mapSize`,`vec2`,r).setGroup(su),l=this.vsmMaterialVertical||=new w_;l.fragmentNode=hC({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new w_,l.fragmentNode=gC({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=zm(`intensity`,`float`,r).setGroup(su),c=zm(`normalBias`,`float`,r).setGroup(su),l=IS(n).mul(YS.add(ym.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=mp(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=Wd(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;vC=nC(i,a,vC),a.overrideMaterial=dC(n),i.setRenderObjectFunction(mC(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,rC(i,a,vC)}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),yC.material=this.vsmMaterialVertical,yC.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),yC.material=this.vsmMaterialHorizontal,yC.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 xC=(e,t)=>T(new bC(e,t)),SC=new ra,CC=O(([e,t])=>{let n=e.toVar(),r=hd(n),i=xu(1,Ad(r.x,Ad(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(yu(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=gd(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=gd(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`}]}),wC=O(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>mp(e,CC(t,r.y)).compare(n)),TC=O(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=zm(`radius`,`float`,i).setGroup(su),o=M(-1,1).mul(a).mul(r.y);return mp(e,CC(t.add(o.xyy),r.y)).compare(n).add(mp(e,CC(t.add(o.yyy),r.y)).compare(n)).add(mp(e,CC(t.add(o.xyx),r.y)).compare(n)).add(mp(e,CC(t.add(o.yyx),r.y)).compare(n)).add(mp(e,CC(t,r.y)).compare(n)).add(mp(e,CC(t.add(o.xxy),r.y)).compare(n)).add(mp(e,CC(t.add(o.yxy),r.y)).compare(n)).add(mp(e,CC(t.add(o.xxx),r.y)).compare(n)).add(mp(e,CC(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),EC=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=zm(`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}),DC=new Pr,OC=new lr,kC=new lr;var AC=class extends bC{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===S?wC:TC}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return EC({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();kC.copy(t.mapSize),kC.multiply(o),n.setSize(kC.width,kC.height),OC.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(SC),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=OC.x*o.x,c=kC.y-OC.y-OC.y*o.y;DC.set(s,c,OC.x*o.z,OC.y*o.w),n.viewport.copy(DC),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const jC=(e,t)=>T(new AC(e,t));var MC=class extends Mg{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 BS(this.light).sub(e.context.positionView||cm)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return xC(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 NC=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)}),PC=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=NC({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}};var FC=class extends MC{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 jC(this.light)}setupDirect(e){return PC({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}};const IC=O(([e=op()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),LC=O(([e=op()],{renderer:t,material:n})=>{let r=Ud(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=k(r.fwidth()).toVar();i=Jd(e.oneMinus(),e.add(1),r).oneMinus()}else i=rf(r.greaterThan(1),0,1);return i}),RC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=ul(e).toVar();return rf(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),zC=O(([e,t])=>{let n=ul(t).toVar(),r=k(e).toVar();return rf(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),BC=O(([e])=>{let t=k(e).toVar();return A(ad(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),VC=O(([e,t])=>{let n=k(e).toVar();return t.assign(BC(n)),n.sub(k(t))}),HC=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(yu(1,s)).toVar();return yu(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`}]}),UC=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(yu(1,s)).toVar();return yu(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`}]}),WC=mb([HC,UC]),GC=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(yu(1,p)).toVar(),ee=k(yu(1,f)).toVar(),te=k(yu(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`}]}),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=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(yu(1,p)).toVar(),ee=k(yu(1,f)).toVar(),te=k(yu(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`}]}),qC=mb([GC,KC]),JC=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(RC(o.lessThan(j(4)),i,r)).toVar(),c=k(bu(2,RC(o.lessThan(j(4)),r,i))).toVar();return zC(s,ul(o.bitAnd(j(1)))).add(zC(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`}]}),YC=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(RC(c.lessThan(j(8)),o,a)).toVar(),u=k(RC(c.lessThan(j(4)),a,RC(c.equal(j(12)).or(c.equal(j(14))),o,i))).toVar();return zC(l,ul(c.bitAnd(j(1)))).add(zC(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`}]}),XC=mb([JC,YC]),ZC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=hl(e).toVar();return N(XC(a.x,i,r),XC(a.y,i,r),XC(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`}]}),QC=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=k(t).toVar(),s=hl(e).toVar();return N(XC(s.x,o,a,i),XC(s.y,o,a,i),XC(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`}]}),$C=mb([ZC,QC]),ew=O(([e])=>{let t=k(e).toVar();return bu(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),tw=O(([e])=>{let t=k(e).toVar();return bu(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),nw=O(([e])=>{let t=N(e).toVar();return bu(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),rw=mb([ew,nw]),iw=O(([e])=>{let t=N(e).toVar();return bu(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),aw=mb([tw,iw]),ow=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`}]}),sw=O(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(ow(n,A(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(ow(e,A(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(ow(t,A(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(ow(n,A(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(ow(e,A(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(ow(t,A(4))),t.addAssign(e)}),cw=O(([e,t,n])=>{let r=j(n).toVar(),i=j(t).toVar(),a=j(e).toVar();return r.bitXorAssign(i),r.subAssign(ow(i,A(14))),a.bitXorAssign(r),a.subAssign(ow(r,A(11))),i.bitXorAssign(a),i.subAssign(ow(a,A(25))),r.bitXorAssign(i),r.subAssign(ow(i,A(16))),a.bitXorAssign(r),a.subAssign(ow(r,A(4))),i.bitXorAssign(a),i.subAssign(ow(a,A(14))),r.bitXorAssign(i),r.subAssign(ow(i,A(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),lw=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`}]}),uw=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`}]}),dw=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 cw(r.add(j(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),fw=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)),cw(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),pw=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)),cw(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),mw=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)),sw(l,u,d),l.addAssign(j(i)),cw(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`}]}),hw=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)),sw(d,f,p),d.addAssign(j(o)),f.addAssign(j(a)),cw(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`}]}),gw=mb([dw,fw,pw,mw,hw]),_w=O(([e,t])=>{let n=A(t).toVar(),r=A(e).toVar(),i=j(gw(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`}]}),vw=O(([e,t,n])=>{let r=A(n).toVar(),i=A(t).toVar(),a=A(e).toVar(),o=j(gw(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`}]}),yw=mb([_w,vw]),bw=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(VC(t.x,n)).toVar(),a=k(VC(t.y,r)).toVar(),o=k(uw(i)).toVar(),s=k(uw(a)).toVar(),c=k(WC(XC(gw(n,r),i,a),XC(gw(n.add(A(1)),r),i.sub(1),a),XC(gw(n,r.add(A(1))),i,a.sub(1)),XC(gw(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return rw(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),xw=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(VC(t.x,n)).toVar(),o=k(VC(t.y,r)).toVar(),s=k(VC(t.z,i)).toVar(),c=k(uw(a)).toVar(),l=k(uw(o)).toVar(),u=k(uw(s)).toVar(),d=k(qC(XC(gw(n,r,i),a,o,s),XC(gw(n.add(A(1)),r,i),a.sub(1),o,s),XC(gw(n,r.add(A(1)),i),a,o.sub(1),s),XC(gw(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),XC(gw(n,r,i.add(A(1))),a,o,s.sub(1)),XC(gw(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),XC(gw(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),XC(gw(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 aw(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Sw=mb([bw,xw]),Cw=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(VC(t.x,n)).toVar(),a=k(VC(t.y,r)).toVar(),o=k(uw(i)).toVar(),s=k(uw(a)).toVar(),c=N(WC($C(yw(n,r),i,a),$C(yw(n.add(A(1)),r),i.sub(1),a),$C(yw(n,r.add(A(1))),i,a.sub(1)),$C(yw(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return rw(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),ww=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(VC(t.x,n)).toVar(),o=k(VC(t.y,r)).toVar(),s=k(VC(t.z,i)).toVar(),c=k(uw(a)).toVar(),l=k(uw(o)).toVar(),u=k(uw(s)).toVar(),d=N(qC($C(yw(n,r,i),a,o,s),$C(yw(n.add(A(1)),r,i),a.sub(1),o,s),$C(yw(n,r.add(A(1)),i),a,o.sub(1),s),$C(yw(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),$C(yw(n,r,i.add(A(1))),a,o,s.sub(1)),$C(yw(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),$C(yw(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),$C(yw(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 aw(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Tw=mb([Cw,ww]),Ew=O(([e])=>{let t=k(e).toVar(),n=A(BC(t)).toVar();return lw(gw(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Dw=O(([e])=>{let t=M(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar();return lw(gw(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Ow=O(([e])=>{let t=N(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar(),i=A(BC(t.z)).toVar();return lw(gw(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),kw=O(([e])=>{let t=_l(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar(),i=A(BC(t.z)).toVar(),a=A(BC(t.w)).toVar();return lw(gw(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Aw=mb([Ew,Dw,Ow,kw]),jw=O(([e])=>{let t=k(e).toVar(),n=A(BC(t)).toVar();return N(lw(gw(n,A(0))),lw(gw(n,A(1))),lw(gw(n,A(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Mw=O(([e])=>{let t=M(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar();return N(lw(gw(n,r,A(0))),lw(gw(n,r,A(1))),lw(gw(n,r,A(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Nw=O(([e])=>{let t=N(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar(),i=A(BC(t.z)).toVar();return N(lw(gw(n,r,i,A(0))),lw(gw(n,r,i,A(1))),lw(gw(n,r,i,A(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Pw=O(([e])=>{let t=_l(e).toVar(),n=A(BC(t.x)).toVar(),r=A(BC(t.y)).toVar(),i=A(BC(t.z)).toVar(),a=A(BC(t.w)).toVar();return N(lw(gw(n,r,i,a,A(0))),lw(gw(n,r,i,a,A(1))),lw(gw(n,r,i,a,A(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),Fw=mb([jw,Mw,Nw,Pw]),Iw=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 Sg(o,()=>{c.addAssign(l.mul(Sw(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`}]}),Lw=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 Sg(o,()=>{c.addAssign(l.mul(Tw(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`}]}),Rw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar();return M(Iw(s,o,a,i),Iw(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`}]}),zw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar(),c=N(Lw(s,o,a,i)).toVar(),l=k(Iw(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`}]}),Bw=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(Fw(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)),()=>hd(_.x).add(hd(_.y))),sl(s.equal(A(3)),()=>Ad(hd(_.x),hd(_.y))),Fd(_,_)}).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`}]}),Vw=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(Fw(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)),()=>hd(b.x).add(hd(b.y)).add(hd(b.z))),sl(l.equal(A(3)),()=>Ad(hd(b.x),hd(b.y),hd(b.z))),Fd(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`}]}),Hw=mb([Bw,Vw]),Uw=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(VC(a.x,o),VC(a.y,s)).toVar(),l=k(1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(c,e,t,o,s,i,r)).toVar();l.assign(kd(l,n))})}),sl(r.equal(A(0)),()=>{l.assign(rd(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),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(VC(a.x,o),VC(a.y,s)).toVar(),l=M(1e6,1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(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(rd(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,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(VC(a.x,o),VC(a.y,s)).toVar(),l=N(1e6,1e6,1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(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(rd(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,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=N(e).toVar(),o=A().toVar(),s=A().toVar(),c=A().toVar(),l=N(VC(a.x,o),VC(a.y,s),VC(a.z,c)).toVar(),u=k(1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Sg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(l,e,t,n,o,s,c,i,r)).toVar();u.assign(kd(u,a))})})}),sl(r.equal(A(0)),()=>{u.assign(rd(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),qw=mb([Uw,Kw]),Jw=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(VC(a.x,o),VC(a.y,s),VC(a.z,c)).toVar(),u=M(1e6,1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Sg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(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(rd(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Yw=mb([Ww,Jw]),Xw=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(VC(a.x,o),VC(a.y,s),VC(a.z,c)).toVar(),u=N(1e6,1e6,1e6).toVar();return Sg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{Sg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{Sg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(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(rd(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Zw=mb([Gw,Xw]),Qw=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(ad(i)).mul(6).toVar();let a=A(wd(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`}]}),$w=O(([e])=>{let t=N(e).toVar(),n=k(t.x).toVar(),r=k(t.y).toVar(),i=k(t.z).toVar(),a=k(kd(n,kd(r,i))).toVar(),o=k(Ad(n,Ad(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(vu(2,i.sub(n).div(s)))}).Else(()=>{c.assign(vu(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`}]}),eT=O(([e])=>{let t=N(e).toVar(),n=gl(Eu(t,N(.04045))).toVar(),r=N(t.div(12.92)).toVar(),i=N(Ld(Ad(t.add(N(.055)),N(0)).div(1.055),N(2.4))).toVar();return Wd(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),tT=(e,t)=>{e=k(e),t=k(t);let n=M(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Jd(e.sub(n),e.add(n),t)},nT=(e,t,n,r)=>Wd(e,t,n[r].clamp()),rT=(e,t,n=op())=>nT(e,t,n,`x`),iT=(e,t,n=op())=>nT(e,t,n,`y`),aT=(e,t,n,r,i)=>Wd(e,t,tT(n,r[i])),oT=(e,t,n,r=op())=>aT(e,t,n,r,`x`),sT=(e,t,n,r=op())=>aT(e,t,n,r,`y`),cT=(e=1,t=0,n=op())=>n.mul(e).add(t),lT=(e,t=1)=>(e=k(e),e.abs().pow(t).mul(e.sign())),uT=(e,t=1,n=.5)=>k(e).sub(n).mul(t).add(n),dT=(e=op(),t=1,n=0)=>Sw(e.convert(`vec2|vec3`)).mul(t).add(n),fT=(e=op(),t=1,n=0)=>Tw(e.convert(`vec2|vec3`)).mul(t).add(n),pT=(e=op(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=_l(Tw(e),Sw(e.add(M(19,73))));return r.mul(t).add(n)},mT=(e=op(),t=1)=>qw(e.convert(`vec2|vec3`),t,A(1)),hT=(e=op(),t=1)=>Yw(e.convert(`vec2|vec3`),t,A(1)),gT=(e=op(),t=1)=>Zw(e.convert(`vec2|vec3`),t,A(1)),_T=(e=op())=>Aw(e.convert(`vec2|vec3`)),vT=(e=op(),t=3,n=2,r=.5,i=1)=>Iw(e,A(t),n,r).mul(i),yT=(e=op(),t=3,n=2,r=.5,i=1)=>Rw(e,A(t),n,r).mul(i),bT=(e=op(),t=3,n=2,r=.5,i=1)=>Lw(e,A(t),n,r).mul(i),xT=(e=op(),t=3,n=2,r=.5,i=1)=>zw(e,A(t),n,r).mul(i),ST=O(([e,t,n])=>{let r=sd(e).toVar(),i=yu(k(.5).mul(t.sub(n)),om).div(r).toVar(),a=yu(k(-.5).mul(t.sub(n)),om).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=kd(o.x,o.y,o.z).toVar(),c=om.add(r.mul(s)).toVar();return c.sub(n)}),CT=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(bu(n,n).sub(bu(r,r)))),a});var I=Object.freeze({__proto__:null,BRDF_GGX:mv,BRDF_Lambert:Q_,BasicPointShadowFilter:wC,BasicShadowFilter:aC,Break:wg,Const:pf,Continue:Cg,DFGApprox:hv,D_GGX:dv,Discard:Zf,EPSILON:Gu,F_Schlick:Z_,Fn:O,INFINITY:Ku,If:sl,Loop:Sg,NodeAccess:sc,NodeShaderStage:ic,NodeType:oc,NodeUpdateType:ac,PCFShadowFilter:oC,PCFSoftShadowFilter:sC,PI:qu,PI2:Ju,PointShadowFilter:TC,Return:Qf,Schlick_to_F0:_v,ScriptableNodeResources:Jx,ShaderNode:nl,Stack:cl,Switch:vee,TBNViewMatrix:nh,VSMShadowFilter:cC,V_GGX_SmithCorrelated:lv,Var:ff,abs:hd,acesFilmicToneMapping:kx,acos:pd,add:vu,addMethodChaining:w,addNodeElement:rp,agxToneMapping:Nx,all:Yu,alphaT:Bl,and:ku,anisotropy:Vl,anisotropyB:Ul,anisotropyT:Hl,any:Xu,append:See,array:fu,arrayBuffer:bee,asin:fd,assign:pu,atan:md,atan2:$d,atomicAdd:DS,atomicAnd:jS,atomicFunc:wS,atomicLoad:TS,atomicMax:kS,atomicMin:AS,atomicOr:MS,atomicStore:ES,atomicSub:OS,atomicXor:NS,attenuationColor:tu,attenuationDistance:eu,attribute:ap,attributeArray:bne,backgroundBlurriness:Rb,backgroundIntensity:zb,backgroundRotation:Bb,batch:dg,billboarding:tne,bitAnd:Nu,bitNot:Pu,bitOr:Fu,bitXor:Iu,bitangentGeometry:Xm,bitangentLocal:Zm,bitangentView:Qm,bitangentWorld:$m,bitcast:Dd,blendBurn:Zb,blendColor:tx,blendDodge:Qb,blendOverlay:ex,blendScreen:$b,blur:_y,bool:ul,buffer:bp,bufferAttribute:Ff,bumpMap:fh,burn:ix,bvec2:pl,bvec3:gl,bvec4:bl,bypass:Gf,cache:Hf,call:hu,cameraFar:kp,cameraIndex:Dp,cameraNear:Op,cameraNormalMatrix:Pp,cameraPosition:Fp,cameraProjectionMatrix:Ap,cameraProjectionMatrixInverse:jp,cameraViewMatrix:Mp,cameraWorldMatrix:Np,cbrt:Hd,cdl:px,ceil:od,checker:IC,cineonToneMapping:Dx,clamp:Gd,clearcoat:Nl,clearcoatRoughness:Pl,code:Ix,color:ll,colorSpaceToWorking:wf,colorToDirection:N_,compute:Bf,computeSkinning:bg,cond:af,context:cf,convert:Tl,convertColorSpace:Tf,convertToTexture:hne,cos:ud,cross:Id,cubeTexture:Fm,cubeTextureBase:Pm,cubeToUV:CC,dFdx:bd,dFdy:xd,dashSize:Jl,debug:np,decrement:Hu,decrementBefore:Bu,defaultBuildStages:lc,defaultShaderStages:cc,defined:el,degrees:Qu,deltaTime:gb,densityFog:nS,densityFogFactor:$x,depth:d_,depthPass:Sx,difference:Pd,diffuseColor:kl,directPointLight:PC,directionToColor:M_,dispersion:nu,distance:Nd,div:xu,dodge:ax,dot:Fd,drawIndex:ag,dynamicBufferAttribute:If,element:wl,emissive:Al,equal:Cu,equals:Od,equirectUV:L_,exp:$u,exp2:ed,expression:Xf,faceDirection:fm,faceForward:Yd,faceforward:ef,float:k,floor:ad,fog:eS,fract:cd,frameGroup:ou,frameId:Gte,frontFacing:dm,fwidth:Td,gain:Rte,gapSize:Yl,getConstNodeType:tl,getCurrentStack:ol,getDirection:py,getDistanceAttenuation:NC,getGeometryRoughness:sv,getNormalFromDepth:_ne,getParallaxCorrectNormal:ST,getRoughness:cv,getScreenPosition:gne,getShIrradianceAt:CT,getShadowMaterial:dC,getShadowRenderObjectFunction:mC,getTextureIndex:ub,getViewPosition:Pb,globalId:dS,glsl:zx,glslFn:Hx,grayscale:cx,greaterThan:Eu,greaterThanEqual:Ou,hash:Lte,highpModelNormalViewMatrix:nm,highpModelViewMatrix:tm,hue:dx,increment:Vu,incrementBefore:zu,instance:sg,instanceIndex:tg,instancedArray:xne,instancedBufferAttribute:Lf,instancedDynamicBufferAttribute:Rf,instancedMesh:lg,int:A,inverseSqrt:id,inversesqrt:tf,invocationLocalIndex:ig,invocationSubgroupIndex:rg,ior:Zl,iridescence:Ll,iridescenceIOR:Rl,iridescenceThickness:zl,ivec2:dl,ivec3:ml,ivec4:vl,js:Lx,label:lf,length:_d,lengthSq:Ud,lessThan:Tu,lessThanEqual:Du,lightPosition:RS,lightProjectionUV:LS,lightShadowMatrix:IS,lightTargetDirection:VS,lightTargetPosition:zS,lightViewPosition:BS,lightingContext:Fg,lights:qS,linearDepth:f_,linearToneMapping:Tx,localId:fS,log:td,log2:nd,logarithmicDepthToViewZ:l_,loop:Tg,luminance:fx,mat2:xl,mat3:Sl,mat4:Cl,matcapUV:Uy,materialAO:Xh,materialAlphaTest:mh,materialAnisotropy:Nh,materialAnisotropyVector:Zh,materialAttenuationColor:Vh,materialAttenuationDistance:Bh,materialClearcoat:Dh,materialClearcoatNormal:kh,materialClearcoatRoughness:Oh,materialColor:hh,materialDispersion:Jh,materialEmissive:_h,materialEnvIntensity:Em,materialEnvRotation:Dm,materialIOR:zh,materialIridescence:Ph,materialIridescenceIOR:Fh,materialIridescenceThickness:Ih,materialLightMap:Yh,materialLineDashOffset:Kh,materialLineDashSize:Uh,materialLineGapSize:Wh,materialLineScale:Hh,materialLineWidth:Gh,materialMetalness:Th,materialNormal:Eh,materialOpacity:vh,materialPointSize:qh,materialReference:Hm,materialReflectivity:Ch,materialRefractionRatio:Tm,materialRotation:Ah,materialRoughness:wh,materialSheen:jh,materialSheenRoughness:Mh,materialShininess:gh,materialSpecular:yh,materialSpecularColor:xh,materialSpecularIntensity:bh,materialSpecularStrength:Sh,materialThickness:Rh,materialTransmission:Lh,max:Ad,maxMipLevel:up,mediumpModelViewMatrix:em,metalness:Ml,min:kd,mix:Wd,mixElement:Zd,mod:Su,modInt:Wu,modelDirection:Gp,modelNormalMatrix:Zp,modelPosition:qp,modelRadius:Xp,modelScale:Jp,modelViewMatrix:$p,modelViewPosition:Yp,modelViewProjection:Qh,modelWorldMatrix:Kp,modelWorldMatrixInverse:Qp,morphReference:jg,mrt:db,mul:bu,mx_aastep:tT,mx_cell_noise_float:_T,mx_contrast:uT,mx_fractal_noise_float:vT,mx_fractal_noise_vec2:yT,mx_fractal_noise_vec3:bT,mx_fractal_noise_vec4:xT,mx_hsvtorgb:Qw,mx_noise_float:dT,mx_noise_vec3:fT,mx_noise_vec4:pT,mx_ramplr:rT,mx_ramptb:iT,mx_rgbtohsv:$w,mx_safepower:lT,mx_splitlr:oT,mx_splittb:sT,mx_srgb_texture_to_lin_rec709:eT,mx_transform_uv:cT,mx_worley_noise_float:mT,mx_worley_noise_vec2:hT,mx_worley_noise_vec3:gT,namespace:Uf,negate:vd,neutralToneMapping:Px,nodeArray:il,nodeImmutable:D,nodeObject:T,nodeObjects:rl,nodeProxy:E,normalFlat:hm,normalGeometry:pm,normalLocal:mm,normalMap:ch,normalView:gm,normalWorld:_m,normalize:sd,not:ju,notEqual:wu,numWorkgroups:lS,objectDirection:Rp,objectGroup:cu,objectPosition:Bp,objectRadius:Up,objectScale:Vp,objectViewPosition:Hp,objectWorldMatrix:zp,oneMinus:yd,or:Au,orthographicDepthToViewZ:a_,oscSawtooth:Qte,oscSine:Yte,oscSquare:Xte,oscTriangle:Zte,output:ql,outputStruct:Fte,overlay:sx,overloadingFn:mb,parabola:fb,parallaxDirection:rh,parallaxUV:ih,parameter:kte,pass:bx,passTexture:xx,pcurve:zte,perspectiveDepthToViewZ:s_,pmremTexture:zy,pointShadow:jC,pointUV:Cne,pointWidth:Xl,positionGeometry:rm,positionLocal:im,positionPrevious:am,positionView:cm,positionViewDirection:lm,positionWorld:om,positionWorldDirection:sm,posterize:hx,pow:Ld,pow2:Rd,pow3:zd,pow4:Bd,premult:nx,property:Dl,radians:Zu,rand:Xd,range:oS,rangeFog:tS,rangeFogFactor:Qx,reciprocal:Cd,reference:zm,referenceBuffer:Bm,reflect:Md,reflectVector:Am,reflectView:Om,reflector:une,refract:qd,refractVector:jm,refractView:km,reinhardToneMapping:Ex,remainder:Uu,remap:qf,remapClamp:Jf,renderGroup:su,renderOutput:ep,rendererReference:Af,rotate:Wy,rotateUV:$te,roughness:jl,round:Sd,rtt:Nb,sRGBTransferEOTF:vf,sRGBTransferOETF:yf,sampler:_p,samplerComparison:vp,saturate:Kd,saturation:lx,screen:ox,screenCoordinate:Hg,screenSize:Vg,screenUV:Bg,scriptable:Xx,scriptableValue:Gx,select:rf,setCurrentStack:al,shaderStages:uc,shadow:xC,shadowPositionWorld:YS,shapeCircle:LC,sharedUniformGroup:au,sheen:Fl,sheenRoughness:Il,shiftLeft:Lu,shiftRight:Ru,shininess:Kl,sign:gd,sin:ld,sinc:Bte,skinning:yg,smoothstep:Jd,smoothstepElement:Qd,specularColor:Wl,specularF90:Gl,spherizeUV:ene,split:xee,spritesheetUV:ine,sqrt:rd,stack:cb,step:jd,storage:hg,storageBarrier:_S,storageObject:gg,storageTexture:Vb,string:yee,struct:Pte,sub:yu,subgroupIndex:ng,subgroupSize:pS,tan:dd,tangentGeometry:Um,tangentLocal:Wm,tangentView:Gm,tangentWorld:Km,temp:mf,texture:mp,texture3D:Wb,textureBarrier:vS,textureBicubic:Fv,textureCubeUV:my,textureLoad:gp,textureSize:cp,textureStore:Tne,thickness:$l,time:hb,timerDelta:Jte,timerGlobal:qte,timerLocal:Kte,toneMapping:Mf,toneMappingExposure:Nf,toonOutlinePass:wx,transformDirection:Vd,transformNormal:xm,transformNormalToView:Sm,transformedBentNormalView:ah,transformedBitangentView:eh,transformedBitangentWorld:th,transformedClearcoatNormalView:bm,transformedNormalView:vm,transformedNormalWorld:ym,transformedTangentView:qm,transformedTangentWorld:Jm,transmission:Ql,transpose:Ed,triNoise3D:Hte,triplanarTexture:one,triplanarTextures:_b,trunc:wd,tslFn:Cee,uint:j,uniform:uu,uniformArray:Cp,uniformCubeTexture:Im,uniformGroup:iu,uniformTexture:hp,uniforms:wp,unpremult:rx,userData:Kb,uv:op,uvec2:fl,uvec3:hl,uvec4:yl,varying:gf,varyingProperty:Ol,vec2:M,vec3:N,vec4:_l,vectorComponents:dc,velocity:Xb,vertexColor:C_,vertexIndex:eg,vertexStage:_f,vibrance:ux,viewZToLogarithmicDepth:c_,viewZToOrthographicDepth:i_,viewZToPerspectiveDepth:o_,viewport:Ug,viewportBottomLeft:Yg,viewportCoordinate:Gg,viewportDepthTexture:n_,viewportLinearDepth:p_,viewportMipTexture:$g,viewportResolution:qg,viewportSafeUV:nne,viewportSharedTexture:j_,viewportSize:Wg,viewportTexture:Qg,viewportTopLeft:Jg,viewportUV:Kg,wgsl:Rx,wgslFn:Ux,workgroupArray:xS,workgroupBarrier:gS,workgroupId:uS,workingToColorSpace:Cf,xor:Mu});const wT=new ob;var TT=class extends Jy{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(wT),wT.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(wT),wT.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;wT.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=cf(_l(a).mul(zb),{getUV:()=>Bb.mul(_m),getTextureLevel:()=>Rb}),t=Qh;t=t.setZ(t.w);let r=new w_;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(zb),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`?wT.set(0,0,0,1):o===`alpha-blend`&&wT.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=wT.r,e.g=wT.g,e.b=wT.b,e.a=wT.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 ET=0;var DT=class{constructor(e=``,t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=ET++}},OT=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 DT(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}},kT=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},AT=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}},jT=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},MT=class extends jT{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},NT=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}};let PT=0;var FT=class{constructor(e=null){this.id=PT++,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)}},IT=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},LT=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}},RT=class extends LT{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},zT=class extends LT{constructor(e,t=new lr){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},BT=class extends LT{constructor(e,t=new C){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},VT=class extends LT{constructor(e,t=new Pr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},HT=class extends LT{constructor(e,t=new ra){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},UT=class extends LT{constructor(e,t=new Ls){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},WT=class extends LT{constructor(e,t=new pr){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},GT=class extends LT{constructor(e,t=new di){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},KT=class extends RT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},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}};const eE=new WeakMap,tE=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),nE=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`));var rE=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=cb(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new FT,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=eE.get(this.renderer);return e===void 0&&(e=new Ky,eE.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Fr(e,t,n)}createCubeRenderTarget(e,t){return new R_(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 DT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new DT(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 FT(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 nE(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`)}( ${nE(t.r)}, ${nE(t.g)}, ${nE(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 kT(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 tE.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=cb(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 kT(`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 IT(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 AT(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 jT(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 MT(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 NT(`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
|
|
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 w_),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 KT(e);if(t===`vec2`||t===`ivec2`||t===`uvec2`)return new qT(e);if(t===`vec3`||t===`ivec3`||t===`uvec3`)return new JT(e);if(t===`vec4`||t===`ivec4`||t===`uvec4`)return new YT(e);if(t===`color`)return new XT(e);if(t===`mat2`)return new ZT(e);if(t===`mat3`)return new QT(e);if(t===`mat4`)return new $T(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.`)}},iE=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}},aE=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};aE.isNodeFunctionInput=!0;var oE=class extends MC{static get type(){return`DirectionalLightNode`}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode,t=VS(this.light);return{lightDirection:t,lightColor:e}}};const sE=new di,cE=new di;let lE=null;var uE=class extends MC{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;cE.identity(),sE.copy(t.matrixWorld),sE.premultiply(n),cE.extractRotation(sE),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(cE),this.halfHeight.value.applyMatrix4(cE)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=mp(lE.LTC_FLOAT_1),n=mp(lE.LTC_FLOAT_2)):(t=mp(lE.LTC_HALF_1),n=mp(lE.LTC_HALF_2));let{colorNode:r,light:i}=this,a=BS(i);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){lE=e}},dE=class extends MC{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 Jd(n,r,t)}getLightCoord(e){let t=e.getNodeProperties(this),n=t.projectionUV;return n===void 0&&(n=LS(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(VS(i)),c=this.getSpotAttenuation(e,s),l=a.length(),u=NC({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=mp(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}}},fE=class extends dE{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=mp(n,M(e,0),0).r}else r=super.getSpotAttenuation(t);return r}};const pE=O(([e,t])=>{let n=e.abs().sub(t);return _d(Ad(n,0)).add(kd(Ad(n.x,n.y),0))});var mE=class extends dE{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=pE(r.xy.sub(M(.5)),M(.5)),a=xu(-1,yu(1,pd(t)).sub(1)),o=Kd(i.mul(-2).mul(a));return o}},hE=class extends MC{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},gE=class extends MC{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=RS(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=_m.dot(r),a=i.mul(.5).add(.5),o=Wd(n,t,a);e.context.irradiance.addAssign(o)}},_E=class extends MC{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=Cp(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=CT(_m,this.lightProbe);e.context.irradiance.addAssign(t)}},vE=class{parseFunction(){console.warn(`Abstract function.`)}},yE=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};yE.isNodeFunction=!0;const bE=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xE=/[a-z_0-9]+/gi,SE=`#pragma main`,CE=e=>{e=e.trim();let t=e.indexOf(SE),n=t===-1?e:e.slice(t+SE.length),r=n.match(bE);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=xE.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 aE(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 wE=class extends yE{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=CE(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}},TE=class extends vE{parseFunction(e){return new wE(e)}};const EE=new WeakMap,DE=[],OE=[];var kE=class extends Jy{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new iE,this.nodeBuilderCache=new Map,this.callHashCache=new Ky,this.groupsData=new Ky,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)}DE[0]=t,DE[1]=e;let r=this.groupsData.get(DE);return r===void 0&&this.groupsData.set(DE,r={}),DE.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 OT(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){DE[0]=e,DE[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(DE)||{};if(r.callId!==n){let i=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&OE.push(t.getCacheKey(!0)),i&&OE.push(i.getCacheKey()),a&&OE.push(a.getCacheKey()),OE.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),OE.push(this.renderer.shadowMap.enabled?1:0),r.callId=n,r.cacheKey=Hs(OE),this.callHashCache.set(DE,r),OE.length=0}return DE.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 zy(n);{let e;return e=n.isCubeTexture===!0?Fm(n):mp(n),W_(e)}}else if(n.isTexture===!0)return mp(n,Bg.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=zm(`color`,`color`,n).setGroup(su),t=zm(`density`,`float`,n).setGroup(su);return eS(e,$x(t))}else if(n.isFog){let e=zm(`color`,`color`,n).setGroup(su),t=zm(`near`,`float`,n).setGroup(su),r=zm(`far`,`float`,n).setGroup(su);return eS(e,Qx(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 Fm(n);if(n.isTexture===!0)return mp(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=EE.get(e);return t!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?Wb(e,N(Bg,Ep(`gl_ViewID_OVR`))).renderOutput(t.toneMapping,t.currentColorSpace):mp(e,Bg).renderOutput(t.toneMapping,t.currentColorSpace);return EE.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 iE,this.nodeBuilderCache=new Map,this.cacheLib={}}};const AE=new ho;var jE=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++){AE.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=AE.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=AE.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}},ME=class{constructor(e,t){this.bundleGroup=e,this.camera=t}};const NE=[];var PE=class{constructor(){this.bundles=new Ky}get(e,t){let n=this.bundles;NE[0]=e,NE[1]=t;let r=n.get(NE);return r===void 0&&(r=new ME(e,t),n.set(NE,r)),NE.length=0,r}dispose(){this.bundles=new Ky}},FE=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 IE=new KS,LE=[];var RE=class extends Ky{constructor(){super()}createNode(e=[]){return new KS().setLights(e)}getNode(e,t){if(e.isQuadMesh)return IE;LE[0]=e,LE[1]=t;let n=this.get(LE);return n===void 0&&(n=this.createNode(),this.set(LE,n)),LE.length=0,n}},zE=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 BE=new C,VE=new C;var HE=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=YE.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new lr,this._onSessionEvent=KE.bind(this),this._onSessionEnd=qE.bind(this),this._onInputSourcesChange=JE.bind(this),this._onAnimationFrame=XE.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 zE(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 zE(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 Mb(new w_),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 zE(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 zE(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;WE(i,s);for(let e=0;e<c.length;e++)WE(c[e],s);c.length===2?UE(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),GE(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new ro,this._controllers[e]=t),t}};function UE(e,t,n){BE.setFromMatrixPosition(t.matrixWorld),VE.setFromMatrixPosition(n.matrixWorld);let r=BE.distanceTo(VE),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 WE(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function GE(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 KE(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 qE(){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 zE(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 JE(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 YE(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 XE(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 ZE=new io,QE=new lr,$E=new Pr,eD=new vo,tD=new xo,nD=new di,rD=new Pr;var iD=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 pte,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new FE,this.lighting=new RE,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 Mb(new w_),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 ob(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 HE(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 kE(this,n),this._animation=new ite(this._nodes,this.info),this._attributes=new dte(n),this._background=new TT(this,this._nodes),this._geometries=new fte(this._attributes,this.info),this._textures=new Ote(this,n,this.info),this._pipelines=new _te(n,this._nodes),this._bindings=new vte(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new cte(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new xte(this.lighting),this._bundles=new PE,this._renderContexts=new Ete,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:ZE;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 jE,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=tm,this.overrideNodes.modelNormalViewMatrix=nm):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===tm&&this.overrideNodes.modelNormalViewMatrix===nm}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(QE),{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:ZE,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(QE),$E.set(0,0,QE.width,QE.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($E)===!1,p.scissorValue.copy(_).multiplyScalar(v).floor(),p.scissor=this._scissorTest&&p.scissorValue.equals($E)===!1,p.scissorValue.width>>=d,p.scissorValue.height>>=d,p.clippingContext||=new jE,p.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,f);let x=t.isArrayCamera?tD:eD;t.isArrayCamera||(nD.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(nD,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=rD.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=rD.copy(t).floor();else{console.error(`THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=rD.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?tD:eD;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&rD.setFromMatrixPosition(e.matrixWorld).applyMatrix4(nD);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,rD.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?tD:eD;if(!e.frustumCulled||a.intersectsObject(e,t)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),rD.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(nD)),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,rD.z,c,i)}}else a.visible&&r.push(e,t,a,n,rD.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}},aD=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}};function oD(e){return e+(Xy-e%Xy)%Xy}var sD=class extends aD{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return oD(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},cD=class extends sD{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}};let lD=0;var uD=class extends cD{constructor(e,t){super(`UniformBuffer_`+ lD++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}},dD=class extends cD{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%Xy,s=o%i,c=o+s;t+=s,c!==0&&Xy-c<a&&(t+=Xy-c),r.offset=t/e,t+=a}return Math.ceil(t/Xy)*Xy}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(pD(n,r,i)===!1){let e=this.buffer;e.set(r,i),fD(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 fD(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function pD(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}let mD=0;var hD=class extends dD{constructor(e,t){super(e),this.id=mD++,this.groupNode=t,this.isNodeUniformsGroup=!0}};let gD=0;var _D=class extends aD{constructor(e,t){super(e),this.id=gD++,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)}},vD=class extends _D{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)}},yD=class extends vD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},bD=class extends vD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}};const xD={textureDimensions:`textureSize`,equals:`equal`},SD={low:`lowp`,medium:`mediump`,high:`highp`},CD={swizzleAssign:!0,storageBuffer:!1},wD={perspective:`smooth`,linear:`noperspective`},TD={centroid:`centroid`,"flat first":`flat`,"flat either":`flat`},ED=`
|
|
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=[Hs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Us(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||um.z).negate()}const eS=O(([e,t],n)=>{let r=$x(n);return Xd(e,t,r)}),tS=O(([e],t)=>{let n=$x(t);return e.mul(e,n,n).negate().exp().oneMinus()}),nS=O(([e,t])=>yl(t.toFloat().mix(Yl.rgb,e.toVec3()),Yl.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 hc{static get type(){return`RangeNode`}constructor(e=k(),t=k()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(ec(this.minNode.value)),n=e.getTypeLength(ec(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(ec(r)),o=e.getTypeLength(ec(i));aS||=new Fr,oS||=new Fr,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]=lr.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=Sp(l,`vec4`,t.count).element(rg).convert(u);else{let t=new fo(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=zf(t).convert(u)}}else n=k(0);return n}};const cS=E(sS).setParameterLength(2);var lS=class extends hc{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 hc{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 gc{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 hc{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 hc{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=Qf(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||=fu(`mat4`).setGroup(lu).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function zS(e,t=cm){let n=RS(e).mul(t),r=n.xyz.div(n.w);return r}function BS(e){let t=LS(e);return t.position||=fu(new C).setGroup(lu).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function VS(e){let t=LS(e);return t.targetPosition||=fu(new C).setGroup(lu).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function HS(e){let t=LS(e);return t.viewPosition||=fu(new C).setGroup(lu).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new C,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const US=e=>Pp.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 hc{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=Us(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 hc{static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=oc.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){ZS.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||cm)}};const ZS=kl(`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 ia),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=gp(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=gp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=Vm(`mapSize`,`vec2`,n).setGroup(lu),o=Vm(`radius`,`float`,n).setGroup(lu),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 bu(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=gp(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=Vm(`mapSize`,`vec2`,n).setGroup(lu),o=M(1).div(a),s=o.x,c=o.y,l=t.xy,u=ud(l.mul(a).add(.5));return l.subAssign(u.mul(o)),bu(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),Kd(i(l.add(M(s.negate(),0)),t.z),i(l.add(M(s.mul(2),0)),t.z),u.x),Kd(i(l.add(M(s.negate(),c)),t.z),i(l.add(M(s.mul(2),c)),t.z),u.x),Kd(i(l.add(M(0,c.negate())),t.z),i(l.add(M(0,c.mul(2))),t.z),u.y),Kd(i(l.add(M(s,c.negate())),t.z),i(l.add(M(s,c.mul(2))),t.z),u.y),Kd(Kd(i(l.add(M(s.negate(),c.negate())),t.z),i(l.add(M(s.mul(2),c.negate())),t.z),u.x),Kd(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=gp(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=Nd(t.z,i.x);return ll(a.notEqual(k(1)),()=>{let e=t.z.sub(i.x),n=Md(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=qd(xu(o,.3).div(.6499999999999999)),r.assign(qd(Md(a,o)))}),r}),dC=O(([e,t,n])=>{let r=cm.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),fC=e=>{let t=e.shadow.camera,n=Vm(`near`,`float`,t).setGroup(lu),r=Vm(`far`,`float`,t).setGroup(lu),i=Hp(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 E_,t.colorNode=yl(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,oC.set(e,t)}return t},mC=new Xy,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&&(nc(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));wg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(bu(Wg.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=ad(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));wg({start:A(0),end:A(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(k(e).mul(s)),u=r.sample(bu(Wg.xy,M(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(bu(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=ad(o.sub(a.mul(a)));return M(a,l)}),yC=[sC,cC,lC,uC];let bC;const xC=new Ib;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=Vm(`bias`,`float`,n).setGroup(lu),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===Kn&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=Vm(`near`,`float`,n.camera).setGroup(lu),r=Vm(`far`,`float`,n.camera).setGroup(lu);o=u_(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 Eo(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=In;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=gp(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=gp(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=Vm(`blurSamples`,`float`,r).setGroup(lu),s=Vm(`radius`,`float`,r).setGroup(lu),c=Vm(`mapSize`,`vec2`,r).setGroup(lu),l=this.vsmMaterialVertical||=new E_;l.fragmentNode=_C({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new E_,l.fragmentNode=vC({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=Vm(`intensity`,`float`,r).setGroup(lu),c=Vm(`normalBias`,`float`,r).setGroup(lu),l=RS(n).mul(ZS.add(xm.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=gp(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=Kd(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 ia,TC=O(([e,t])=>{let n=e.toVar(),r=_d(n),i=Cu(1,Md(r.x,Md(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 ll(r.z.greaterThanEqual(s),()=>{ll(n.z.greaterThan(0),()=>{a.x.assign(xu(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=vd(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=vd(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})=>gp(e,TC(t,r.y)).compare(n)),DC=O(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=Vm(`radius`,`float`,i).setGroup(lu),o=M(-1,1).mul(a).mul(r.y);return gp(e,TC(t.add(o.xyy),r.y)).compare(n).add(gp(e,TC(t.add(o.yyy),r.y)).compare(n)).add(gp(e,TC(t.add(o.xyx),r.y)).compare(n)).add(gp(e,TC(t.add(o.yyx),r.y)).compare(n)).add(gp(e,TC(t,r.y)).compare(n)).add(gp(e,TC(t.add(o.xxy),r.y)).compare(n)).add(gp(e,TC(t.add(o.yxy),r.y)).compare(n)).add(gp(e,TC(t.add(o.xxx),r.y)).compare(n)).add(gp(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=fu(`float`).setGroup(lu).onRenderUpdate(()=>r.camera.near),s=fu(`float`).setGroup(lu).onRenderUpdate(()=>r.camera.far),c=Vm(`bias`,`float`,r).setGroup(lu),l=fu(r.mapSize).setGroup(lu),u=k(1).toVar();return ll(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 Fr,AC=new ur,jC=new ur;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 Pg{static get type(){return`AnalyticLightNode`}constructor(e=null){super(),this.light=e,this.color=new ia,this.colorNode=e&&e.colorNode||fu(this.color).setGroup(lu),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=oc.FRAME}getHash(){return this.light.uuid}getLightVector(e){return HS(this.light).sub(e.context.positionView||um)}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=fu(0).setGroup(lu),this.decayExponentNode=fu(2).setGroup(lu)}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=cp()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),zC=O(([e=cp()],{renderer:t,material:n})=>{let r=Gd(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=k(r.fwidth()).toVar();i=Xd(e.oneMinus(),e.add(1),r).oneMinus()}else i=sf(r.greaterThan(1),0,1);return i}),BC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=fl(e).toVar();return sf(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),VC=O(([e,t])=>{let n=fl(t).toVar(),r=k(e).toVar();return sf(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),HC=O(([e])=>{let t=k(e).toVar();return A(sd(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),UC=O(([e,t])=>{let n=k(e).toVar();return t.assign(HC(n)),n.sub(k(t))}),Tne=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(xu(1,s)).toVar();return xu(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`}]}),Ene=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(xu(1,s)).toVar();return xu(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`}]}),WC=vb([Tne,Ene]),GC=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(xu(1,p)).toVar(),ee=k(xu(1,f)).toVar(),te=k(xu(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`}]}),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=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(xu(1,p)).toVar(),ee=k(xu(1,f)).toVar(),te=k(xu(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`}]}),qC=vb([GC,KC]),JC=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(BC(o.lessThan(j(4)),i,r)).toVar(),c=k(Su(2,BC(o.lessThan(j(4)),r,i))).toVar();return VC(s,fl(o.bitAnd(j(1)))).add(VC(c,fl(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`}]}),YC=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(BC(c.lessThan(j(8)),o,a)).toVar(),u=k(BC(c.lessThan(j(4)),a,BC(c.equal(j(12)).or(c.equal(j(14))),o,i))).toVar();return VC(l,fl(c.bitAnd(j(1)))).add(VC(u,fl(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`}]}),XC=vb([JC,YC]),ZC=O(([e,t,n])=>{let r=k(n).toVar(),i=k(t).toVar(),a=_l(e).toVar();return N(XC(a.x,i,r),XC(a.y,i,r),XC(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`}]}),QC=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=k(t).toVar(),s=_l(e).toVar();return N(XC(s.x,o,a,i),XC(s.y,o,a,i),XC(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`}]}),$C=vb([ZC,QC]),ew=O(([e])=>{let t=k(e).toVar();return Su(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),tw=O(([e])=>{let t=k(e).toVar();return Su(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),nw=O(([e])=>{let t=N(e).toVar();return Su(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),rw=vb([ew,nw]),iw=O(([e])=>{let t=N(e).toVar();return Su(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),aw=vb([tw,iw]),ow=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`}]}),sw=O(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(ow(n,A(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(ow(e,A(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(ow(t,A(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(ow(n,A(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(ow(e,A(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(ow(t,A(4))),t.addAssign(e)}),cw=O(([e,t,n])=>{let r=j(n).toVar(),i=j(t).toVar(),a=j(e).toVar();return r.bitXorAssign(i),r.subAssign(ow(i,A(14))),a.bitXorAssign(r),a.subAssign(ow(r,A(11))),i.bitXorAssign(a),i.subAssign(ow(a,A(25))),r.bitXorAssign(i),r.subAssign(ow(i,A(16))),a.bitXorAssign(r),a.subAssign(ow(r,A(4))),i.bitXorAssign(a),i.subAssign(ow(a,A(14))),r.bitXorAssign(i),r.subAssign(ow(i,A(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),lw=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`}]}),uw=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`}]}),dw=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 cw(r.add(j(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),fw=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)),cw(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),pw=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)),cw(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),mw=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)),sw(l,u,d),l.addAssign(j(i)),cw(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`}]}),hw=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)),sw(d,f,p),d.addAssign(j(o)),f.addAssign(j(a)),cw(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`}]}),gw=vb([dw,fw,pw,mw,hw]),_w=O(([e,t])=>{let n=A(t).toVar(),r=A(e).toVar(),i=j(gw(r,n)).toVar(),a=_l().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`}]}),vw=O(([e,t,n])=>{let r=A(n).toVar(),i=A(t).toVar(),a=A(e).toVar(),o=j(gw(a,i,r)).toVar(),s=_l().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`}]}),yw=vb([_w,vw]),bw=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(UC(t.x,n)).toVar(),a=k(UC(t.y,r)).toVar(),o=k(uw(i)).toVar(),s=k(uw(a)).toVar(),c=k(WC(XC(gw(n,r),i,a),XC(gw(n.add(A(1)),r),i.sub(1),a),XC(gw(n,r.add(A(1))),i,a.sub(1)),XC(gw(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return rw(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),xw=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(UC(t.x,n)).toVar(),o=k(UC(t.y,r)).toVar(),s=k(UC(t.z,i)).toVar(),c=k(uw(a)).toVar(),l=k(uw(o)).toVar(),u=k(uw(s)).toVar(),d=k(qC(XC(gw(n,r,i),a,o,s),XC(gw(n.add(A(1)),r,i),a.sub(1),o,s),XC(gw(n,r.add(A(1)),i),a,o.sub(1),s),XC(gw(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),XC(gw(n,r,i.add(A(1))),a,o,s.sub(1)),XC(gw(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),XC(gw(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),XC(gw(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 aw(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Sw=vb([bw,xw]),Cw=O(([e])=>{let t=M(e).toVar(),n=A().toVar(),r=A().toVar(),i=k(UC(t.x,n)).toVar(),a=k(UC(t.y,r)).toVar(),o=k(uw(i)).toVar(),s=k(uw(a)).toVar(),c=N(WC($C(yw(n,r),i,a),$C(yw(n.add(A(1)),r),i.sub(1),a),$C(yw(n,r.add(A(1))),i,a.sub(1)),$C(yw(n.add(A(1)),r.add(A(1))),i.sub(1),a.sub(1)),o,s)).toVar();return rw(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),ww=O(([e])=>{let t=N(e).toVar(),n=A().toVar(),r=A().toVar(),i=A().toVar(),a=k(UC(t.x,n)).toVar(),o=k(UC(t.y,r)).toVar(),s=k(UC(t.z,i)).toVar(),c=k(uw(a)).toVar(),l=k(uw(o)).toVar(),u=k(uw(s)).toVar(),d=N(qC($C(yw(n,r,i),a,o,s),$C(yw(n.add(A(1)),r,i),a.sub(1),o,s),$C(yw(n,r.add(A(1)),i),a,o.sub(1),s),$C(yw(n.add(A(1)),r.add(A(1)),i),a.sub(1),o.sub(1),s),$C(yw(n,r,i.add(A(1))),a,o,s.sub(1)),$C(yw(n.add(A(1)),r,i.add(A(1))),a.sub(1),o,s.sub(1)),$C(yw(n,r.add(A(1)),i.add(A(1))),a,o.sub(1),s.sub(1)),$C(yw(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 aw(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Tw=vb([Cw,ww]),Ew=O(([e])=>{let t=k(e).toVar(),n=A(HC(t)).toVar();return lw(gw(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Dw=O(([e])=>{let t=M(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar();return lw(gw(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Ow=O(([e])=>{let t=N(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar(),i=A(HC(t.z)).toVar();return lw(gw(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),kw=O(([e])=>{let t=yl(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar(),i=A(HC(t.z)).toVar(),a=A(HC(t.w)).toVar();return lw(gw(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Aw=vb([Ew,Dw,Ow,kw]),jw=O(([e])=>{let t=k(e).toVar(),n=A(HC(t)).toVar();return N(lw(gw(n,A(0))),lw(gw(n,A(1))),lw(gw(n,A(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Mw=O(([e])=>{let t=M(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar();return N(lw(gw(n,r,A(0))),lw(gw(n,r,A(1))),lw(gw(n,r,A(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Nw=O(([e])=>{let t=N(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar(),i=A(HC(t.z)).toVar();return N(lw(gw(n,r,i,A(0))),lw(gw(n,r,i,A(1))),lw(gw(n,r,i,A(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Pw=O(([e])=>{let t=yl(e).toVar(),n=A(HC(t.x)).toVar(),r=A(HC(t.y)).toVar(),i=A(HC(t.z)).toVar(),a=A(HC(t.w)).toVar();return N(lw(gw(n,r,i,a,A(0))),lw(gw(n,r,i,a,A(1))),lw(gw(n,r,i,a,A(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),Fw=vb([jw,Mw,Nw,Pw]),Iw=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 wg(o,()=>{c.addAssign(l.mul(Sw(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`}]}),Lw=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 wg(o,()=>{c.addAssign(l.mul(Tw(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`}]}),Rw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar();return M(Iw(s,o,a,i),Iw(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`}]}),zw=O(([e,t,n,r])=>{let i=k(r).toVar(),a=k(n).toVar(),o=A(t).toVar(),s=N(e).toVar(),c=N(Lw(s,o,a,i)).toVar(),l=k(Iw(s.add(N(A(19),A(193),A(17))),o,a,i)).toVar();return yl(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`}]}),Bw=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(Fw(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 ll(s.equal(A(2)),()=>_d(_.x).add(_d(_.y))),ll(s.equal(A(3)),()=>Md(_d(_.x),_d(_.y))),Ld(_,_)}).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`}]}),Vw=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(Fw(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 ll(l.equal(A(2)),()=>_d(b.x).add(_d(b.y)).add(_d(b.z))),ll(l.equal(A(3)),()=>Md(_d(b.x),_d(b.y),_d(b.z))),Ld(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`}]}),Hw=vb([Bw,Vw]),Uw=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(UC(a.x,o),UC(a.y,s)).toVar(),l=k(1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(c,e,t,o,s,i,r)).toVar();l.assign(jd(l,n))})}),ll(r.equal(A(0)),()=>{l.assign(ad(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),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(UC(a.x,o),UC(a.y,s)).toVar(),l=M(1e6,1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(c,e,t,o,s,i,r)).toVar();ll(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),ll(r.equal(A(0)),()=>{l.assign(ad(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,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(UC(a.x,o),UC(a.y,s)).toVar(),l=N(1e6,1e6,1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{let n=k(Hw(c,e,t,o,s,i,r)).toVar();ll(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)})})}),ll(r.equal(A(0)),()=>{l.assign(ad(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,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=N(e).toVar(),o=A().toVar(),s=A().toVar(),c=A().toVar(),l=N(UC(a.x,o),UC(a.y,s),UC(a.z,c)).toVar(),u=k(1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{wg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(l,e,t,n,o,s,c,i,r)).toVar();u.assign(jd(u,a))})})}),ll(r.equal(A(0)),()=>{u.assign(ad(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),qw=vb([Uw,Kw]),Jw=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(UC(a.x,o),UC(a.y,s),UC(a.z,c)).toVar(),u=M(1e6,1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{wg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(l,e,t,n,o,s,c,i,r)).toVar();ll(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),ll(r.equal(A(0)),()=>{u.assign(ad(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Yw=vb([Ww,Jw]),Xw=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(UC(a.x,o),UC(a.y,s),UC(a.z,c)).toVar(),u=N(1e6,1e6,1e6).toVar();return wg({start:-1,end:A(1),name:`x`,condition:`<=`},({x:e})=>{wg({start:-1,end:A(1),name:`y`,condition:`<=`},({y:t})=>{wg({start:-1,end:A(1),name:`z`,condition:`<=`},({z:n})=>{let a=k(Hw(l,e,t,n,o,s,c,i,r)).toVar();ll(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)})})})}),ll(r.equal(A(0)),()=>{u.assign(ad(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Zw=vb([Gw,Xw]),Qw=O(([e])=>{let t=e.y,n=e.z,r=N().toVar();return ll(t.lessThan(1e-4),()=>{r.assign(N(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(sd(i)).mul(6).toVar();let a=A(Ed(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());ll(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`}]}),$w=O(([e])=>{let t=N(e).toVar(),n=k(t.x).toVar(),r=k(t.y).toVar(),i=k(t.z).toVar(),a=k(jd(n,jd(r,i))).toVar(),o=k(Md(n,Md(r,i))).toVar(),s=k(o.sub(a)).toVar(),c=k().toVar(),l=k().toVar(),u=k().toVar();return u.assign(o),ll(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),ll(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{ll(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(bu(2,i.sub(n).div(s)))}).Else(()=>{c.assign(bu(4,n.sub(r).div(s)))}),c.mulAssign(1/6),ll(c.lessThan(0),()=>{c.addAssign(1)})}),N(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),eT=O(([e])=>{let t=N(e).toVar(),n=vl(Ou(t,N(.04045))).toVar(),r=N(t.div(12.92)).toVar(),i=N(zd(Md(t.add(N(.055)),N(0)).div(1.055),N(2.4))).toVar();return Kd(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),tT=(e,t)=>{e=k(e),t=k(t);let n=M(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Xd(e.sub(n),e.add(n),t)},nT=(e,t,n,r)=>Kd(e,t,n[r].clamp()),rT=(e,t,n=cp())=>nT(e,t,n,`x`),iT=(e,t,n=cp())=>nT(e,t,n,`y`),aT=(e,t,n,r,i)=>Kd(e,t,tT(n,r[i])),oT=(e,t,n,r=cp())=>aT(e,t,n,r,`x`),sT=(e,t,n,r=cp())=>aT(e,t,n,r,`y`),cT=(e=1,t=0,n=cp())=>n.mul(e).add(t),lT=(e,t=1)=>(e=k(e),e.abs().pow(t).mul(e.sign())),uT=(e,t=1,n=.5)=>k(e).sub(n).mul(t).add(n),dT=(e=cp(),t=1,n=0)=>Sw(e.convert(`vec2|vec3`)).mul(t).add(n),fT=(e=cp(),t=1,n=0)=>Tw(e.convert(`vec2|vec3`)).mul(t).add(n),pT=(e=cp(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=yl(Tw(e),Sw(e.add(M(19,73))));return r.mul(t).add(n)},mT=(e=cp(),t=1)=>qw(e.convert(`vec2|vec3`),t,A(1)),hT=(e=cp(),t=1)=>Yw(e.convert(`vec2|vec3`),t,A(1)),gT=(e=cp(),t=1)=>Zw(e.convert(`vec2|vec3`),t,A(1)),_T=(e=cp())=>Aw(e.convert(`vec2|vec3`)),vT=(e=cp(),t=3,n=2,r=.5,i=1)=>Iw(e,A(t),n,r).mul(i),yT=(e=cp(),t=3,n=2,r=.5,i=1)=>Rw(e,A(t),n,r).mul(i),bT=(e=cp(),t=3,n=2,r=.5,i=1)=>Lw(e,A(t),n,r).mul(i),xT=(e=cp(),t=3,n=2,r=.5,i=1)=>zw(e,A(t),n,r).mul(i),ST=O(([e,t,n])=>{let r=ld(e).toVar(),i=xu(k(.5).mul(t.sub(n)),cm).div(r).toVar(),a=xu(k(-.5).mul(t.sub(n)),cm).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=jd(o.x,o.y,o.z).toVar(),c=cm.add(r.mul(s)).toVar();return c.sub(n)}),CT=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(Su(n,n).sub(Su(r,r)))),a});var I=Object.freeze({__proto__:null,BRDF_GGX:gv,BRDF_Lambert:ev,BasicPointShadowFilter:EC,BasicShadowFilter:sC,Break:Eg,Const:hf,Continue:Tg,DFGApprox:_v,D_GGX:pv,Discard:$f,EPSILON:qu,F_Schlick:$_,Fn:O,INFINITY:Ju,If:ll,Loop:wg,NodeAccess:cc,NodeShaderStage:ac,NodeType:sc,NodeUpdateType:oc,PCFShadowFilter:cC,PCFSoftShadowFilter:lC,PI:Yu,PI2:Xu,PointShadowFilter:DC,Return:ep,Schlick_to_F0:yv,ScriptableNodeResources:Xx,ShaderNode:rl,Stack:ul,Switch:gee,TBNViewMatrix:ih,VSMShadowFilter:uC,V_GGX_SmithCorrelated:dv,Var:mf,abs:_d,acesFilmicToneMapping:jx,acos:hd,add:bu,addMethodChaining:w,addNodeElement:ap,agxToneMapping:Fx,all:Zu,alphaT:Hl,and:ju,anisotropy:Ul,anisotropyB:Gl,anisotropyT:Wl,any:Qu,append:bee,array:mu,arrayBuffer:vee,asin:md,assign:gu,atan:gd,atan2:tf,atomicAdd:kS,atomicAnd:NS,atomicFunc:ES,atomicLoad:DS,atomicMax:jS,atomicMin:MS,atomicOr:PS,atomicStore:OS,atomicSub:AS,atomicXor:FS,attenuationColor:ru,attenuationDistance:nu,attribute:sp,attributeArray:gne,backgroundBlurriness:Hb,backgroundIntensity:Ub,backgroundRotation:Wb,batch:pg,billboarding:Zte,bitAnd:Fu,bitNot:Iu,bitOr:Lu,bitXor:Ru,bitangentGeometry:Qm,bitangentLocal:$m,bitangentView:eh,bitangentWorld:th,bitcast:kd,blendBurn:$b,blendColor:rx,blendDodge:ex,blendOverlay:nx,blendScreen:tx,blur:yy,bool:fl,buffer:Sp,bufferAttribute:Lf,bumpMap:mh,burn:ox,bvec2:hl,bvec3:vl,bvec4:Sl,bypass:qf,cache:Wf,call:_u,cameraFar:jp,cameraIndex:kp,cameraNear:Ap,cameraNormalMatrix:Ip,cameraPosition:Lp,cameraProjectionMatrix:Mp,cameraProjectionMatrixInverse:Np,cameraViewMatrix:Pp,cameraWorldMatrix:Fp,cbrt:Wd,cdl:hx,ceil:cd,checker:RC,cineonToneMapping:kx,clamp:qd,clearcoat:Fl,clearcoatRoughness:Il,code:Rx,color:dl,colorSpaceToWorking:Ef,colorToDirection:F_,compute:Hf,computeSkinning:Sg,cond:cf,context:uf,convert:Dl,convertColorSpace:Df,convertToTexture:dne,cos:fd,cross:Rd,cubeTexture:Lm,cubeTextureBase:Im,cubeToUV:TC,dFdx:Sd,dFdy:Cd,dashSize:Xl,debug:ip,decrement:Wu,decrementBefore:Hu,defaultBuildStages:uc,defaultShaderStages:lc,defined:tl,degrees:ed,deltaTime:bb,densityFog:iS,densityFogFactor:tS,depth:p_,depthPass:wx,difference:Id,diffuseColor:jl,directPointLight:IC,directionToColor:P_,dispersion:iu,distance:Fd,div:Cu,dodge:sx,dot:Ld,drawIndex:sg,dynamicBufferAttribute:Rf,element:El,emissive:Ml,equal:Tu,equals:Ad,equirectUV:z_,exp:td,exp2:nd,expression:Qf,faceDirection:mm,faceForward:Zd,faceforward:nf,float:k,floor:sd,fog:nS,fract:ud,frameGroup:cu,frameId:Vte,frontFacing:pm,fwidth:Dd,gain:Pte,gapSize:Zl,getConstNodeType:nl,getCurrentStack:cl,getDirection:hy,getDistanceAttenuation:FC,getGeometryRoughness:lv,getNormalFromDepth:pne,getParallaxCorrectNormal:ST,getRoughness:uv,getScreenPosition:fne,getShIrradianceAt:CT,getShadowMaterial:pC,getShadowRenderObjectFunction:gC,getTextureIndex:mb,getViewPosition:Rb,globalId:pS,glsl:Vx,glslFn:Wx,grayscale:ux,greaterThan:Ou,greaterThanEqual:Au,hash:Nte,highpModelNormalViewMatrix:im,highpModelViewMatrix:rm,hue:px,increment:Uu,incrementBefore:Vu,instance:lg,instanceIndex:rg,instancedArray:_ne,instancedBufferAttribute:zf,instancedDynamicBufferAttribute:Bf,instancedMesh:dg,int:A,inverseSqrt:od,inversesqrt:rf,invocationLocalIndex:og,invocationSubgroupIndex:ag,ior:$l,iridescence:zl,iridescenceIOR:Bl,iridescenceThickness:Vl,ivec2:pl,ivec3:gl,ivec4:bl,js:zx,label:df,length:yd,lengthSq:Gd,lessThan:Du,lessThanEqual:ku,lightPosition:BS,lightProjectionUV:zS,lightShadowMatrix:RS,lightTargetDirection:US,lightTargetPosition:VS,lightViewPosition:HS,lightingContext:Lg,lights:YS,linearDepth:m_,linearToneMapping:Dx,localId:mS,log:rd,log2:id,logarithmicDepthToViewZ:d_,loop:Dg,luminance:mx,mat2:Cl,mat3:wl,mat4:Tl,matcapUV:qy,materialAO:Qh,materialAlphaTest:gh,materialAnisotropy:Fh,materialAnisotropyVector:$h,materialAttenuationColor:Uh,materialAttenuationDistance:Hh,materialClearcoat:kh,materialClearcoatNormal:jh,materialClearcoatRoughness:Ah,materialColor:_h,materialDispersion:Xh,materialEmissive:yh,materialEnvIntensity:Om,materialEnvRotation:km,materialIOR:Vh,materialIridescence:Ih,materialIridescenceIOR:Lh,materialIridescenceThickness:Rh,materialLightMap:Zh,materialLineDashOffset:Jh,materialLineDashSize:Gh,materialLineGapSize:Kh,materialLineScale:Wh,materialLineWidth:qh,materialMetalness:Dh,materialNormal:Oh,materialOpacity:bh,materialPointSize:Yh,materialReference:Wm,materialReflectivity:Th,materialRefractionRatio:Dm,materialRotation:Mh,materialRoughness:Eh,materialSheen:Nh,materialSheenRoughness:Ph,materialShininess:vh,materialSpecular:xh,materialSpecularColor:Ch,materialSpecularIntensity:Sh,materialSpecularStrength:wh,materialThickness:Bh,materialTransmission:zh,max:Md,maxMipLevel:fp,mediumpModelViewMatrix:nm,metalness:Pl,min:jd,mix:Kd,mixElement:$d,mod:wu,modInt:Ku,modelDirection:qp,modelNormalMatrix:$p,modelPosition:Yp,modelRadius:Qp,modelScale:Xp,modelViewMatrix:tm,modelViewPosition:Zp,modelViewProjection:eg,modelWorldMatrix:Jp,modelWorldMatrixInverse:em,morphReference:Ng,mrt:hb,mul:Su,mx_aastep:tT,mx_cell_noise_float:_T,mx_contrast:uT,mx_fractal_noise_float:vT,mx_fractal_noise_vec2:yT,mx_fractal_noise_vec3:bT,mx_fractal_noise_vec4:xT,mx_hsvtorgb:Qw,mx_noise_float:dT,mx_noise_vec3:fT,mx_noise_vec4:pT,mx_ramplr:rT,mx_ramptb:iT,mx_rgbtohsv:$w,mx_safepower:lT,mx_splitlr:oT,mx_splittb:sT,mx_srgb_texture_to_lin_rec709:eT,mx_transform_uv:cT,mx_worley_noise_float:mT,mx_worley_noise_vec2:hT,mx_worley_noise_vec3:gT,namespace:Gf,negate:bd,neutralToneMapping:Ix,nodeArray:al,nodeImmutable:D,nodeObject:T,nodeObjects:il,nodeProxy:E,normalFlat:_m,normalGeometry:hm,normalLocal:gm,normalMap:uh,normalView:vm,normalWorld:ym,normalize:ld,not:Nu,notEqual:Eu,numWorkgroups:dS,objectDirection:Bp,objectGroup:uu,objectPosition:Hp,objectRadius:Gp,objectScale:Up,objectViewPosition:Wp,objectWorldMatrix:Vp,oneMinus:xd,or:Mu,orthographicDepthToViewZ:s_,oscSawtooth:Jte,oscSine:Gte,oscSquare:Kte,oscTriangle:qte,output:Yl,outputStruct:jte,overlay:lx,overloadingFn:vb,parabola:gb,parallaxDirection:ah,parallaxUV:oh,parameter:Tte,pass:Sx,passTexture:Cx,pcurve:Fte,perspectiveDepthToViewZ:l_,pmremTexture:Uy,pointShadow:NC,pointUV:yne,pointWidth:Ql,positionGeometry:am,positionLocal:om,positionPrevious:sm,positionView:um,positionViewDirection:dm,positionWorld:cm,positionWorldDirection:lm,posterize:_x,pow:zd,pow2:Bd,pow3:Vd,pow4:Hd,premult:ix,property:kl,radians:$u,rand:Qd,range:cS,rangeFog:rS,rangeFogFactor:eS,reciprocal:Td,reference:Vm,referenceBuffer:Hm,reflect:Pd,reflectVector:Mm,reflectView:Am,reflector:one,refract:Yd,refractVector:Nm,refractView:jm,reinhardToneMapping:Ox,remainder:Gu,remap:Yf,remapClamp:Xf,renderGroup:lu,renderOutput:np,rendererReference:Mf,rotate:Jy,rotateUV:Yte,roughness:Nl,round:wd,rtt:Lb,sRGBTransferEOTF:bf,sRGBTransferOETF:xf,sampler:yp,samplerComparison:bp,saturate:Jd,saturation:dx,screen:cx,screenCoordinate:Wg,screenSize:Ug,screenUV:Hg,scriptable:Qx,scriptableValue:qx,select:sf,setCurrentStack:sl,shaderStages:dc,shadow:CC,shadowPositionWorld:ZS,shapeCircle:zC,sharedUniformGroup:su,sheen:Ll,sheenRoughness:Rl,shiftLeft:zu,shiftRight:Bu,shininess:Jl,sign:vd,sin:dd,sinc:Ite,skinning:xg,smoothstep:Xd,smoothstepElement:ef,specularColor:Kl,specularF90:ql,spherizeUV:Xte,split:yee,spritesheetUV:ene,sqrt:ad,stack:fb,step:Nd,storage:_g,storageBarrier:yS,storageObject:vg,storageTexture:Gb,string:_ee,struct:Ate,sub:xu,subgroupIndex:ig,subgroupSize:hS,tan:pd,tangentGeometry:Gm,tangentLocal:Km,tangentView:qm,tangentWorld:Jm,temp:gf,texture:gp,texture3D:Kb,textureBarrier:bS,textureBicubic:Lv,textureCubeUV:gy,textureLoad:vp,textureSize:up,textureStore:xne,thickness:tu,time:yb,timerDelta:Wte,timerGlobal:Ute,timerLocal:Hte,toneMapping:Pf,toneMappingExposure:Ff,toonOutlinePass:Ex,transformDirection:Ud,transformNormal:Cm,transformNormalToView:wm,transformedBentNormalView:sh,transformedBitangentView:nh,transformedBitangentWorld:rh,transformedClearcoatNormalView:Sm,transformedNormalView:bm,transformedNormalWorld:xm,transformedTangentView:Ym,transformedTangentWorld:Xm,transmission:eu,transpose:Od,triNoise3D:Rte,triplanarTexture:nne,triplanarTextures:xb,trunc:Ed,tslFn:xee,uint:j,uniform:fu,uniformArray:Tp,uniformCubeTexture:Rm,uniformGroup:ou,uniformTexture:_p,uniforms:Ep,unpremult:ax,userData:qb,uv:cp,uvec2:ml,uvec3:_l,uvec4:xl,varying:vf,varyingProperty:Al,vec2:M,vec3:N,vec4:yl,vectorComponents:fc,velocity:Qb,vertexColor:T_,vertexIndex:ng,vertexStage:yf,vibrance:fx,viewZToLogarithmicDepth:u_,viewZToOrthographicDepth:o_,viewZToPerspectiveDepth:c_,viewport:Gg,viewportBottomLeft:Zg,viewportCoordinate:qg,viewportDepthTexture:i_,viewportLinearDepth:h_,viewportMipTexture:t_,viewportResolution:Yg,viewportSafeUV:Qte,viewportSharedTexture:N_,viewportSize:Kg,viewportTexture:e_,viewportTopLeft:Xg,viewportUV:Jg,wgsl:Bx,wgslFn:Gx,workgroupArray:CS,workgroupBarrier:vS,workgroupId:fS,workingToColorSpace:Tf,xor:Pu});const wT=new ub;var TT=class extends Qy{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(wT),wT.a=r._clearColor.a;else if(i.isColor===!0)i.getRGB(wT),wT.a=1,a=!0;else if(i.isNode===!0){let n=this.get(e),a=i;wT.copy(r._clearColor);let o=n.backgroundMesh;if(o===void 0){let e=uf(yl(a).mul(Ub),{getUV:()=>Wb.mul(ym),getTextureLevel:()=>Hb}),t=eg;t=t.setZ(t.w);let r=new E_;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 La(new ko(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=yl(a).mul(Ub),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`?wT.set(0,0,0,1):o===`alpha-blend`&&wT.set(0,0,0,0),r.autoClear===!0||a===!0){let e=n.clearColorValue;e.r=wT.r,e.g=wT.g,e.b=wT.b,e.a=wT.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 ET=0;var DT=class{constructor(e=``,t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=ET++}},OT=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 DT(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}},kT=class{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}},AT=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}},jT=class{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}},MT=class extends jT{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}},NT=class{constructor(e,t,n=``){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,`isNodeCode`,{value:!0})}};let PT=0;var FT=class{constructor(e=null){this.id=PT++,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)}},IT=class{constructor(e,t){this.name=e,this.members=t,this.output=!1}},LT=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}},RT=class extends LT{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}},zT=class extends LT{constructor(e,t=new ur){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}},BT=class extends LT{constructor(e,t=new C){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}},VT=class extends LT{constructor(e,t=new Fr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}},HT=class extends LT{constructor(e,t=new ia){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}},UT=class extends LT{constructor(e,t=new Rs){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}},WT=class extends LT{constructor(e,t=new mr){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}},GT=class extends LT{constructor(e,t=new fi){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}},KT=class extends RT{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}},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}};const eE=new WeakMap,tE=new Map([[Int8Array,`int`],[Int16Array,`int`],[Int32Array,`int`],[Uint8Array,`uint`],[Uint16Array,`uint`],[Uint32Array,`uint`],[Float32Array,`float`]]),nE=e=>/e/g.test(e)?String(e).replace(/\+/g,``):(e=Number(e),e+(e%1?``:`.0`));var rE=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=fb(),this.stacks=[],this.tab=` `,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new FT,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=eE.get(this.renderer);return e===void 0&&(e=new Xy,eE.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Ir(e,t,n)}createCubeRenderTarget(e,t){return new B_(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 DT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new DT(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 dc)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!==oc.NONE&&this.updateNodes.push(e.getSelf())}for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==oc.NONE&&this.updateBeforeNodes.push(e.getSelf()),n!==oc.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 FT(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 ia:e===`vec2`?t=new ur:e===`vec3`?t=new C:e===`vec4`&&(t=new Fr)),e===`float`)return nE(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`)}( ${nE(t.r)}, ${nE(t.g)}, ${nE(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 kT(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=Ys(e),r=t===`float`?``:t[0];return/mat2/.test(t)===!0&&(n=n.replace(`vec`,`mat`)),r+n}getTypeFromArray(e){return tE.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 ga)&&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=fb(this.stack),this.stacks.push(cl()||this.stack),sl(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,sl(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 kT(`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 IT(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 AT(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 jT(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 MT(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 NT(`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 Hx,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 db(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 FT,this.stack=fb();for(let n of uc)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 E_),e.build(this)}else this.addFlow(`compute`,e);for(let e of uc){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage(`vertex`,this.context.vertex);for(let t of dc){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 KT(e);if(t===`vec2`||t===`ivec2`||t===`uvec2`)return new qT(e);if(t===`vec3`||t===`ivec3`||t===`uvec3`)return new JT(e);if(t===`vec4`||t===`ivec4`||t===`uvec4`)return new YT(e);if(t===`color`)return new XT(e);if(t===`mat2`)return new ZT(e);if(t===`mat3`)return new QT(e);if(t===`mat4`)return new $T(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.`)}},iE=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===oc.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===oc.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===oc.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===oc.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===oc.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===oc.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),n=e.updateReference(this);if(t===oc.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===oc.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===oc.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}},aE=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};aE.isNodeFunctionInput=!0;var oE=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 sE=new fi,cE=new fi;let lE=null;var uE=class extends PC{static get type(){return`RectAreaLightNode`}constructor(e=null){super(e),this.halfHeight=fu(new C).setGroup(lu),this.halfWidth=fu(new C).setGroup(lu),this.updateType=oc.RENDER}update(e){super.update(e);let{light:t}=this,n=e.camera.matrixWorldInverse;cE.identity(),sE.copy(t.matrixWorld),sE.premultiply(n),cE.extractRotation(sE),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(cE),this.halfHeight.value.applyMatrix4(cE)}setupDirectRectArea(e){let t,n;e.isAvailable(`float32Filterable`)?(t=gp(lE.LTC_FLOAT_1),n=gp(lE.LTC_FLOAT_2)):(t=gp(lE.LTC_HALF_1),n=gp(lE.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){lE=e}},dE=class extends PC{static get type(){return`SpotLightNode`}constructor(e=null){super(e),this.coneCosNode=fu(0).setGroup(lu),this.penumbraCosNode=fu(0).setGroup(lu),this.cutoffDistanceNode=fu(0).setGroup(lu),this.decayExponentNode=fu(0).setGroup(lu),this.colorNode=fu(this.color).setGroup(lu)}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 Xd(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=gp(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}}},fE=class extends dE{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=gp(n,M(e,0),0).r}else r=super.getSpotAttenuation(t);return r}};const pE=O(([e,t])=>{let n=e.abs().sub(t);return yd(Md(n,0)).add(jd(Md(n.x,n.y),0))});var mE=class extends dE{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=pE(r.xy.sub(M(.5)),M(.5)),a=Cu(-1,xu(1,hd(t)).sub(1)),o=Jd(i.mul(-2).mul(a));return o}},hE=class extends PC{static get type(){return`AmbientLightNode`}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}},gE=class extends PC{static get type(){return`HemisphereLightNode`}constructor(e=null){super(e),this.lightPositionNode=BS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=fu(new ia).setGroup(lu)}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=ym.dot(r),a=i.mul(.5).add(.5),o=Kd(n,t,a);e.context.irradiance.addAssign(o)}},_E=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=Tp(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=CT(ym,this.lightProbe);e.context.irradiance.addAssign(t)}},vE=class{parseFunction(){console.warn(`Abstract function.`)}},yE=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};yE.isNodeFunction=!0;const bE=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xE=/[a-z_0-9]+/gi,SE=`#pragma main`,CE=e=>{e=e.trim();let t=e.indexOf(SE),n=t===-1?e:e.slice(t+SE.length),r=n.match(bE);if(r!==null&&r.length===5){let i=r[4],a=[],o=null;for(;(o=xE.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 aE(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 wE=class extends yE{constructor(e){let{type:t,inputs:n,name:r,precision:i,inputsCode:a,blockCode:o,headerCode:s}=CE(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}},TE=class extends vE{parseFunction(e){return new wE(e)}};const EE=new WeakMap,DE=[],OE=[];var kE=class extends Qy{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new iE,this.nodeBuilderCache=new Map,this.callHashCache=new Xy,this.groupsData=new Xy,this.cacheLib={}}updateGroup(e){let t=e.groupNode,n=t.name;if(n===uu.name)return!0;if(n===lu.name){let t=this.get(e),n=this.nodeFrame.renderId;return t.renderId===n?!1:(t.renderId=n,!0)}if(n===cu.name){let t=this.get(e),n=this.nodeFrame.frameId;return t.frameId===n?!1:(t.frameId=n,!0)}DE[0]=t,DE[1]=e;let r=this.groupsData.get(DE);return r===void 0&&this.groupsData.set(DE,r={}),DE.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 OT(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){DE[0]=e,DE[1]=t;let n=this.renderer.info.calls,r=this.callHashCache.get(DE)||{};if(r.callId!==n){let i=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&OE.push(t.getCacheKey(!0)),i&&OE.push(i.getCacheKey()),a&&OE.push(a.getCacheKey()),OE.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),OE.push(this.renderer.shadowMap.enabled?1:0),r.callId=n,r.cacheKey=Us(OE),this.callHashCache.set(DE,r),OE.length=0}return DE.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 Uy(n);{let e;return e=n.isCubeTexture===!0?Lm(n):gp(n),K_(e)}}else if(n.isTexture===!0)return gp(n,Hg.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=Vm(`color`,`color`,n).setGroup(lu),t=Vm(`density`,`float`,n).setGroup(lu);return nS(e,tS(t))}else if(n.isFog){let e=Vm(`color`,`color`,n).setGroup(lu),t=Vm(`near`,`float`,n).setGroup(lu),r=Vm(`far`,`float`,n).setGroup(lu);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 Lm(n);if(n.isTexture===!0)return gp(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=EE.get(e);return t!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?Kb(e,N(Hg,Op(`gl_ViewID_OVR`))).renderOutput(t.toneMapping,t.currentColorSpace):gp(e,Hg).renderOutput(t.toneMapping,t.currentColorSpace);return EE.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 iE,this.nodeBuilderCache=new Map,this.cacheLib={}}};const AE=new go;var jE=class e{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey=``,this.shadowPass=!1,this.viewNormalMatrix=new mr,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++){AE.copy(e[i]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let r=t[n+i],a=AE.normal;r.x=-a.x,r.y=-a.y,r.z=-a.z,r.w=AE.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 Fr;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}},ME=class{constructor(e,t){this.bundleGroup=e,this.camera=t}};const NE=[];var PE=class{constructor(){this.bundles=new Xy}get(e,t){let n=this.bundles;NE[0]=e,NE[1]=t;let r=n.get(NE);return r===void 0&&(r=new ME(e,t),n.set(NE,r)),NE.length=0,r}dispose(){this.bundles=new Xy}},FE=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 IE=new JS,LE=[];var RE=class extends Xy{constructor(){super()}createNode(e=[]){return new JS().setLights(e)}getNode(e,t){if(e.isQuadMesh)return IE;LE[0]=e,LE[1]=t;let n=this.get(LE);return n===void 0&&(n=this.createNode(),this.set(LE,n)),LE.length=0,n}},zE=class extends Ir{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 BE=new C,VE=new C;var HE=class extends qn{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Xa,this._cameraL.viewport=new Fr,this._cameraR=new Xa,this._cameraR.viewport=new Fr,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new ws,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._supportsLayers=!1,this._frameBufferTargets=null,this._createXRLayer=YE.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new ur,this._onSessionEvent=KE.bind(this),this._onSessionEnd=qE.bind(this),this._onInputSourcesChange=JE.bind(this),this._onAnimationFrame=XE.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 Oo(e,t),l=new zE(i,a,{format:bt,type:st,depthTexture:new Eo(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 sa({color:16777215,side:ne});u.map=l.texture,u.map.offset.y=1,u.map.repeat.y=-1;let d=new La(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 sa({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 Do(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),u=new zE(a,o,{format:bt,type:st,depthTexture:new Eo(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 sa({color:16777215,side:re});d.map=u.texture,d.map.offset.y=1,d.map.repeat.y=-1;let f=new La(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 sa({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 dr,n=this._renderer,r=this.isPresenting,i=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;let o=new ur;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 Ib(new E_),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 Eo(l.textureWidth,l.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n,d);if(this._xrRenderTarget=new zE(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 sa({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 zE(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;WE(i,s);for(let e=0;e<c.length;e++)WE(c[e],s);c.length===2?UE(i,a,o):i.projectionMatrix.copy(a.projectionMatrix),GE(e,i,s)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new io,this._controllers[e]=t),t}};function UE(e,t,n){BE.setFromMatrixPosition(t.matrixWorld),VE.setFromMatrixPosition(n.matrixWorld);let r=BE.distanceTo(VE),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 WE(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function GE(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=Zn*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}function KE(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 qE(){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 zE(e.pixelwidth,e.pixelheight,{format:bt,type:st,depthTexture:new Eo(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 JE(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 YE(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 XE(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 Xa,c.layers.enable(r),c.viewport=new Fr,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 ZE=new ao,QE=new ur,$E=new Fr,eD=new yo,tD=new So,nD=new fi,rD=new Fr;var iD=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 lte,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new FE,this.lighting=new RE,this._getFallback=c,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Fr(0,0,this._width,this._height),this._scissor=new Fr(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 Ib(new E_),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 ub(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 HE(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 kE(this,n),this._animation=new ete(this._nodes,this.info),this._attributes=new ste(n),this._background=new TT(this,this._nodes),this._geometries=new cte(this._attributes,this.info),this._textures=new wte(this,n,this.info),this._pipelines=new pte(n,this._nodes),this._bindings=new mte(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new ite(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new _te(this.lighting),this._bundles=new PE,this._renderContexts=new Ste,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:ZE;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 jE,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=rm,this.overrideNodes.modelNormalViewMatrix=im):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===rm&&this.overrideNodes.modelNormalViewMatrix===im}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(QE),{depth:o,stencil:s}=this,c=this._frameBufferTarget;c===null&&(c=new Ir(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:ZE,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(QE),$E.set(0,0,QE.width,QE.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($E)===!1,p.scissorValue.copy(_).multiplyScalar(v).floor(),p.scissor=this._scissorTest&&p.scissorValue.equals($E)===!1,p.scissorValue.width>>=d,p.scissorValue.height>>=d,p.clippingContext||=new jE,p.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,f);let x=t.isArrayCamera?tD:eD;t.isArrayCamera||(nD.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),x.setFromProjectionMatrix(nD,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=rD.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=rD.copy(t).floor();else{console.error(`THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.`);return}else t=rD.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?tD:eD;if(!e.frustumCulled||a.intersectsSprite(e,t)){this.sortObjects===!0&&rD.setFromMatrixPosition(e.matrixWorld).applyMatrix4(nD);let{geometry:t,material:a}=e;a.visible&&r.push(e,t,a,n,rD.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?tD:eD;if(!e.frustumCulled||a.intersectsObject(e,t)){let{geometry:t,material:a}=e;if(this.sortObjects===!0&&(t.boundingSphere===null&&t.computeBoundingSphere(),rD.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(nD)),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,rD.z,c,i)}}else a.visible&&r.push(e,t,a,n,rD.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}},aD=class{constructor(e=``){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}};function oD(e){return e+(eb-e%eb)%eb}var sD=class extends aD{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return oD(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}},cD=class extends sD{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}};let lD=0;var uD=class extends cD{constructor(e,t){super(`UniformBuffer_`+ lD++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}},dD=class extends cD{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%eb,s=o%i,c=o+s;t+=s,c!==0&&eb-c<a&&(t+=eb-c),r.offset=t/e,t+=a}return Math.ceil(t/eb)*eb}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(pD(n,r,i)===!1){let e=this.buffer;e.set(r,i),fD(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 fD(e,t,n){for(let r=0,i=t.length;r<i;r++)e[n+r]=t[r]}function pD(e,t,n){for(let r=0,i=t.length;r<i;r++)if(e[n+r]!==t[r])return!1;return!0}let mD=0;var hD=class extends dD{constructor(e,t){super(e),this.id=mD++,this.groupNode=t,this.isNodeUniformsGroup=!0}};let gD=0;var _D=class extends aD{constructor(e,t){super(e),this.id=gD++,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)}},vD=class extends _D{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)}},yD=class extends vD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}},bD=class extends vD{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}};const xD={textureDimensions:`textureSize`,equals:`equal`},SD={low:`lowp`,medium:`mediump`,high:`highp`},CD={swizzleAssign:!0,storageBuffer:!1},wD={perspective:`smooth`,linear:`noperspective`},TD={centroid:`centroid`,"flat first":`flat`,"flat either":`flat`},ED=`
|
|
66
66
|
precision highp float;
|
|
67
67
|
precision highp int;
|
|
68
68
|
precision highp sampler2D;
|
|
@@ -90,7 +90,7 @@ precision lowp samplerCubeShadow;
|
|
|
90
90
|
${n.code}
|
|
91
91
|
return ${n.result};
|
|
92
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
|
|
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 uo(t.array,s,c,a,o[t.array.constructor.name]||pt);d.needsUpdate=!0,d.isPBOTexture=!0;let f=new mp(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=`.`+fc.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
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=SD[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
95
|
`))+`
|
|
96
96
|
`}return i+=n.join(`
|
|
@@ -178,7 +178,7 @@ void main() {
|
|
|
178
178
|
|
|
179
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
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 vD(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`)o=new yD(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new bD(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 uD(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 hD(n+`_`+s,r),e[s]=a,c.push(a)),o=this.getNodeUniform(i,t),a.addUniform(o)}a.uniformGPU=o}return i}};let OD=null,kD=null;var AD=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 OD||=new lr,this.renderer.getDrawingBufferSize(OD)}setScissorTest(){}getClearColor(){let e=this.renderer;return kD||=new ob,e.getClearColor(kD),kD.getRGB(kD),kD}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 jD=0;var MD=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}},ND=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:jD++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new MD(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 PD,FD;var ID=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;PD={[de]:e.FUNC_ADD,[fe]:e.FUNC_SUBTRACT,[pe]:e.FUNC_REVERSE_SUBTRACT},FD={[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(PD[t],PD[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(FD[n],FD[r],FD[a],FD[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)}},LD=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 RD=!1,zD,BD,VD;var HD=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},RD===!1&&(this._init(),RD=!0)}_init(){let e=this.gl;zD={[Ze]:e.REPEAT,[Qe]:e.CLAMP_TO_EDGE,[$e]:e.MIRRORED_REPEAT},BD={[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},VD={[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,zD[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,zD[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,zD[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,BD[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,BD[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,VD[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=UD(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=UD(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 UD(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 WD=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)}},GD=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 KD={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 qD=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)}}},JD=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(){}},YD=class extends JD{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 XD=new lr;var ZD=class extends AD{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 WD(this),this.capabilities=new GD(this),this.attributeUtils=new ND(this),this.textureUtils=new HD(this),this.bufferRenderer=new qD(this),this.state=new ID(this),this.utils=new LD(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 YD(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(XD);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(XD);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 DD(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(`
|
|
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 vD(i.name,i.node,r),c.push(o);else if(t===`cubeTexture`)o=new yD(i.name,i.node,r),c.push(o);else if(t===`texture3D`)o=new bD(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 uD(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 hD(n+`_`+s,r),e[s]=a,c.push(a)),o=this.getNodeUniform(i,t),a.addUniform(o)}a.uniformGPU=o}return i}};let OD=null,kD=null;var AD=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){br(`WebGPURenderer: Timestamp tracking is disabled.`);return}let t=this.timestampQueryPool[e];if(!t){br(`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 OD||=new ur,this.renderer.getDrawingBufferSize(OD)}setScissorTest(){}getClearColor(){let e=this.renderer;return kD||=new ub,e.getClearColor(kD),kD.getRGB(kD),kD}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas===void 0?vr():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 jD=0;var MD=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}},ND=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:jD++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){let e=this._createBuffer(r,t,i,a);u=new MD(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 PD,FD;var ID=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;PD={[de]:e.FUNC_ADD,[fe]:e.FUNC_SUBTRACT,[pe]:e.FUNC_REVERSE_SUBTRACT},FD={[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 Fr().fromArray(t),this.currentViewport=new Fr().fromArray(n),this._tempVec4=new Fr}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(PD[t],PD[i]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=i),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||o!==this.currentBlendDstAlpha)&&(c.blendFuncSeparate(FD[n],FD[r],FD[a],FD[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)}},LD=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=wr.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 RD=!1,zD,BD,VD;var HD=class{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},RD===!1&&(this._init(),RD=!0)}_init(){let e=this.gl;zD={[Ze]:e.REPEAT,[Qe]:e.CLAMP_TO_EDGE,[$e]:e.MIRRORED_REPEAT},BD={[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},VD={[Fn]:e.NEVER,[Hn]:e.ALWAYS,[In]:e.LESS,[Rn]:e.LEQUAL,[Ln]:e.EQUAL,[Vn]:e.GEQUAL,[zn]:e.GREATER,[Bn]: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:wr.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:wr.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=wr.getPrimaries(wr.workingColorSpace),o=t.colorSpace===mn?null:wr.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,zD[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,zD[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,zD[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,BD[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,BD[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,VD[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=UD(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=UD(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 UD(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 WD=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)}},GD=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 KD={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 qD=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)}}},JD=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(){}},YD=class extends JD{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 br(`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 XD=new ur;var ZD=class extends AD{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 WD(this),this.capabilities=new GD(this),this.attributeUtils=new ND(this),this.textureUtils=new HD(this),this.bufferRenderer=new qD(this),this.state=new ID(this),this.utils=new LD(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 Gn}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 YD(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(XD);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(XD);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):br(`THREE.WebGLRenderer: WEBGL_multi_draw not supported.`):(br(`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 DD(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
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
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
184
|
|
|
@@ -190,7 +190,7 @@ Program Info Log: `+i+`
|
|
|
190
190
|
`+a+`
|
|
191
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
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(KD).filter(t=>KD[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=ib(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 QD={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`,TriangleStrip:`triangle-strip`},$D={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},eO={Store:`store`},tO={Load:`load`,Clear:`clear`},nO={CCW:`ccw`},rO={None:`none`,Front:`front`,Back:`back`},iO={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`},aO={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},oO={Linear:`linear`,Nearest:`nearest`},sO={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`},cO={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},lO={None:0,All:15},uO={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},dO={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},fO={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},pO={NonFiltering:`non-filtering`,Comparison:`comparison`},mO={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},hO={TwoD:`2d`,ThreeD:`3d`},gO={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},_O={All:`all`},vO={Vertex:`vertex`,Instance:`instance`},yO={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 bO=class extends aD{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}},xO=class extends bO{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}},SO=class extends sD{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}};let CO=0;var wO=class extends SO{constructor(e,t){super(`StorageBuffer_`+ CO++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:sc.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}},TO=class extends Jy{constructor(e){super(),this.device=e;let t=`
|
|
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(KD).filter(t=>KD[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=cb(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 QD={PointList:`point-list`,LineList:`line-list`,LineStrip:`line-strip`,TriangleList:`triangle-list`,TriangleStrip:`triangle-strip`},$D={Never:`never`,Less:`less`,Equal:`equal`,LessEqual:`less-equal`,Greater:`greater`,NotEqual:`not-equal`,GreaterEqual:`greater-equal`,Always:`always`},eO={Store:`store`},tO={Load:`load`,Clear:`clear`},nO={CCW:`ccw`},rO={None:`none`,Front:`front`,Back:`back`},iO={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`},aO={ClampToEdge:`clamp-to-edge`,Repeat:`repeat`,MirrorRepeat:`mirror-repeat`},oO={Linear:`linear`,Nearest:`nearest`},sO={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`},cO={Add:`add`,Subtract:`subtract`,ReverseSubtract:`reverse-subtract`,Min:`min`,Max:`max`},lO={None:0,All:15},uO={Keep:`keep`,Zero:`zero`,Replace:`replace`,Invert:`invert`,IncrementClamp:`increment-clamp`,DecrementClamp:`decrement-clamp`,IncrementWrap:`increment-wrap`,DecrementWrap:`decrement-wrap`},dO={Storage:`storage`,ReadOnlyStorage:`read-only-storage`},fO={WriteOnly:`write-only`,ReadOnly:`read-only`,ReadWrite:`read-write`},pO={NonFiltering:`non-filtering`,Comparison:`comparison`},mO={Float:`float`,UnfilterableFloat:`unfilterable-float`,Depth:`depth`,SInt:`sint`,UInt:`uint`},hO={TwoD:`2d`,ThreeD:`3d`},gO={TwoD:`2d`,TwoDArray:`2d-array`,Cube:`cube`,ThreeD:`3d`},_O={All:`all`},vO={Vertex:`vertex`,Instance:`instance`},yO={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 bO=class extends aD{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}},xO=class extends bO{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}},SO=class extends sD{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}};let CO=0;var wO=class extends SO{constructor(e,t){super(`StorageBuffer_`+ CO++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:cc.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}},TO=class extends Qy{constructor(e){super(),this.device=e;let t=`
|
|
194
194
|
struct VarysStruct {
|
|
195
195
|
@builtin( position ) Position: vec4<f32>,
|
|
196
196
|
@location( 0 ) vTex : vec2<f32>
|
|
@@ -247,7 +247,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
247
247
|
return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
|
|
248
248
|
|
|
249
249
|
}
|
|
250
|
-
`;this.mipmapSampler=e.createSampler({minFilter:oO.Linear}),this.flipYSampler=e.createSampler({minFilter:oO.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:QD.TriangleStrip,stripIndexFormat:iO.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:QD.TriangleStrip,stripIndexFormat:iO.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:gO.TwoD,baseArrayLayer:n}),u=c.createView({baseMipLevel:0,mipLevelCount:1,dimension:gO.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:tO.Clear,storeOp:eO.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:gO.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:gO.TwoD,baseArrayLayer:n}),u={colorAttachments:[{view:l,loadOp:tO.Clear,storeOp:eO.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 EO={[Pn]:`never`,[Fn]:`less`,[In]:`equal`,[Ln]:`less-equal`,[Rn]:`greater`,[Bn]:`greater-equal`,[Vn]:`always`,[zn]:`not-equal`},DO=[0,1,3,2,4,5];var OO=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===oO.Linear&&i.minFilter===oO.Linear&&i.mipmapFilter===oO.Linear&&(i.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(i.compare=EO[e.compareFunction]),r.sampler=n.createSampler(i)}createDefaultTexture(e){let t,n=kO(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||kO(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=gO.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?DO[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 TO(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=aO.ClampToEdge;return e===Ze?t=aO.Repeat:e===$e&&(t=aO.MirrorRepeat),t}_convertFilterMode(e){let t=oO.Linear;return(e===et||e===tt||e===nt)&&(t=oO.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?hO.ThreeD:hO.TwoD,t}};function kO(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(yO.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 AO=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,jO=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,MO={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`},NO=e=>{e=e.trim();let t=e.match(AO);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=jO.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=MO[i]),a.push(new aE(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1],l=MO[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 PO=class extends yE{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=NO(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}},FO=class extends vE{parseFunction(e){return new PO(e)}};const IO=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},LO={[sc.READ_ONLY]:`read`,[sc.WRITE_ONLY]:`write`,[sc.READ_WRITE]:`read_write`},RO={[Ze]:`repeat`,[Qe]:`clamp`,[$e]:`mirror`},zO={vertex:IO?IO.VERTEX:1,fragment:IO?IO.FRAGMENT:2,compute:IO?IO.COMPUTE:4},BO={instance:!0,swizzleAssign:!1,storageBuffer:!0},VO={"^^":`tsl_xor`},HO={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>`},UO={},WO={tsl_xor:new Fx(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new Fx(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new Fx(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new Fx(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new Fx(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new Fx(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new Fx(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new Fx(`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 Fx(`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 Fx(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new Fx(`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 Fx(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new Fx(`
|
|
250
|
+
`;this.mipmapSampler=e.createSampler({minFilter:oO.Linear}),this.flipYSampler=e.createSampler({minFilter:oO.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:QD.TriangleStrip,stripIndexFormat:iO.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:QD.TriangleStrip,stripIndexFormat:iO.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:gO.TwoD,baseArrayLayer:n}),u=c.createView({baseMipLevel:0,mipLevelCount:1,dimension:gO.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:tO.Clear,storeOp:eO.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:gO.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:gO.TwoD,baseArrayLayer:n}),u={colorAttachments:[{view:l,loadOp:tO.Clear,storeOp:eO.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 EO={[Fn]:`never`,[In]:`less`,[Ln]:`equal`,[Rn]:`less-equal`,[zn]:`greater`,[Vn]:`greater-equal`,[Hn]:`always`,[Bn]:`not-equal`},DO=[0,1,3,2,4,5];var OO=class{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new Eo,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===oO.Linear&&i.minFilter===oO.Linear&&i.mipmapFilter===oO.Linear&&(i.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(i.compare=EO[e.compareFunction]),r.sampler=n.createSampler(i)}createDefaultTexture(e){let t,n=kO(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||kO(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=gO.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 Pr;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 eo;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?DO[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 TO(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=aO.ClampToEdge;return e===Ze?t=aO.Repeat:e===$e&&(t=aO.MirrorRepeat),t}_convertFilterMode(e){let t=oO.Linear;return(e===et||e===tt||e===nt)&&(t=oO.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?hO.ThreeD:hO.TwoD,t}};function kO(e,t=null){let n=e.format,r=e.type,i=e.colorSpace,a=wr.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(yO.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 AO=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,jO=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,MO={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`},NO=e=>{e=e.trim();let t=e.match(AO);if(t!==null&&t.length===4){let n=t[2],r=[],i=null;for(;(i=jO.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=MO[i]),a.push(new aE(i,t))}let o=e.substring(t[0].length),s=t[3]||`void`,c=t[1]===void 0?``:t[1],l=MO[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 PO=class extends yE{constructor(e){let{type:t,inputs:n,name:r,inputsCode:i,blockCode:a,outputType:o}=NO(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}},FO=class extends vE{parseFunction(e){return new PO(e)}};const IO=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},LO={[cc.READ_ONLY]:`read`,[cc.WRITE_ONLY]:`write`,[cc.READ_WRITE]:`read_write`},RO={[Ze]:`repeat`,[Qe]:`clamp`,[$e]:`mirror`},zO={vertex:IO?IO.VERTEX:1,fragment:IO?IO.FRAGMENT:2,compute:IO?IO.COMPUTE:4},BO={instance:!0,swizzleAssign:!1,storageBuffer:!0},VO={"^^":`tsl_xor`},HO={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>`},UO={},WO={tsl_xor:new Lx(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new Lx(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new Lx(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new Lx(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new Lx(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new Lx(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new Lx(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new Lx(`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 Lx(`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 Lx(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new Lx(`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 Lx(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new Lx(`
|
|
251
251
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
252
252
|
|
|
253
253
|
let res = vec2f( iRes );
|
|
@@ -269,14 +269,14 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
269
269
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
270
270
|
|
|
271
271
|
}
|
|
272
|
-
`)},GO={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)&&(WO.pow_float=new
|
|
272
|
+
`)},GO={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)&&(WO.pow_float=new Lx(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),WO.pow_vec2=new Lx(`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 ) ); }`,[WO.pow_float]),WO.pow_vec3=new Lx(`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 ) ); }`,[WO.pow_float]),WO.pow_vec4=new Lx(`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 ) ); }`,[WO.pow_float]),GO.pow_float=`tsl_pow_float`,GO.pow_vec2=`tsl_pow_vec2`,GO.pow_vec3=`tsl_pow_vec3`,GO.pow_vec4=`tsl_pow_vec4`);let KO=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(KO+=`diagnostic( off, derivative_uniformity );
|
|
273
273
|
`);var qO=class extends rE{constructor(e,t){super(e,t,new FO),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_${RO[e.wrapS]}S_${RO[e.wrapT]}_${e.isData3DTexture?`3d`:`2d`}T`,n=UO[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(WO.repeatWrapping_float),a+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===Qe?(r.push(WO.clampWrapping_float),a+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===$e?(r.push(WO.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
274
|
`,o(e.wrapT,`y`),e.isData3DTexture&&(a+=`,
|
|
275
275
|
`,o(e.wrapR,`z`)),a+=`
|
|
276
276
|
);
|
|
277
277
|
|
|
278
278
|
}
|
|
279
|
-
`,UO[t]=n=new
|
|
279
|
+
`,UO[t]=n=new Lx(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 ff(new Zf(`textureDimensions( ${a} )`,o)),r.dimensionsSnippet[n]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new ff(new Zf(`textureNumLayers(${t})`,`u32`))),e.isTextureCube&&(r.cubeFaceCount=new ff(new Zf(`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=VO[e];return t===void 0?null:(this._include(t),t)}getNodeAccess(e,t){return t===`compute`?e.access:cc.READ_ONLY}getStorageAccess(e,t){return LO[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 vD(i.name,i.node,s,a):t===`cubeTexture`?r=new yD(i.name,i.node,s,a):t===`texture3D`&&(r=new bD(i.name,i.node,s,a)),r.store=e.isStorageTextureNode===!0,r.setVisibility(zO[n]),this.isUnfilterable(e.value)===!1&&r.store===!1){let e=new xO(`${i.name}_sampler`,i.node,s);e.setVisibility(zO[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`?uD:wO,c=new a(e,s);c.setVisibility(zO[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 hD(c,s),r.setVisibility(zO[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
280
|
${n.vars}
|
|
281
281
|
${n.code}
|
|
282
282
|
`;return n.result&&(i+=`\treturn ${n.result};\n`),i+=`
|
|
@@ -393,7 +393,7 @@ struct ${e} {
|
|
|
393
393
|
${t}
|
|
394
394
|
};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`,o=this._getWGSLStruct(a,t);return`${o}
|
|
395
395
|
@binding( ${r} ) @group( ${i} )
|
|
396
|
-
var<${n}> ${e} : ${a};`}},JO=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 QD.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return QD.LineList;if(e.isLine)return QD.LineStrip;if(e.isMesh)return QD.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 YO=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),XO=new Map([[ha,[`float16`]]]),ZO=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var QO=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?vO.Instance:vO.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?vO.Instance:vO.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=ZO.get(r);else{let e=XO.get(i)||YO.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}},$O=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=dO.Storage:t.type=dO.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=pO.NonFiltering):r.type=pO.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=fO.ReadWrite:r===sc.WRITE_ONLY?t.access=fO.WriteOnly:t.access=fO.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=mO.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=mO.UnfilterableFloat:r.sampleType=mO.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=mO.SInt:e===ft?r.sampleType=mO.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=mO.Float:r.sampleType=mO.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=gO.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=gO.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=gO.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=_O.All,a;a=t.isSampledCubeTexture?gO.Cube:t.isSampledTexture3D?gO.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?gO.TwoDArray:gO.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})}},ek=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:cO.Add},n={srcFactor:i,dstFactor:a,operation:cO.Add}};if(i)switch(r){case oe:a(sO.One,sO.OneMinusSrcAlpha,sO.One,sO.OneMinusSrcAlpha);break;case se:a(sO.One,sO.One,sO.One,sO.One);break;case ce:a(sO.Zero,sO.OneMinusSrc,sO.Zero,sO.One);break;case le:a(sO.Zero,sO.Src,sO.Zero,sO.SrcAlpha);break}else switch(r){case oe:a(sO.SrcAlpha,sO.OneMinusSrcAlpha,sO.One,sO.OneMinusSrcAlpha);break;case se:a(sO.SrcAlpha,sO.One,sO.SrcAlpha,sO.One);break;case ce:a(sO.Zero,sO.OneMinusSrc,sO.Zero,sO.One);break;case le:a(sO.Zero,sO.Src,sO.Zero,sO.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=sO.Zero;break;case _e:t=sO.One;break;case ve:t=sO.Src;break;case ye:t=sO.OneMinusSrc;break;case be:t=sO.SrcAlpha;break;case xe:t=sO.OneMinusSrcAlpha;break;case we:t=sO.Dst;break;case Te:t=sO.OneMinusDst;break;case Se:t=sO.DstAlpha;break;case Ce:t=sO.OneMinusDstAlpha;break;case Ee:t=sO.SrcAlphaSaturated;break;case lte:t=sO.Constant;break;case ute:t=sO.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=$D.Never;break;case Nn:t=$D.Always;break;case Dn:t=$D.Less;break;case kn:t=$D.LessEqual;break;case On:t=$D.Equal;break;case Mn:t=$D.GreaterEqual;break;case An:t=$D.Greater;break;case jn:t=$D.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bn:t=uO.Keep;break;case yn:t=uO.Zero;break;case xn:t=uO.Replace;break;case Tn:t=uO.Invert;break;case Sn:t=uO.IncrementClamp;break;case Cn:t=uO.DecrementClamp;break;case wn:t=uO.IncrementWrap;break;case tee:t=uO.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=cO.Add;break;case fe:t=cO.Subtract;break;case pe:t=cO.ReverseSubtract;break;case me:t=cO.Min;break;case he:t=cO.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?iO.Uint16:iO.Uint32),n.side){case ne:r.frontFace=nO.CCW,r.cullMode=rO.Back;break;case re:r.frontFace=nO.CCW,r.cullMode=rO.Front;break;case ie:r.frontFace=nO.CCW,r.cullMode=rO.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?lO.All:lO.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=$D.Always;else{let n=e.depthFunc;switch(n){case De:t=$D.Never;break;case Oe:t=$D.Always;break;case ke:t=$D.Less;break;case Ae:t=$D.LessEqual;break;case je:t=$D.Equal;break;case Me:t=$D.GreaterEqual;break;case Ne:t=$D.Greater;break;case Pe:t=$D.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},tk=class extends JD{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}}},nk=class extends AD{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 JO(this),this.attributeUtils=new QO(this),this.bindingUtils=new $O(this),this.pipelineUtils=new ek(this),this.textureUtils=new OO(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(yO),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(yO.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:gO.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=gO.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:gO.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=gO.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=gO.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||tO.Load,storeOp:t.storeOp||eO.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:tO.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=tO.Clear):r.loadOp=tO.Load,r.storeOp=eO.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=tO.Clear):t.loadOp=tO.Load,t.storeOp=eO.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=tO.Clear):o.depthLoadOp=tO.Load,o.depthStoreOp=eO.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=tO.Clear):o.stencilLoadOp=tO.Load,o.stencilStoreOp=eO.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:gO.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||tO.Clear,depthStoreOp:i.depthStoreOp||eO.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=tO.Clear):t.depthLoadOp=tO.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=tO.Clear):t.stencilLoadOp=tO.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=tO.Clear,e.storeOp=eO.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?tO.Clear:tO.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?tO.Clear:tO.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=eO.Store),u&&(i.stencilLoadOp=n?tO.Clear:tO.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=eO.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=tO.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=eO.Store):(s.depthLoadOp=tO.Load,s.depthStoreOp=eO.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=tO.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=eO.Store):(s.stencilLoadOp=tO.Load,s.stencilStoreOp=eO.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?iO.Uint16:iO.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 tk(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 qO(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=tO.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=tO.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=tO.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)}},rk=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}},ik=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}},ak=class extends FE{constructor(){super(),this.addMaterial(ov,`MeshPhongMaterial`),this.addMaterial(Hy,`MeshStandardMaterial`),this.addMaterial(Bee,`MeshPhysicalMaterial`),this.addMaterial(Wee,`MeshToonMaterial`),this.addMaterial(X_,`MeshBasicMaterial`),this.addMaterial(iv,`MeshLambertMaterial`),this.addMaterial(F_,`MeshNormalMaterial`),this.addMaterial(qee,`MeshMatcapMaterial`),this.addMaterial(E_,`LineBasicMaterial`),this.addMaterial(O_,`LineDashedMaterial`),this.addMaterial(Zee,`PointsMaterial`),this.addMaterial(Gy,`SpriteMaterial`),this.addMaterial(ete,`ShadowMaterial`),this.addLight(FC,hs),this.addLight(oE,vs),this.addLight(uE,bs),this.addLight(dE,us),this.addLight(hE,ys),this.addLight(gE,ns),this.addLight(_E,Ss),this.addLight(fE,rk),this.addLight(mE,ik),this.addToneMapping(Tx,ze),this.addToneMapping(Ex,Be),this.addToneMapping(Dx,Ve),this.addToneMapping(kx,He),this.addToneMapping(Nx,Ue),this.addToneMapping(Px,We)}},ok=class extends iD{constructor(e={}){let t;e.forceWebGL?t=ZD:(t=nk,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new ZD(e)));let n=new t(e);super(n,e),this.library=new ak,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},sk={};_(sk,{BRDF_GGX:()=>ck,BRDF_Lambert:()=>lk,BasicShadowFilter:()=>uk,Break:()=>dk,Const:()=>yj,Continue:()=>fk,DFGApprox:()=>pk,D_GGX:()=>mk,Discard:()=>hk,EPSILON:()=>gk,F_Schlick:()=>_k,Fn:()=>vk,INFINITY:()=>yk,If:()=>bk,Loop:()=>Sk,NodeAccess:()=>Ek,NodeShaderStage:()=>Ck,NodeType:()=>wk,NodeUpdateType:()=>Tk,PCFShadowFilter:()=>Dk,PCFSoftShadowFilter:()=>Ok,PI:()=>kk,PI2:()=>Ak,Return:()=>jk,Schlick_to_F0:()=>Mk,ScriptableNodeResources:()=>Nk,ShaderNode:()=>Pk,Switch:()=>xk,TBNViewMatrix:()=>Fk,VSMShadowFilter:()=>Ik,V_GGX_SmithCorrelated:()=>Lk,Var:()=>mF,abs:()=>Rk,acesFilmicToneMapping:()=>zk,acos:()=>Bk,add:()=>Vk,addNodeElement:()=>Hk,agxToneMapping:()=>Uk,all:()=>Wk,alphaT:()=>Gk,and:()=>Kk,anisotropy:()=>qk,anisotropyB:()=>Jk,anisotropyT:()=>Yk,any:()=>Xk,append:()=>Zk,array:()=>Qk,arrayBuffer:()=>$k,asin:()=>eA,assign:()=>tA,atan:()=>nA,atan2:()=>rA,atomicAdd:()=>iA,atomicAnd:()=>aA,atomicFunc:()=>oA,atomicLoad:()=>pA,atomicMax:()=>sA,atomicMin:()=>cA,atomicOr:()=>lA,atomicStore:()=>uA,atomicSub:()=>dA,atomicXor:()=>fA,attenuationColor:()=>mA,attenuationDistance:()=>hA,attribute:()=>gA,attributeArray:()=>_A,backgroundBlurriness:()=>vA,backgroundIntensity:()=>yA,backgroundRotation:()=>bA,batch:()=>xA,billboarding:()=>SA,bitAnd:()=>CA,bitNot:()=>wA,bitOr:()=>TA,bitXor:()=>EA,bitangentGeometry:()=>DA,bitangentLocal:()=>OA,bitangentView:()=>kA,bitangentWorld:()=>AA,bitcast:()=>jA,blendBurn:()=>MA,blendColor:()=>NA,blendDodge:()=>PA,blendOverlay:()=>FA,blendScreen:()=>IA,blur:()=>LA,bool:()=>RA,buffer:()=>zA,bufferAttribute:()=>BA,bumpMap:()=>VA,burn:()=>HA,bvec2:()=>UA,bvec3:()=>WA,bvec4:()=>GA,bypass:()=>KA,cache:()=>qA,call:()=>JA,cameraFar:()=>YA,cameraIndex:()=>XA,cameraNear:()=>ZA,cameraNormalMatrix:()=>QA,cameraPosition:()=>$A,cameraProjectionMatrix:()=>ej,cameraProjectionMatrixInverse:()=>tj,cameraViewMatrix:()=>nj,cameraWorldMatrix:()=>rj,cbrt:()=>ij,cdl:()=>aj,ceil:()=>oj,checker:()=>sj,cineonToneMapping:()=>cj,clamp:()=>lj,clearcoat:()=>uj,clearcoatRoughness:()=>dj,code:()=>fj,color:()=>pj,colorSpaceToWorking:()=>mj,colorToDirection:()=>hj,compute:()=>gj,computeSkinning:()=>_j,cond:()=>vj,context:()=>bj,convert:()=>xj,convertColorSpace:()=>Sj,convertToTexture:()=>Cj,cos:()=>wj,cross:()=>Tj,cubeTexture:()=>Ej,dFdx:()=>Dj,dFdy:()=>Oj,dashSize:()=>kj,debug:()=>Aj,decrement:()=>jj,decrementBefore:()=>Mj,defaultBuildStages:()=>Nj,defaultShaderStages:()=>Pj,defined:()=>Fj,degrees:()=>Ij,deltaTime:()=>Lj,densityFog:()=>Rj,densityFogFactor:()=>zj,depth:()=>Bj,depthPass:()=>Vj,difference:()=>Hj,diffuseColor:()=>Uj,directPointLight:()=>Wj,directionToColor:()=>Gj,dispersion:()=>Kj,distance:()=>qj,div:()=>Jj,dodge:()=>Yj,dot:()=>Xj,drawIndex:()=>Zj,dynamicBufferAttribute:()=>Qj,element:()=>$j,emissive:()=>eM,equal:()=>tM,equals:()=>nM,equirectUV:()=>rM,exp:()=>iM,exp2:()=>aM,expression:()=>oM,faceDirection:()=>sM,faceForward:()=>cM,faceforward:()=>lM,float:()=>uM,floor:()=>dM,fog:()=>fM,fract:()=>pM,frameGroup:()=>mM,frameId:()=>hM,frontFacing:()=>gM,fwidth:()=>_M,gain:()=>vM,gapSize:()=>yM,getConstNodeType:()=>bM,getCurrentStack:()=>xM,getDirection:()=>SM,getDistanceAttenuation:()=>CM,getGeometryRoughness:()=>wM,getNormalFromDepth:()=>TM,getParallaxCorrectNormal:()=>EM,getRoughness:()=>DM,getScreenPosition:()=>OM,getShIrradianceAt:()=>kM,getShadowMaterial:()=>One,getShadowRenderObjectFunction:()=>kne,getTextureIndex:()=>AM,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:()=>$M,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:()=>LN,pointUV:()=>Yae,pointWidth:()=>Xae,positionGeometry:()=>Zae,positionLocal:()=>PM,positionPrevious:()=>FM,positionView:()=>IM,positionViewDirection:()=>LM,positionWorld:()=>RM,positionWorldDirection:()=>zM,posterize:()=>BM,pow:()=>VM,pow2:()=>HM,pow3:()=>UM,pow4:()=>WM,premult:()=>GM,property:()=>KM,radians:()=>qM,rand:()=>JM,range:()=>YM,rangeFog:()=>XM,rangeFogFactor:()=>ZM,reciprocal:()=>QM,reference:()=>eN,referenceBuffer:()=>tN,reflect:()=>nN,reflectVector:()=>rN,reflectView:()=>iN,reflector:()=>aN,refract:()=>oN,refractVector:()=>sN,refractView:()=>cN,reinhardToneMapping:()=>lN,remainder:()=>uN,remap:()=>dN,remapClamp:()=>fN,renderGroup:()=>pN,renderOutput:()=>mN,rendererReference:()=>hN,rotate:()=>gN,rotateUV:()=>_N,roughness:()=>vN,round:()=>yN,rtt:()=>bN,sRGBTransferEOTF:()=>xN,sRGBTransferOETF:()=>SN,sampler:()=>CN,samplerComparison:()=>wN,saturate:()=>TN,saturation:()=>EN,screen:()=>DN,screenCoordinate:()=>ON,screenSize:()=>kN,screenUV:()=>AN,scriptable:()=>jN,scriptableValue:()=>MN,select:()=>NN,setCurrentStack:()=>PN,shaderStages:()=>FN,shadow:()=>IN,shadowPositionWorld:()=>RN,shapeCircle:()=>BN,sharedUniformGroup:()=>zN,sheen:()=>VN,sheenRoughness:()=>HN,shiftLeft:()=>UN,shiftRight:()=>WN,shininess:()=>GN,sign:()=>KN,sin:()=>qN,sinc:()=>JN,skinning:()=>YN,smoothstep:()=>XN,smoothstepElement:()=>ZN,specularColor:()=>QN,specularF90:()=>$N,spherizeUV:()=>eP,split:()=>tP,spritesheetUV:()=>nP,sqrt:()=>rP,stack:()=>iP,step:()=>aP,storage:()=>oP,storageBarrier:()=>sP,storageObject:()=>cP,storageTexture:()=>lP,string:()=>uP,struct:()=>dP,sub:()=>fP,subgroupIndex:()=>pP,subgroupSize:()=>mP,tan:()=>hP,tangentGeometry:()=>gP,tangentLocal:()=>_P,tangentView:()=>vP,tangentWorld:()=>yP,temp:()=>bP,texture:()=>xP,texture3D:()=>SP,textureBarrier:()=>CP,textureBicubic:()=>wP,textureCubeUV:()=>TP,textureLoad:()=>EP,textureSize:()=>DP,textureStore:()=>OP,thickness:()=>kP,time:()=>AP,timerDelta:()=>jP,timerGlobal:()=>MP,timerLocal:()=>NP,toneMapping:()=>PP,toneMappingExposure:()=>FP,toonOutlinePass:()=>IP,transformDirection:()=>LP,transformNormal:()=>RP,transformNormalToView:()=>zP,transformedBentNormalView:()=>BP,transformedBitangentView:()=>VP,transformedBitangentWorld:()=>HP,transformedClearcoatNormalView:()=>UP,transformedNormalView:()=>WP,transformedNormalWorld:()=>GP,transformedTangentView:()=>KP,transformedTangentWorld:()=>qP,transmission:()=>JP,transpose:()=>YP,triNoise3D:()=>XP,triplanarTexture:()=>ZP,triplanarTextures:()=>QP,trunc:()=>$P,tslFn:()=>eF,uint:()=>tF,uniform:()=>nF,uniformArray:()=>iF,uniformCubeTexture:()=>rF,uniformGroup:()=>aF,uniformTexture:()=>oF,uniforms:()=>sF,unpremult:()=>cF,userData:()=>lF,uv:()=>uF,uvec2:()=>dF,uvec3:()=>fF,uvec4:()=>pF,varying:()=>hF,varyingProperty:()=>gF,vec2:()=>_F,vec3:()=>vF,vec4:()=>yF,vectorComponents:()=>bF,velocity:()=>xF,vertexColor:()=>SF,vertexIndex:()=>CF,vibrance:()=>wF,viewZToLogarithmicDepth:()=>TF,viewZToOrthographicDepth:()=>EF,viewZToPerspectiveDepth:()=>DF,viewport:()=>OF,viewportBottomLeft:()=>kF,viewportCoordinate:()=>AF,viewportDepthTexture:()=>jF,viewportLinearDepth:()=>MF,viewportMipTexture:()=>NF,viewportResolution:()=>PF,viewportSafeUV:()=>Qae,viewportSharedTexture:()=>FF,viewportSize:()=>IF,viewportTexture:()=>LF,viewportTopLeft:()=>RF,viewportUV:()=>zF,wgsl:()=>BF,wgslFn:()=>VF,workgroupArray:()=>HF,workgroupBarrier:()=>UF,workgroupId:()=>WF,workingToColorSpace:()=>GF,xor:()=>KF});const ck=I.BRDF_GGX,lk=I.BRDF_Lambert,uk=I.BasicShadowFilter,dk=I.Break,fk=I.Continue,pk=I.DFGApprox,mk=I.D_GGX,hk=I.Discard,gk=I.EPSILON,_k=I.F_Schlick,vk=I.Fn,yk=I.INFINITY,bk=I.If,xk=I.Switch,Sk=I.Loop,Ck=I.NodeShaderStage,wk=I.NodeType,Tk=I.NodeUpdateType,Ek=I.NodeAccess,Dk=I.PCFShadowFilter,Ok=I.PCFSoftShadowFilter,kk=I.PI,Ak=I.PI2,jk=I.Return,Mk=I.Schlick_to_F0,Nk=I.ScriptableNodeResources,Pk=I.ShaderNode,Fk=I.TBNViewMatrix,Ik=I.VSMShadowFilter,Lk=I.V_GGX_SmithCorrelated,Rk=I.abs,zk=I.acesFilmicToneMapping,Bk=I.acos,Vk=I.add,Hk=I.addNodeElement,Uk=I.agxToneMapping,Wk=I.all,Gk=I.alphaT,Kk=I.and,qk=I.anisotropy,Jk=I.anisotropyB,Yk=I.anisotropyT,Xk=I.any,Zk=I.append,Qk=I.array,$k=I.arrayBuffer,eA=I.asin,tA=I.assign,nA=I.atan,rA=I.atan2,iA=I.atomicAdd,aA=I.atomicAnd,oA=I.atomicFunc,sA=I.atomicMax,cA=I.atomicMin,lA=I.atomicOr,uA=I.atomicStore,dA=I.atomicSub,fA=I.atomicXor,pA=I.atomicLoad,mA=I.attenuationColor,hA=I.attenuationDistance,gA=I.attribute,_A=I.attributeArray,vA=I.backgroundBlurriness,yA=I.backgroundIntensity,bA=I.backgroundRotation,xA=I.batch,SA=I.billboarding,CA=I.bitAnd,wA=I.bitNot,TA=I.bitOr,EA=I.bitXor,DA=I.bitangentGeometry,OA=I.bitangentLocal,kA=I.bitangentView,AA=I.bitangentWorld,jA=I.bitcast,MA=I.blendBurn,NA=I.blendColor,PA=I.blendDodge,FA=I.blendOverlay,IA=I.blendScreen,LA=I.blur,RA=I.bool,zA=I.buffer,BA=I.bufferAttribute,VA=I.bumpMap,HA=I.burn,UA=I.bvec2,WA=I.bvec3,GA=I.bvec4,KA=I.bypass,qA=I.cache,JA=I.call,YA=I.cameraFar,XA=I.cameraIndex,ZA=I.cameraNear,QA=I.cameraNormalMatrix,$A=I.cameraPosition,ej=I.cameraProjectionMatrix,tj=I.cameraProjectionMatrixInverse,nj=I.cameraViewMatrix,rj=I.cameraWorldMatrix,ij=I.cbrt,aj=I.cdl,oj=I.ceil,sj=I.checker,cj=I.cineonToneMapping,lj=I.clamp,uj=I.clearcoat,dj=I.clearcoatRoughness,fj=I.code,pj=I.color,mj=I.colorSpaceToWorking,hj=I.colorToDirection,gj=I.compute,_j=I.computeSkinning,vj=I.cond,yj=I.Const,bj=I.context,xj=I.convert,Sj=I.convertColorSpace,Cj=I.convertToTexture,wj=I.cos,Tj=I.cross,Ej=I.cubeTexture,Dj=I.dFdx,Oj=I.dFdy,kj=I.dashSize,Aj=I.debug,jj=I.decrement,Mj=I.decrementBefore,Nj=I.defaultBuildStages,Pj=I.defaultShaderStages,Fj=I.defined,Ij=I.degrees,Lj=I.deltaTime,Rj=I.densityFog,zj=I.densityFogFactor,Bj=I.depth,Vj=I.depthPass,Hj=I.difference,Uj=I.diffuseColor,Wj=I.directPointLight,Gj=I.directionToColor,Kj=I.dispersion,qj=I.distance,Jj=I.div,Yj=I.dodge,Xj=I.dot,Zj=I.drawIndex,Qj=I.dynamicBufferAttribute,$j=I.element,eM=I.emissive,tM=I.equal,nM=I.equals,rM=I.equirectUV,iM=I.exp,aM=I.exp2,oM=I.expression,sM=I.faceDirection,cM=I.faceForward,lM=I.faceforward,uM=I.float,dM=I.floor,fM=I.fog,pM=I.fract,mM=I.frameGroup,hM=I.frameId,gM=I.frontFacing,_M=I.fwidth,vM=I.gain,yM=I.gapSize,bM=I.getConstNodeType,xM=I.getCurrentStack,SM=I.getDirection,CM=I.getDistanceAttenuation,wM=I.getGeometryRoughness,TM=I.getNormalFromDepth,EM=I.getParallaxCorrectNormal,DM=I.getRoughness,OM=I.getScreenPosition,kM=I.getShIrradianceAt,AM=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,Yae=I.pointUV,Xae=I.pointWidth,Zae=I.positionGeometry,PM=I.positionLocal,FM=I.positionPrevious,IM=I.positionView,LM=I.positionViewDirection,RM=I.positionWorld,zM=I.positionWorldDirection,BM=I.posterize,VM=I.pow,HM=I.pow2,UM=I.pow3,WM=I.pow4,GM=I.premult,KM=I.property,qM=I.radians,JM=I.rand,YM=I.range,XM=I.rangeFog,ZM=I.rangeFogFactor,QM=I.reciprocal,$M=I.lightProjectionUV,eN=I.reference,tN=I.referenceBuffer,nN=I.reflect,rN=I.reflectVector,iN=I.reflectView,aN=I.reflector,oN=I.refract,sN=I.refractVector,cN=I.refractView,lN=I.reinhardToneMapping,uN=I.remainder,dN=I.remap,fN=I.remapClamp,pN=I.renderGroup,mN=I.renderOutput,hN=I.rendererReference,gN=I.rotate,_N=I.rotateUV,vN=I.roughness,yN=I.round,bN=I.rtt,xN=I.sRGBTransferEOTF,SN=I.sRGBTransferOETF,CN=I.sampler,wN=I.samplerComparison,TN=I.saturate,EN=I.saturation,DN=I.screen,ON=I.screenCoordinate,kN=I.screenSize,AN=I.screenUV,jN=I.scriptable,MN=I.scriptableValue,NN=I.select,PN=I.setCurrentStack,FN=I.shaderStages,IN=I.shadow,LN=I.pointShadow,RN=I.shadowPositionWorld,zN=I.sharedUniformGroup,BN=I.shapeCircle,VN=I.sheen,HN=I.sheenRoughness,UN=I.shiftLeft,WN=I.shiftRight,GN=I.shininess,KN=I.sign,qN=I.sin,JN=I.sinc,YN=I.skinning,XN=I.smoothstep,ZN=I.smoothstepElement,QN=I.specularColor,$N=I.specularF90,eP=I.spherizeUV,tP=I.split,nP=I.spritesheetUV,rP=I.sqrt,iP=I.stack,aP=I.step,oP=I.storage,sP=I.storageBarrier,cP=I.storageObject,lP=I.storageTexture,uP=I.string,dP=I.struct,fP=I.sub,pP=I.subgroupIndex,mP=I.subgroupSize,hP=I.tan,gP=I.tangentGeometry,_P=I.tangentLocal,vP=I.tangentView,yP=I.tangentWorld,bP=I.temp,xP=I.texture,SP=I.texture3D,CP=I.textureBarrier,wP=I.textureBicubic,TP=I.textureCubeUV,EP=I.textureLoad,DP=I.textureSize,OP=I.textureStore,kP=I.thickness,AP=I.time,jP=I.timerDelta,MP=I.timerGlobal,NP=I.timerLocal,PP=I.toneMapping,FP=I.toneMappingExposure,IP=I.toonOutlinePass,LP=I.transformDirection,RP=I.transformNormal,zP=I.transformNormalToView,BP=I.transformedBentNormalView,VP=I.transformedBitangentView,HP=I.transformedBitangentWorld,UP=I.transformedClearcoatNormalView,WP=I.transformedNormalView,GP=I.transformedNormalWorld,KP=I.transformedTangentView,qP=I.transformedTangentWorld,JP=I.transmission,YP=I.transpose,XP=I.triNoise3D,ZP=I.triplanarTexture,QP=I.triplanarTextures,$P=I.trunc,eF=I.tslFn,tF=I.uint,nF=I.uniform,rF=I.uniformCubeTexture,iF=I.uniformArray,aF=I.uniformGroup,oF=I.uniformTexture,sF=I.uniforms,cF=I.unpremult,lF=I.userData,uF=I.uv,dF=I.uvec2,fF=I.uvec3,pF=I.uvec4,mF=I.Var,hF=I.varying,gF=I.varyingProperty,_F=I.vec2,vF=I.vec3,yF=I.vec4,bF=I.vectorComponents,xF=I.velocity,SF=I.vertexColor,CF=I.vertexIndex,wF=I.vibrance,TF=I.viewZToLogarithmicDepth,EF=I.viewZToOrthographicDepth,DF=I.viewZToPerspectiveDepth,OF=I.viewport,kF=I.viewportBottomLeft,AF=I.viewportCoordinate,jF=I.viewportDepthTexture,MF=I.viewportLinearDepth,NF=I.viewportMipTexture,PF=I.viewportResolution,Qae=I.viewportSafeUV,FF=I.viewportSharedTexture,IF=I.viewportSize,LF=I.viewportTexture,RF=I.viewportTopLeft,zF=I.viewportUV,BF=I.wgsl,VF=I.wgslFn,HF=I.workgroupArray,UF=I.workgroupBarrier,WF=I.workgroupId,GF=I.workingToColorSpace,KF=I.xor;function qF(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 yF(s,c)}function JF(e,t,n=1){let r=NM(t.a,n),i=Vk(r,NM(e.a,fP(1,r))),a=Vk(NM(t.rgb,r),NM(e.rgb,NM(e.a,fP(1,r))));return yF(a,i)}const YF={normal:JF,multiply:qF};function XF(e,t,n=`normal`,r=1){let i=YF[n]||YF.normal;return i(e,t,r)}function ZF(e,t){let n=NM(e.a,t.a);return yF(e.rgb,n)}function QF(e,t){let n=fP(1,t.a),r=NM(e.a,n);return yF(e.rgb,r)}function $F(e,t){let n=vF(.2126,.7152,.0722),r=Xj(t.rgb,n),i=NM(e.a,r);return yF(e.rgb,i)}function eI(e,t){let n=vF(.2126,.7152,.0722),r=Xj(t.rgb,n),i=fP(1,r),a=NM(e.a,i);return yF(e.rgb,a)}const tI={alpha:ZF,alphaInverted:QF,luminance:$F,luminanceInverted:eI};function nI(e,t,n=`alpha`){let r=tI[n]||tI.alpha;return r(e,t)}const rI={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let iI=null,aI=!1;const oI=()=>{try{if(rI!==void 0){let{MODE:e,DEV:t}=rI;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 sI(){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 nI(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 yF(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:iI});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:XF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:iI});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:XF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:iI});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 ok?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(!iI)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=iI.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(iI=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 ok({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 X_({transparent:!0}),a.nodes.size===0?i.fragmentNode=yF(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=()=>{!oI()||aI||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),aI=!0)},Se=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),iI&&(iI.removeEventListener(`mousemove`,ye),iI.removeEventListener(`touchmove`,ye),iI.removeEventListener(`mousedown`,()=>{x=!0}),iI.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)}iI=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:cI}=sk;function lI(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:cI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:uI,fract:dI,sin:fI,dot:pI}=sk,mI=e=>dI(fI(pI(e,uI(12.12345,78.12345))).mul(40000.12345)),$ae=(e=.03)=>t=>mI(t).mul(e).mul(.10012345),{vec2:hI}=sk,eoe=(e=hI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=sk,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)},toe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=sk,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)},noe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=sk,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 gI=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}({}),_I,vI;function yI(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 bI(e){return xI(e)===`string`}function xI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function SI(e,{precision:t,unit:n}){return CI(e)?`none`:TI(e,t)+(n??``)}function CI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function wI(e){return CI(e)?0:e}function TI(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 EI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function DI(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*EI[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 OI(e){return e[e.length-1]}function kI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function AI(e,t,n){return(n-e)/(t-e)}function jI(e,t,n){return kI(t[0],t[1],AI(e[0],e[1],n))}function MI(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 NI(e,t,n){return Math.max(Math.min(n,t),e)}function PI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function FI(e,t){return PI(Math.abs(e)**t,e)}function II(e,t){return t===0?0:e/t}function LI(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 RI=Object.freeze({__proto__:null,bisectLeft:LI,clamp:NI,copySign:PI,interpolate:kI,interpolateInv:AI,isNone:CI,isString:bI,last:OI,mapRange:jI,multiplyMatrices:yI,parseCoordGrammar:MI,parseFunction:DI,serializeNumber:SI,skipNone:wI,spow:FI,toPrecision:TI,type:xI,zdiv:II}),zI=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 BI=new zI;var VI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((_I=globalThis)==null||(_I=_I.process)==null||(_I=_I.env)==null||(_I=_I.NODE_ENV)==null?void 0:_I.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 HI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function UI(e){return Array.isArray(e)?e:HI[e]}function WI(e,t,n,r={}){if(e=UI(e),t=UI(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(BI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===HI.D65&&i.W2===HI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===HI.D50&&i.W2===HI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),BI.run(`chromatic-adaptation-end`,i),i.M)return yI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const GI=new Set([`<number>`,`<percentage>`,`<angle>`]);function KI(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=>GI.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]=jI(u,d,r[a])),l});return i}function qI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(BI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=DI(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 XI.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=KI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&VI.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(`--`)&&VI.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 XI.registry?e:n;if(u in XI.registry){var s;let e=(s=XI.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 XI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||OI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=KI(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 XI.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 JI(e){if(Array.isArray(e))return e.map(JI);if(!e)throw TypeError(`Empty color reference`);bI(e)&&(e=qI(e));let t=e.space||e.spaceId;return t instanceof XI||(e.space=XI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const YI=75e-6;var XI=(vI=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=UI(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:ZI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),BI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=YI}={}){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=QI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=QI(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=JI(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=JI(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=xI(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=xI(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=xI(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(`, `)}`)}},gI.defineProperty(vI,`registry`,{}),gI.defineProperty(vI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),vI);function ZI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function QI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=MI(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=jI(i,a,e)),e=SI(e,{precision:t,unit:o}),e})}return e}var $I=new XI({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`]}),eL=class extends XI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=$I,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=yI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=WI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=WI(this.base.white,this.white,t),yI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function tL(e,t){return e=JI(e),!t||e.space.equals(t)?e.coords.slice():(t=XI.get(t),t.from(e))}function nL(e,t){e=JI(e);let{space:n,index:r}=XI.resolveCoord(t,e.space),i=tL(e,n);return i[r]}function rL(e,t,n){return e=JI(e),t=XI.get(t),e.coords=t.to(e.space,n),e}rL.returns=`color`;function iL(e,t,n){if(e=JI(e),arguments.length===2&&xI(arguments[1])===`object`){let t=arguments[1];for(let n in t)iL(e,n,t[n])}else{typeof n==`function`&&(n=n(nL(e,t)));let{space:r,index:i}=XI.resolveCoord(t,e.space),a=tL(e,r);a[i]=n,rL(e,r,a)}return e}iL.returns=`color`;var aL=new XI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:$I,fromBase:e=>WI($I.white,`D50`,e),toBase:e=>WI(`D50`,$I.white,e)});const oL=216/24389,sL=24/116,cL=24389/27;let lL=HI.D50;var uL=new XI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:lL,base:aL,fromBase(e){let t=e.map((e,t)=>e/lL[t]),n=t.map(e=>e>oL?Math.cbrt(e):(cL*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]>sL?t[0]**3:(116*t[0]-16)/cL,e[0]>8?((e[0]+16)/116)**3:e[0]/cL,t[2]>sL?t[2]**3:(116*t[2]-16)/cL];return n.map((e,t)=>e*lL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function dL(e){return(e%360+360)%360}function fL(e,t){if(e===`raw`)return t;let[n,r]=t.map(dL),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 pL=new XI({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:uL,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),dL(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 mL=25**7,hL=Math.PI,gL=180/hL,_L=hL/180;function vL(e){let t=e*e,n=t*t*t*e;return n}function yL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=JI([e,t]);let[a,o,s]=uL.from(e),c=pL.from(uL,[a,o,s])[1],[l,u,d]=uL.from(t),f=pL.from(uL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=vL(p),h=.5*(1-Math.sqrt(m/(m+mL))),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*hL),x<0&&(x+=2*hL),b*=gL,x*=gL;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:VI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*_L/2),oe=(a+l)/2,se=(v+y)/2,ce=vL(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)*_L),pe+=.24*Math.cos(2*le*_L),pe+=.32*Math.cos((3*le+6)*_L),pe-=.2*Math.cos((4*le-63)*_L);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+mL)),_e=-1*Math.sin(2*he*_L)*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 bL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],xL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],SL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],CL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var wL=new XI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:$I,fromBase(e){let t=yI(bL,e),n=t.map(e=>Math.cbrt(e));return yI(SL,n)},toBase(e){let t=yI(CL,e),n=t.map(e=>e**3);return yI(xL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function TL(e,t){[e,t]=JI([e,t]);let[n,r,i]=wL.from(e),[a,o,s]=wL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const EL=75e-6;function DL(e,t,{epsilon:n=EL}={}){e=JI(e),t||=e.space,t=XI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function OL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function kL(e,t,n=`lab`){n=XI.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 AL(e,t){return kL(e,t,`lab`)}const jL=Math.PI,ML=jL/180;function NL(e,t,{l:n=2,c:r=1}={}){[e,t]=JI([e,t]);let[i,a,o]=uL.from(e),[,s,c]=pL.from(uL,[i,a,o]),[l,u,d]=uL.from(t),f=pL.from(uL,[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)*ML)):.36+Math.abs(.4*Math.cos((c+35)*ML));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 PL=203;var FL=new XI({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:$I,fromBase(e){return e.map(e=>Math.max(e*PL,0))},toBase(e){return e.map(e=>Math.max(e/PL,0))}});const IL=1.15,LL=.66,RL=2610/2**14,zL=2**14/2610,BL=3424/2**12,VL=2413/2**7,HL=2392/2**7,UL=1.7*2523/2**5,WL=2**5/(1.7*2523),GL=-.56,KL=16295499532821565e-27,qL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],JL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],YL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],XL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var ZL=new XI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:FL,fromBase(e){let[t,n,r]=e,i=IL*t-(IL-1)*r,a=LL*n-(LL-1)*t,o=yI(qL,[i,a,r]),s=o.map(function(e){let t=BL+VL*(e/1e4)**RL,n=1+HL*(e/1e4)**RL;return(t/n)**UL}),[c,l,u]=yI(YL,s),d=(1+GL)*c/(1+GL*c)-KL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+KL)/(1+GL-GL*(t+KL)),a=yI(XL,[i,n,r]),o=a.map(function(e){let t=BL-e**WL,n=HL*e**WL-VL,r=1e4*(t/n)**zL;return r}),[s,c,l]=yI(JL,o),u=(s+(IL-1)*l)/IL,d=(c+(LL-1)*u)/LL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),QL=new XI({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:ZL,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),dL(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 $L(e,t){[e,t]=JI([e,t]);let[n,r,i]=QL.from(e),[a,o,s]=QL.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 eR=3424/4096,tR=2413/128,nR=2392/128,rR=2610/16384,iR=2523/32,aR=16384/2610,oR=32/2523,sR=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],cR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],lR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],uR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var dR=new XI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:FL,fromBase(e){let t=yI(sR,e);return fR(t)},toBase(e){let t=pR(e);return yI(uR,t)}});function fR(e){let t=e.map(function(e){let t=eR+tR*(e/1e4)**rR,n=1+nR*(e/1e4)**rR;return(t/n)**iR});return yI(cR,t)}function pR(e){let t=yI(lR,e),n=t.map(function(e){let t=Math.max(e**oR-eR,0),n=tR-nR*e**oR;return 1e4*(t/n)**aR});return n}function mR(e,t){[e,t]=JI([e,t]);let[n,r,i]=dR.from(e),[a,o,s]=dR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const hR=HI.D65,gR=.42,_R=1/gR,vR=2*Math.PI,yR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],bR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],xR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],SR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},CR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},wR=180/Math.PI,TR=Math.PI/180;function ER(e,t){let n=e.map(e=>{let n=FI(t*Math.abs(e)*.01,gR);return 400*PI(n,e)/(n+27.13)});return n}function DR(e,t){let n=100/t*27.13**_R;return e.map(e=>{let t=Math.abs(e);return PI(n*FI(t/(400-t),_R),e)})}function OR(e){let t=dL(e);t<=CR.h[0]&&(t+=360);let n=LI(CR.h,t)-1,[r,i]=CR.h.slice(n,n+2),[a,o]=CR.e.slice(n,n+2),s=CR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function kR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=CR.h.slice(n,n+2),[a,o]=CR.e.slice(n,n+2);return dL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function AR(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=yI(yR,o);r=SR[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=>kI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=ER(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const jR=AR(hR,64/Math.PI*.2,20,`average`,!1);function MR(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?kR(e.H)*TR:dL(e.h)*TR;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=FI(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=FI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*FI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*II(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=DR(yI(xR,[d,p,m]).map(e=>e*1/1403),t.fl);return yI(bR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function NR(e,t){let n=e.map(e=>e*100),r=ER(yI(yR,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)%vR+vR)%vR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*II(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=FI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=FI(u/t.aW,.5*t.c*t.z),f=100*FI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=dL(o*wR),_=OR(g),v=50*FI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var PR=new XI({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:$I,fromBase(e){let t=NR(e,jR);return[t.J,t.M,t.h]},toBase(e){return MR({J:e[0],M:e[1],h:e[2]},jR)}});const FR=HI.D65,IR=216/24389,LR=24389/27;function RR(e){let t=e>IR?Math.cbrt(e):(LR*e+16)/116;return 116*t-16}function zR(e){return e>8?((e+16)/116)**3:e/LR}function BR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=zR(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=MR({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 MR({J:o,C:r,h:n},t)}function VR(e,t){let n=RR(e[1]);if(n===0)return[0,0,0];let r=NR(e,HR);return[dL(r.h),r.C,n]}const HR=AR(FR,200/Math.PI*zR(50),zR(50)*100,`average`,!1);var UR=new XI({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:$I,fromBase(e){return VR(e)},toBase(e){return BR(e,HR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const WR=Math.PI/180,GR=[1,.007,.0228];function KR(e){e[1]<0&&(e=UR.fromBase(UR.toBase(e)));let t=Math.log(Math.max(1+GR[2]*e[1]*HR.flRoot,1))/GR[2],n=e[0]*WR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function qR(e,t){[e,t]=JI([e,t]);let[n,r,i]=KR(UR.from(e)),[a,o,s]=KR(UR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var JR={deltaE76:AL,deltaECMC:NL,deltaE2000:yL,deltaEJz:$L,deltaEITP:mR,deltaEOK:TL,deltaEHCT:qR};function YR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const XR={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 ZR(e,{method:t=VI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=JI(e),bI(arguments[1])?n=arguments[1]:n||=e.space,n=XI.get(n),DL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=$R(e,{space:n});else{if(t!==`clip`&&!DL(e,n)){Object.prototype.hasOwnProperty.call(XR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=XR[t]);let s=yL;if(r!==``){for(let e in JR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=JR[e];break}}let c=ZR(ez(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=XI.resolveCoord(a.channel),n=nL(ez(e,t.space),t.id);if(CI(n)&&(n=0),n>=a.max)return ez({space:`xyz-d65`,coords:HI.D65},e.space);if(n<=a.min)return ez({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=XI.resolveCoord(t),c=r.space,l=r.id,u=ez(e,c);u.coords.forEach((e,t)=>{CI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=YR(i),m=f,h=nL(u,l);for(;h-m>p;){let e=OL(u);e=ZR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=nL(u,l):h=nL(u,l),iL(u,l,(m+h)/2)}o=ez(u,n)}else o=c}else o=ez(e,n);if(t===`clip`||!DL(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=ez(o,e.space)),e.coords=o.coords,e}ZR.returns=`color`;const QR={WHITE:{space:wL,coords:[1,0,0]},BLACK:{space:wL,coords:[0,0,0]}};function $R(e,{space:t}={}){let n=.02,r=1e-4;e=JI(e),t||=e.space,t=XI.get(t);let i=XI.get(`oklch`);if(t.isUnbounded)return ez(e,t);let a=ez(e,i),o=a.coords[0];if(o>=1){let n=ez(QR.WHITE,t);return n.alpha=e.alpha,ez(n,t)}if(o<=0){let n=ez(QR.BLACK,t);return n.alpha=e.alpha,ez(n,t)}if(DL(a,t,{epsilon:0}))return ez(a,t);function s(e){let n=ez(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 NI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=OL(a),f=s(d),p=TL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&DL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=TL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function ez(e,t,{inGamut:n}={}){e=JI(e),t=XI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=ZR(i,n===!0?void 0:n)),i}ez.returns=`color`;function tz(e,{precision:t=VI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=JI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??XI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!DL(e)&&(s=ZR(OL(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=>SI(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=SI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const nz=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],rz=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var iz=new eL({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:nz,fromXYZ_M:rz});const az=1.09929682680944,oz=.018053968510807;var sz=new eL({id:`rec2020`,name:`REC.2020`,base:iz,toBase(e){return e.map(function(e){return e<oz*4.5?e/4.5:((e+az-1)/az)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=oz?az*e**.45-(az-1):4.5*e})}});const cz=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],lz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var uz=new eL({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:cz,fromXYZ_M:lz});const dz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var pz=new eL({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:dz,fromXYZ_M:fz}),mz={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 hz=[,,,].fill(`<percentage> | <number>[0, 255]`),gz=[,,,].fill(`<number>[0, 255]`);var _z=new eL({id:`srgb`,name:`sRGB`,base:pz,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:hz},rgb_number:{name:`rgb`,commas:!0,coords:gz,noAlpha:!0},color:{},rgba:{coords:hz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:gz},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=mz.black,t.alpha=0):t.coords=mz[e],t.coords)return t}}}}),vz=new eL({id:`p3`,cssId:`display-p3`,name:`P3`,base:uz,fromBase:_z.fromBase,toBase:_z.toBase});VI.display_space=_z;let yz;if(typeof CSS<`u`&&CSS.supports)for(let e of[uL,sz,vz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=tz(n);if(CSS.supports(`color`,r)){VI.display_space=e;break}}function bz(e,{space:t=VI.display_space,...n}={}){let r=tz(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!VI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(CI)||CI(e.alpha);if(a&&!(yz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=OL(e),i.coords=i.coords.map(wI),i.alpha=wI(i.alpha),r=tz(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=ez(i,t),r=new String(tz(i,n)),r.color=i}return r}function xz(e,t){return e=JI(e),t=JI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function Sz(e){return nL(e,[$I,`y`])}function Cz(e,t){iL(e,[$I,`y`],t)}function wz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return Sz(this)},set(e){Cz(this,e)}})}var Tz=Object.freeze({__proto__:null,getLuminance:Sz,register:wz,setLuminance:Cz});function Ez(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const Dz=.56,Oz=.57,kz=.62,Az=.65,jz=.022,Mz=1.414,Nz=.1,Pz=5e-4,Fz=1.14,Iz=.027,Lz=1.14;function Rz(e){return e>=jz?e:e+(jz-e)**Mz}function zz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Bz(e,t){t=JI(t),e=JI(e);let n,r,i,a,o,s;t=ez(t,`srgb`),[a,o,s]=t.coords;let c=zz(a)*.2126729+zz(o)*.7151522+zz(s)*.072175;e=ez(e,`srgb`),[a,o,s]=e.coords;let l=zz(a)*.2126729+zz(o)*.7151522+zz(s)*.072175,u=Rz(c),d=Rz(l),f=d>u;return Math.abs(d-u)<Pz?r=0:f?(n=d**Dz-u**Oz,r=n*Fz):(n=d**Az-u**kz,r=n*Lz),i=Math.abs(r)<Nz?0:r>0?r-Iz:r+Iz,i*100}function Vz(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Hz=5e4;function Uz(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);return r>n&&([n,r]=[r,n]),r===0?Hz:(n-r)/r}function Wz(e,t){e=JI(e),t=JI(t);let n=nL(e,[uL,`l`]),r=nL(t,[uL,`l`]);return Math.abs(n-r)}const Gz=216/24389,Kz=24/116,qz=24389/27;let Jz=HI.D65;var Yz=new XI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Jz,base:$I,fromBase(e){let t=e.map((e,t)=>e/Jz[t]),n=t.map(e=>e>Gz?Math.cbrt(e):(qz*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]>Kz?t[0]**3:(116*t[0]-16)/qz,e[0]>8?((e[0]+16)/116)**3:e[0]/qz,t[2]>Kz?t[2]**3:(116*t[2]-16)/qz];return n.map((e,t)=>e*Jz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Xz=5**.5*.5+.5;function Zz(e,t){e=JI(e),t=JI(t);let n=nL(e,[Yz,`l`]),r=nL(t,[Yz,`l`]),i=Math.abs(n**+Xz-r**+Xz),a=i**(1/Xz)*Math.SQRT2-40;return a<7.5?0:a}var Qz=Object.freeze({__proto__:null,contrastAPCA:Bz,contrastDeltaPhi:Zz,contrastLstar:Wz,contrastMichelson:Vz,contrastWCAG21:Ez,contrastWeber:Uz});function $z(e,t,n={}){bI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(Qz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=JI(e),t=JI(t),Qz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return Qz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function eB(e){let[t,n,r]=tL(e,$I),i=t+15*n+3*r;return[4*t/i,9*n/i]}function tB(e){let[t,n,r]=tL(e,$I),i=t+n+r;return[t/i,n/i]}function nB(e){Object.defineProperty(e.prototype,`uv`,{get(){return eB(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return tB(this)}})}var rB=Object.freeze({__proto__:null,register:nB,uv:eB,xy:tB});function iB(e,t,n={}){bI(n)&&(n={method:n});let{method:r=VI.deltaE,...i}=n;for(let n in JR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return JR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function aB(e,t=.25){let n=XI.get(`oklch`,`lch`),r=[n,`l`];return iL(e,r,e=>e*(1+t))}function oB(e,t=.25){let n=XI.get(`oklch`,`lch`),r=[n,`l`];return iL(e,r,e=>e*(1-t))}var sB=Object.freeze({__proto__:null,darken:oB,lighten:aB});function cB(e,t,n=.5,r={}){[e,t]=[JI(e),JI(t)],xI(n)===`object`&&([n,r]=[.5,n]);let i=uB(e,t,r);return i(n)}function lB(e,t,n={}){let r;dB(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]=[JI(e),JI(t)],r=uB(e,t,c));let l=iB(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=iB(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,iB(o,n.color),iB(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function uB(e,t,n={}){if(dB(e)){let[n,r]=[e,t];return uB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=JI(e),t=JI(t),e=OL(e),t=OL(t);let s={colors:[e,t],options:n};if(r=r?XI.get(r):XI.registry[VI.interpolationSpace]||e.space,i=i?XI.get(i):r,e=ez(e,r),t=ez(t,r),e=ZR(e),t=ZR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[nL(e,a),nL(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=fL(i,[o,s]),iL(e,a,o),iL(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 kI(e,i,n)}),c=kI(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=ez(l,i)),l},{rangeArgs:s})}function dB(e){return xI(e)===`function`&&!!e.rangeArgs}VI.interpolationSpace=`lab`;function fB(e){e.defineFunction(`mix`,cB,{returns:`color`}),e.defineFunction(`range`,uB,{returns:`function<color>`}),e.defineFunction(`steps`,lB,{returns:`array<color>`})}var pB=Object.freeze({__proto__:null,isRange:dB,mix:cB,range:uB,register:fB,steps:lB}),mB=new XI({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:_z,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}}}),hB=new XI({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:mB,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>`]}}}),gB=new XI({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:hB,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 _B=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],vB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var yB=new eL({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:_B,fromXYZ_M:vB}),bB=new eL({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:yB,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 xB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],SB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var CB=new eL({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:aL,toXYZ_M:xB,fromXYZ_M:SB});const wB=1/512,TB=16/512;var EB=new eL({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:CB,toBase(e){return e.map(e=>e<TB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=wB?e**(1/1.8):16*e)}}),DB=new XI({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:wL,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),dL(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 OB=HI.D65;const kB=216/24389,AB=24389/27,[jB,MB]=eB({space:$I,coords:OB});var NB=new XI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:OB,base:$I,fromBase(e){let t=[wI(e[0]),wI(e[1]),wI(e[2])],n=t[1],[r,i]=eB({space:$I,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=kB?AB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-jB),13*a*(i-MB)]},toBase(e){let[t,n,r]=e;if(t===0||CI(t))return[0,0,0];n=wI(n),r=wI(r);let i=n/(13*t)+jB,a=r/(13*t)+MB,o=t<=8?t/AB:((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]`]}}}),PB=new XI({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:NB,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),dL(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 FB=216/24389,IB=24389/27,LB=fz[0][0],RB=fz[0][1],zB=fz[0][2],BB=fz[1][0],VB=fz[1][1],HB=fz[1][2],UB=fz[2][0],WB=fz[2][1],GB=fz[2][2];function KB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function qB(e){let t=(e+16)**3/1560896,n=t>FB?t:e/IB,r=n*(284517*LB-94839*zB),i=n*(838422*zB+769860*RB+731718*LB),a=n*(632260*zB-126452*RB),o=n*(284517*BB-94839*HB),s=n*(838422*HB+769860*VB+731718*BB),c=n*(632260*HB-126452*VB),l=n*(284517*UB-94839*GB),u=n*(838422*GB+769860*WB+731718*UB),d=n*(632260*GB-126452*WB);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 JB(e,t){let n=t/360*Math.PI*2,r=KB(e.r0s,e.r0i,n),i=KB(e.r1s,e.r1i,n),a=KB(e.g0s,e.g0i,n),o=KB(e.g1s,e.g1i,n),s=KB(e.b0s,e.b0i,n),c=KB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var YB=new XI({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:PB,gamutSpace:_z,fromBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=qB(t),a=JB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=qB(r),a=JB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});fz[0][0],fz[0][1],fz[0][2],fz[1][0],fz[1][1],fz[1][2],fz[2][0],fz[2][1],fz[2][2];function XB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function ZB(e){let t=XB(e.r0s,e.r0i),n=XB(e.r1s,e.r1i),r=XB(e.g0s,e.g0i),i=XB(e.g1s,e.g1i),a=XB(e.b0s,e.b0i),o=XB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var QB=new XI({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:PB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=qB(t),r=ZB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=qB(r),t=ZB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const $B=203,eV=2610/2**14,tV=2**14/2610,nV=2523/2**5,rV=2**5/2523,iV=3424/2**12,aV=2413/2**7,oV=2392/2**7;var sV=new eL({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:iz,toBase(e){return e.map(function(e){let t=(Math.max(e**rV-iV,0)/(aV-oV*e**rV))**tV;return t*1e4/$B})},fromBase(e){return e.map(function(e){let t=Math.max(e*$B/1e4,0),n=iV+aV*t**eV,r=1+oV*t**eV;return(n/r)**nV})}});const cV=.17883277,lV=.28466892,uV=.55991073,dV=3.7743;var fV=new eL({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:iz,toBase(e){return e.map(function(e){return e<=.5?e**2/3*dV:(Math.exp((e-uV)/cV)+lV)/12*dV})},fromBase(e){return e.map(function(e){return e/=dV,e<=1/12?Math.sqrt(3*e):cV*Math.log(12*e-lV)+uV})}});const pV={};BI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=hV(e.W1,e.W2,e.options.method))}),BI.add(`chromatic-adaptation-end`,e=>{e.M||=hV(e.W1,e.W2,e.options.method)});function mV({id:e,toCone_M:t,fromCone_M:n}){pV[e]=arguments[0]}function hV(e,t,n=`Bradford`){let r=pV[n],[i,a,o]=yI(r.toCone_M,e),[s,c,l]=yI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=yI(u,r.toCone_M),f=yI(r.fromCone_M,d);return f}mV({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]]}),mV({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]]}),mV({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]]}),mV({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(HI,{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]}),HI.ACES=[.32168/.33767,1,.34065/.33767];const gV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],_V=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var vV=new eL({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:HI.ACES,toXYZ_M:gV,fromXYZ_M:_V});const yV=2**-16,bV=-.35828683,xV=(Math.log2(65504)+9.72)/17.52;var SV=new eL({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[bV,xV],name:`Red`},g:{range:[bV,xV],name:`Green`},b:{range:[bV,xV],name:`Blue`}},referred:`scene`,base:vV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-yV)*2:e<xV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(yV)+9.72)/17.52:e<yV?(Math.log2(yV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),CV=Object.freeze({__proto__:null,A98RGB:bB,A98RGB_Linear:yB,ACEScc:SV,ACEScg:vV,CAM16_JMh:PR,HCT:UR,HPLuv:QB,HSL:mB,HSLuv:YB,HSV:hB,HWB:gB,ICTCP:dR,JzCzHz:QL,Jzazbz:ZL,LCH:pL,LCHuv:PB,Lab:uL,Lab_D65:Yz,Luv:NB,OKLCH:DB,OKLab:wL,P3:vz,P3_Linear:uz,ProPhoto:EB,ProPhoto_Linear:CB,REC_2020:sz,REC_2020_Linear:iz,REC_2100_HLG:fV,REC_2100_PQ:sV,XYZ_ABS_D65:FL,XYZ_D50:aL,XYZ_D65:$I,sRGB:_z,sRGB_Linear:pz}),wV=class e{constructor(...e){let t;e.length===1&&(t=JI(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:XI.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=bz(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])}};wV.defineFunctions({get:nL,getAll:tL,set:iL,setAll:rL,to:ez,equals:xz,inGamut:DL,toGamut:ZR,distance:kL,toString:tz}),Object.assign(wV,{util:RI,hooks:BI,WHITES:HI,Space:XI,spaces:XI.registry,parse:qI,defaults:VI});for(let e of Object.keys(CV))XI.register(CV[e]);for(let e in XI.registry)TV(e,XI.registry[e]);BI.add(`colorspace-init-end`,e=>{var t,n;TV(e.id,e),(t=n=e.aliases)?.forEach(t=>{TV(t,e)})});function TV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(wV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return XI.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}=XI.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}=XI.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})}wV.extend(JR),wV.extend({deltaE:iB}),Object.assign(wV,{deltaEMethods:JR}),wV.extend(sB),wV.extend({contrast:$z}),wV.extend(rB),wV.extend(Tz),wV.extend(pB),wV.extend(Qz);const{vec2:EV,vec4:DV}=sk,OV=e=>{let t=new wV(e);return DV(...t.to(`p3-linear`).coords,t.alpha).value},kV=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 EV(t,1-n).value},{vec2:AV,viewportSize:jV}=sk,MV=(e=AV(0))=>{let t=jV,n=t.x.div(t.y),r=e.x.mul(n);return AV(r,e.y)},NV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:OV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:OV,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:kV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=sk,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=MV(o()),l=MV(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 PV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${NV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=lI(NV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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,NV.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`)}}),FV=PV;const IV={name:`FilmGrain`,props:{intensity:{type:Number,default:1,description:`Grain intensity`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||yF(0,0,0,0),r=uF(),i=r.x.add(4).mul(r.y.add(4)).mul(AP.mul(10)),a=i.mod(13).add(1),o=i.mod(123).add(1),s=a.mul(o).mod(.01).sub(.005),c=s.mul(e.intensity.uniform).mul(10);return yF(n.x.add(c),n.y.add(c),n.z.add(c),n.w)}};var LV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{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=lI(IV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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}=sk;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=lI(BV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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`],roe=[...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),ioe=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+`
|
|
396
|
+
var<${n}> ${e} : ${a};`}},JO=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 QD.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return QD.LineList;if(e.isLine)return QD.LineStrip;if(e.isMesh)return QD.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 YO=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),XO=new Map([[ga,[`float16`]]]),ZO=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var QO=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?vO.Instance:vO.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?vO.Instance:vO.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=ZO.get(r);else{let e=XO.get(i)||YO.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}},$O=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===cc.READ_WRITE||n.access===cc.WRITE_ONLY)?t.type=dO.Storage:t.type=dO.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=pO.NonFiltering):r.type=pO.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===cc.READ_WRITE?t.access=fO.ReadWrite:r===cc.WRITE_ONLY?t.access=fO.WriteOnly:t.access=fO.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=mO.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=mO.UnfilterableFloat:r.sampleType=mO.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=mO.SInt:e===ft?r.sampleType=mO.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=mO.Float:r.sampleType=mO.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=gO.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=gO.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=gO.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=_O.All,a;a=t.isSampledCubeTexture?gO.Cube:t.isSampledTexture3D?gO.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?gO.TwoDArray:gO.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})}},ek=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:cO.Add},n={srcFactor:i,dstFactor:a,operation:cO.Add}};if(i)switch(r){case oe:a(sO.One,sO.OneMinusSrcAlpha,sO.One,sO.OneMinusSrcAlpha);break;case se:a(sO.One,sO.One,sO.One,sO.One);break;case ce:a(sO.Zero,sO.OneMinusSrc,sO.Zero,sO.One);break;case le:a(sO.Zero,sO.Src,sO.Zero,sO.SrcAlpha);break}else switch(r){case oe:a(sO.SrcAlpha,sO.OneMinusSrcAlpha,sO.One,sO.OneMinusSrcAlpha);break;case se:a(sO.SrcAlpha,sO.One,sO.SrcAlpha,sO.One);break;case ce:a(sO.Zero,sO.OneMinusSrc,sO.Zero,sO.One);break;case le:a(sO.Zero,sO.Src,sO.Zero,sO.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=sO.Zero;break;case _e:t=sO.One;break;case ve:t=sO.Src;break;case ye:t=sO.OneMinusSrc;break;case be:t=sO.SrcAlpha;break;case xe:t=sO.OneMinusSrcAlpha;break;case we:t=sO.Dst;break;case Te:t=sO.OneMinusDst;break;case Se:t=sO.DstAlpha;break;case Ce:t=sO.OneMinusDstAlpha;break;case Ee:t=sO.SrcAlphaSaturated;break;case ate:t=sO.Constant;break;case ote:t=sO.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case Dn:t=$D.Never;break;case Pn:t=$D.Always;break;case On:t=$D.Less;break;case An:t=$D.LessEqual;break;case kn:t=$D.Equal;break;case Nn:t=$D.GreaterEqual;break;case jn:t=$D.Greater;break;case Mn:t=$D.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case bn:t=uO.Keep;break;case yn:t=uO.Zero;break;case xn:t=uO.Replace;break;case En:t=uO.Invert;break;case Sn:t=uO.IncrementClamp;break;case Cn:t=uO.DecrementClamp;break;case wn:t=uO.IncrementWrap;break;case Tn:t=uO.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=cO.Add;break;case fe:t=cO.Subtract;break;case pe:t=cO.ReverseSubtract;break;case me:t=cO.Min;break;case he:t=cO.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?iO.Uint16:iO.Uint32),n.side){case ne:r.frontFace=nO.CCW,r.cullMode=rO.Back;break;case re:r.frontFace=nO.CCW,r.cullMode=rO.Front;break;case ie:r.frontFace=nO.CCW,r.cullMode=rO.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?lO.All:lO.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=$D.Always;else{let n=e.depthFunc;switch(n){case De:t=$D.Never;break;case Oe:t=$D.Always;break;case ke:t=$D.Less;break;case Ae:t=$D.LessEqual;break;case je:t=$D.Equal;break;case Me:t=$D.GreaterEqual;break;case Ne:t=$D.Greater;break;case Pe:t=$D.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},tk=class extends JD{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 br(`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}}},nk=class extends AD{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 JO(this),this.attributeUtils=new QO(this),this.bindingUtils=new $O(this),this.pipelineUtils=new ek(this),this.textureUtils=new OO(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(yO),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(yO.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 Kn}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:gO.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=gO.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:gO.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=gO.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=gO.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||tO.Load,storeOp:t.storeOp||eO.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:tO.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=tO.Clear):r.loadOp=tO.Load,r.storeOp=eO.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=tO.Clear):t.loadOp=tO.Load,t.storeOp=eO.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=tO.Clear):o.depthLoadOp=tO.Load,o.depthStoreOp=eO.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=tO.Clear):o.stencilLoadOp=tO.Load,o.stencilStoreOp=eO.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:gO.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||tO.Clear,depthStoreOp:i.depthStoreOp||eO.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=tO.Clear):t.depthLoadOp=tO.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=tO.Clear):t.stencilLoadOp=tO.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=tO.Clear,e.storeOp=eO.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?tO.Clear:tO.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?tO.Clear:tO.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=eO.Store),u&&(i.stencilLoadOp=n?tO.Clear:tO.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=eO.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=tO.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=eO.Store):(s.depthLoadOp=tO.Load,s.depthStoreOp=eO.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=tO.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=eO.Store):(s.stencilLoadOp=tO.Load,s.stencilStoreOp=eO.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?iO.Uint16:iO.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&&br(`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 tk(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 qO(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=tO.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=tO.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=tO.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)}},rk=class extends ds{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}},ik=class extends ds{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}},ak=class extends FE{constructor(){super(),this.addMaterial(cv,`MeshPhongMaterial`),this.addMaterial(Ky,`MeshStandardMaterial`),this.addMaterial(Iee,`MeshPhysicalMaterial`),this.addMaterial(Bee,`MeshToonMaterial`),this.addMaterial(Q_,`MeshBasicMaterial`),this.addMaterial(ov,`MeshLambertMaterial`),this.addMaterial(L_,`MeshNormalMaterial`),this.addMaterial(Uee,`MeshMatcapMaterial`),this.addMaterial(O_,`LineBasicMaterial`),this.addMaterial(A_,`LineDashedMaterial`),this.addMaterial(qee,`PointsMaterial`),this.addMaterial(Yy,`SpriteMaterial`),this.addMaterial(Xee,`ShadowMaterial`),this.addLight(LC,gs),this.addLight(oE,ys),this.addLight(uE,xs),this.addLight(dE,ds),this.addLight(hE,bs),this.addLight(gE,rs),this.addLight(_E,Cs),this.addLight(fE,rk),this.addLight(mE,ik),this.addToneMapping(Dx,ze),this.addToneMapping(Ox,Be),this.addToneMapping(kx,Ve),this.addToneMapping(jx,He),this.addToneMapping(Fx,Ue),this.addToneMapping(Ix,We)}},ok=class extends iD{constructor(e={}){let t;e.forceWebGL?t=ZD:(t=nk,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new ZD(e)));let n=new t(e);super(n,e),this.library=new ak,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},sk={};_(sk,{BRDF_GGX:()=>ck,BRDF_Lambert:()=>lk,BasicShadowFilter:()=>uk,Break:()=>dk,Const:()=>yj,Continue:()=>fk,DFGApprox:()=>pk,D_GGX:()=>mk,Discard:()=>hk,EPSILON:()=>gk,F_Schlick:()=>_k,Fn:()=>vk,INFINITY:()=>yk,If:()=>bk,Loop:()=>Sk,NodeAccess:()=>Ek,NodeShaderStage:()=>Ck,NodeType:()=>wk,NodeUpdateType:()=>Tk,PCFShadowFilter:()=>Dk,PCFSoftShadowFilter:()=>Ok,PI:()=>kk,PI2:()=>Ak,Return:()=>jk,Schlick_to_F0:()=>Mk,ScriptableNodeResources:()=>Nk,ShaderNode:()=>Pk,Switch:()=>xk,TBNViewMatrix:()=>Fk,VSMShadowFilter:()=>Ik,V_GGX_SmithCorrelated:()=>Lk,Var:()=>mF,abs:()=>Rk,acesFilmicToneMapping:()=>zk,acos:()=>Bk,add:()=>Vk,addNodeElement:()=>Hk,agxToneMapping:()=>Uk,all:()=>Wk,alphaT:()=>Gk,and:()=>Kk,anisotropy:()=>qk,anisotropyB:()=>Jk,anisotropyT:()=>Yk,any:()=>Xk,append:()=>Zk,array:()=>Qk,arrayBuffer:()=>$k,asin:()=>eA,assign:()=>tA,atan:()=>nA,atan2:()=>rA,atomicAdd:()=>iA,atomicAnd:()=>aA,atomicFunc:()=>oA,atomicLoad:()=>pA,atomicMax:()=>sA,atomicMin:()=>cA,atomicOr:()=>lA,atomicStore:()=>uA,atomicSub:()=>dA,atomicXor:()=>fA,attenuationColor:()=>mA,attenuationDistance:()=>hA,attribute:()=>gA,attributeArray:()=>_A,backgroundBlurriness:()=>vA,backgroundIntensity:()=>yA,backgroundRotation:()=>bA,batch:()=>xA,billboarding:()=>SA,bitAnd:()=>CA,bitNot:()=>wA,bitOr:()=>TA,bitXor:()=>EA,bitangentGeometry:()=>DA,bitangentLocal:()=>OA,bitangentView:()=>kA,bitangentWorld:()=>AA,bitcast:()=>jA,blendBurn:()=>MA,blendColor:()=>NA,blendDodge:()=>PA,blendOverlay:()=>FA,blendScreen:()=>IA,blur:()=>LA,bool:()=>RA,buffer:()=>zA,bufferAttribute:()=>BA,bumpMap:()=>VA,burn:()=>HA,bvec2:()=>UA,bvec3:()=>WA,bvec4:()=>GA,bypass:()=>KA,cache:()=>qA,call:()=>JA,cameraFar:()=>YA,cameraIndex:()=>XA,cameraNear:()=>ZA,cameraNormalMatrix:()=>QA,cameraPosition:()=>$A,cameraProjectionMatrix:()=>ej,cameraProjectionMatrixInverse:()=>tj,cameraViewMatrix:()=>nj,cameraWorldMatrix:()=>rj,cbrt:()=>ij,cdl:()=>aj,ceil:()=>oj,checker:()=>sj,cineonToneMapping:()=>cj,clamp:()=>lj,clearcoat:()=>uj,clearcoatRoughness:()=>dj,code:()=>fj,color:()=>pj,colorSpaceToWorking:()=>mj,colorToDirection:()=>hj,compute:()=>gj,computeSkinning:()=>_j,cond:()=>vj,context:()=>bj,convert:()=>xj,convertColorSpace:()=>Sj,convertToTexture:()=>Cj,cos:()=>wj,cross:()=>Tj,cubeTexture:()=>Ej,dFdx:()=>Dj,dFdy:()=>Oj,dashSize:()=>kj,debug:()=>Aj,decrement:()=>jj,decrementBefore:()=>Mj,defaultBuildStages:()=>Nj,defaultShaderStages:()=>Pj,defined:()=>Fj,degrees:()=>Ij,deltaTime:()=>Lj,densityFog:()=>Rj,densityFogFactor:()=>zj,depth:()=>Bj,depthPass:()=>Vj,difference:()=>Hj,diffuseColor:()=>Uj,directPointLight:()=>Wj,directionToColor:()=>Gj,dispersion:()=>Kj,distance:()=>qj,div:()=>Jj,dodge:()=>Yj,dot:()=>Xj,drawIndex:()=>Zj,dynamicBufferAttribute:()=>Qj,element:()=>$j,emissive:()=>eM,equal:()=>tM,equals:()=>nM,equirectUV:()=>rM,exp:()=>iM,exp2:()=>aM,expression:()=>oM,faceDirection:()=>sM,faceForward:()=>cM,faceforward:()=>lM,float:()=>uM,floor:()=>dM,fog:()=>fM,fract:()=>pM,frameGroup:()=>mM,frameId:()=>hM,frontFacing:()=>gM,fwidth:()=>_M,gain:()=>vM,gapSize:()=>yM,getConstNodeType:()=>bM,getCurrentStack:()=>xM,getDirection:()=>SM,getDistanceAttenuation:()=>CM,getGeometryRoughness:()=>wM,getNormalFromDepth:()=>TM,getParallaxCorrectNormal:()=>EM,getRoughness:()=>DM,getScreenPosition:()=>OM,getShIrradianceAt:()=>kM,getShadowMaterial:()=>MM,getShadowRenderObjectFunction:()=>NM,getTextureIndex:()=>AM,getViewPosition:()=>jM,globalId:()=>gre,glsl:()=>PM,glslFn:()=>FM,grayscale:()=>Dne,greaterThan:()=>One,greaterThanEqual:()=>kne,hash:()=>Ane,highpModelNormalViewMatrix:()=>jne,highpModelViewMatrix:()=>Mne,hue:()=>Nne,increment:()=>Pne,incrementBefore:()=>Fne,instance:()=>Ine,instanceIndex:()=>Lne,instancedArray:()=>Rne,instancedBufferAttribute:()=>zne,instancedDynamicBufferAttribute:()=>Bne,instancedMesh:()=>Vne,int:()=>Hne,inverseSqrt:()=>Une,inversesqrt:()=>Wne,invocationLocalIndex:()=>Gne,invocationSubgroupIndex:()=>Kne,ior:()=>qne,iridescence:()=>Jne,iridescenceIOR:()=>Yne,iridescenceThickness:()=>Xne,ivec2:()=>Zne,ivec3:()=>Qne,ivec4:()=>$ne,js:()=>ere,label:()=>tre,length:()=>nre,lengthSq:()=>rre,lessThan:()=>ire,lessThanEqual:()=>are,lightPosition:()=>ore,lightProjectionUV:()=>$M,lightShadowMatrix:()=>sre,lightTargetDirection:()=>cre,lightTargetPosition:()=>lre,lightViewPosition:()=>ure,lightingContext:()=>dre,lights:()=>fre,linearDepth:()=>pre,linearToneMapping:()=>mre,localId:()=>hre,log:()=>_re,log2:()=>vre,logarithmicDepthToViewZ:()=>yre,loop:()=>bre,luminance:()=>xre,mat2:()=>Cre,mat3:()=>wre,mat4:()=>Tre,matcapUV:()=>Ere,materialAO:()=>Dre,materialAlphaTest:()=>Ore,materialAnisotropy:()=>kre,materialAnisotropyVector:()=>Are,materialAttenuationColor:()=>jre,materialAttenuationDistance:()=>Mre,materialClearcoat:()=>Nre,materialClearcoatNormal:()=>Pre,materialClearcoatRoughness:()=>Fre,materialColor:()=>Ire,materialDispersion:()=>Lre,materialEmissive:()=>Rre,materialIOR:()=>zre,materialIridescence:()=>Bre,materialIridescenceIOR:()=>Vre,materialIridescenceThickness:()=>Hre,materialLightMap:()=>Ure,materialLineDashOffset:()=>Wre,materialLineDashSize:()=>Gre,materialLineGapSize:()=>Kre,materialLineScale:()=>qre,materialLineWidth:()=>Jre,materialMetalness:()=>Yre,materialNormal:()=>Xre,materialOpacity:()=>Zre,materialPointSize:()=>Qre,materialReference:()=>$re,materialReflectivity:()=>eie,materialRefractionRatio:()=>tie,materialRotation:()=>nie,materialRoughness:()=>rie,materialSheen:()=>iie,materialSheenRoughness:()=>aie,materialShininess:()=>oie,materialSpecular:()=>sie,materialSpecularColor:()=>cie,materialSpecularIntensity:()=>lie,materialSpecularStrength:()=>uie,materialThickness:()=>die,materialTransmission:()=>fie,max:()=>IM,maxMipLevel:()=>pie,mediumpModelViewMatrix:()=>Sre,metalness:()=>mie,min:()=>hie,mix:()=>LM,mixElement:()=>gie,mod:()=>_ie,modInt:()=>vie,modelDirection:()=>yie,modelNormalMatrix:()=>bie,modelPosition:()=>xie,modelRadius:()=>Sie,modelScale:()=>Cie,modelViewMatrix:()=>wie,modelViewPosition:()=>Tie,modelViewProjection:()=>Eie,modelWorldMatrix:()=>Die,modelWorldMatrixInverse:()=>Oie,morphReference:()=>kie,mrt:()=>Aie,mul:()=>RM,mx_aastep:()=>jie,mx_cell_noise_float:()=>Mie,mx_contrast:()=>Nie,mx_fractal_noise_float:()=>Pie,mx_fractal_noise_vec2:()=>Fie,mx_fractal_noise_vec3:()=>Iie,mx_fractal_noise_vec4:()=>Lie,mx_hsvtorgb:()=>Rie,mx_noise_float:()=>zie,mx_noise_vec3:()=>Bie,mx_noise_vec4:()=>Vie,mx_ramplr:()=>Hie,mx_ramptb:()=>Uie,mx_rgbtohsv:()=>Wie,mx_safepower:()=>Gie,mx_splitlr:()=>Kie,mx_splittb:()=>qie,mx_srgb_texture_to_lin_rec709:()=>Jie,mx_transform_uv:()=>Yie,mx_worley_noise_float:()=>Xie,mx_worley_noise_vec2:()=>Zie,mx_worley_noise_vec3:()=>Qie,namespace:()=>$ie,negate:()=>eae,neutralToneMapping:()=>tae,nodeArray:()=>nae,nodeImmutable:()=>rae,nodeObject:()=>iae,nodeObjects:()=>aae,nodeProxy:()=>oae,normalFlat:()=>sae,normalGeometry:()=>cae,normalLocal:()=>lae,normalMap:()=>uae,normalView:()=>dae,normalWorld:()=>fae,normalize:()=>pae,not:()=>mae,notEqual:()=>hae,numWorkgroups:()=>gae,objectDirection:()=>_ae,objectGroup:()=>vae,objectPosition:()=>yae,objectRadius:()=>bae,objectScale:()=>xae,objectViewPosition:()=>Sae,objectWorldMatrix:()=>Cae,oneMinus:()=>wae,or:()=>Tae,orthographicDepthToViewZ:()=>Eae,oscSawtooth:()=>Dae,oscSine:()=>Oae,oscSquare:()=>kae,oscTriangle:()=>Aae,output:()=>jae,outputStruct:()=>Mae,overlay:()=>Nae,overloadingFn:()=>Pae,parabola:()=>Fae,parallaxDirection:()=>Iae,parallaxUV:()=>Lae,parameter:()=>Rae,pass:()=>zae,passTexture:()=>Bae,pcurve:()=>Vae,perspectiveDepthToViewZ:()=>Hae,pmremTexture:()=>Uae,pointShadow:()=>LN,pointUV:()=>Wae,pointWidth:()=>Gae,positionGeometry:()=>Kae,positionLocal:()=>qae,positionPrevious:()=>Jae,positionView:()=>Yae,positionViewDirection:()=>Xae,positionWorld:()=>Zae,positionWorldDirection:()=>zM,posterize:()=>BM,pow:()=>VM,pow2:()=>HM,pow3:()=>UM,pow4:()=>WM,premult:()=>GM,property:()=>KM,radians:()=>qM,rand:()=>JM,range:()=>YM,rangeFog:()=>XM,rangeFogFactor:()=>ZM,reciprocal:()=>QM,reference:()=>eN,referenceBuffer:()=>tN,reflect:()=>nN,reflectVector:()=>rN,reflectView:()=>iN,reflector:()=>aN,refract:()=>oN,refractVector:()=>sN,refractView:()=>cN,reinhardToneMapping:()=>lN,remainder:()=>uN,remap:()=>dN,remapClamp:()=>fN,renderGroup:()=>pN,renderOutput:()=>mN,rendererReference:()=>hN,rotate:()=>gN,rotateUV:()=>_N,roughness:()=>vN,round:()=>yN,rtt:()=>bN,sRGBTransferEOTF:()=>xN,sRGBTransferOETF:()=>SN,sampler:()=>CN,samplerComparison:()=>wN,saturate:()=>TN,saturation:()=>EN,screen:()=>DN,screenCoordinate:()=>ON,screenSize:()=>kN,screenUV:()=>AN,scriptable:()=>jN,scriptableValue:()=>MN,select:()=>NN,setCurrentStack:()=>PN,shaderStages:()=>FN,shadow:()=>IN,shadowPositionWorld:()=>RN,shapeCircle:()=>BN,sharedUniformGroup:()=>zN,sheen:()=>VN,sheenRoughness:()=>HN,shiftLeft:()=>UN,shiftRight:()=>WN,shininess:()=>GN,sign:()=>KN,sin:()=>qN,sinc:()=>JN,skinning:()=>YN,smoothstep:()=>XN,smoothstepElement:()=>ZN,specularColor:()=>QN,specularF90:()=>$N,spherizeUV:()=>eP,split:()=>tP,spritesheetUV:()=>nP,sqrt:()=>rP,stack:()=>iP,step:()=>aP,storage:()=>oP,storageBarrier:()=>sP,storageObject:()=>cP,storageTexture:()=>lP,string:()=>uP,struct:()=>dP,sub:()=>fP,subgroupIndex:()=>pP,subgroupSize:()=>mP,tan:()=>hP,tangentGeometry:()=>gP,tangentLocal:()=>_P,tangentView:()=>vP,tangentWorld:()=>yP,temp:()=>bP,texture:()=>xP,texture3D:()=>SP,textureBarrier:()=>CP,textureBicubic:()=>wP,textureCubeUV:()=>TP,textureLoad:()=>EP,textureSize:()=>DP,textureStore:()=>OP,thickness:()=>kP,time:()=>AP,timerDelta:()=>jP,timerGlobal:()=>MP,timerLocal:()=>NP,toneMapping:()=>PP,toneMappingExposure:()=>FP,toonOutlinePass:()=>IP,transformDirection:()=>LP,transformNormal:()=>RP,transformNormalToView:()=>zP,transformedBentNormalView:()=>BP,transformedBitangentView:()=>VP,transformedBitangentWorld:()=>HP,transformedClearcoatNormalView:()=>UP,transformedNormalView:()=>WP,transformedNormalWorld:()=>GP,transformedTangentView:()=>KP,transformedTangentWorld:()=>qP,transmission:()=>JP,transpose:()=>YP,triNoise3D:()=>XP,triplanarTexture:()=>ZP,triplanarTextures:()=>QP,trunc:()=>$P,tslFn:()=>eF,uint:()=>tF,uniform:()=>nF,uniformArray:()=>iF,uniformCubeTexture:()=>rF,uniformGroup:()=>aF,uniformTexture:()=>oF,uniforms:()=>sF,unpremult:()=>cF,userData:()=>lF,uv:()=>uF,uvec2:()=>dF,uvec3:()=>fF,uvec4:()=>pF,varying:()=>hF,varyingProperty:()=>gF,vec2:()=>_F,vec3:()=>vF,vec4:()=>yF,vectorComponents:()=>bF,velocity:()=>xF,vertexColor:()=>SF,vertexIndex:()=>CF,vibrance:()=>wF,viewZToLogarithmicDepth:()=>TF,viewZToOrthographicDepth:()=>EF,viewZToPerspectiveDepth:()=>DF,viewport:()=>OF,viewportBottomLeft:()=>kF,viewportCoordinate:()=>AF,viewportDepthTexture:()=>jF,viewportLinearDepth:()=>MF,viewportMipTexture:()=>NF,viewportResolution:()=>PF,viewportSafeUV:()=>FF,viewportSharedTexture:()=>IF,viewportSize:()=>LF,viewportTexture:()=>RF,viewportTopLeft:()=>zF,viewportUV:()=>BF,wgsl:()=>VF,wgslFn:()=>HF,workgroupArray:()=>UF,workgroupBarrier:()=>WF,workgroupId:()=>GF,workingToColorSpace:()=>KF,xor:()=>qF});const ck=I.BRDF_GGX,lk=I.BRDF_Lambert,uk=I.BasicShadowFilter,dk=I.Break,fk=I.Continue,pk=I.DFGApprox,mk=I.D_GGX,hk=I.Discard,gk=I.EPSILON,_k=I.F_Schlick,vk=I.Fn,yk=I.INFINITY,bk=I.If,xk=I.Switch,Sk=I.Loop,Ck=I.NodeShaderStage,wk=I.NodeType,Tk=I.NodeUpdateType,Ek=I.NodeAccess,Dk=I.PCFShadowFilter,Ok=I.PCFSoftShadowFilter,kk=I.PI,Ak=I.PI2,jk=I.Return,Mk=I.Schlick_to_F0,Nk=I.ScriptableNodeResources,Pk=I.ShaderNode,Fk=I.TBNViewMatrix,Ik=I.VSMShadowFilter,Lk=I.V_GGX_SmithCorrelated,Rk=I.abs,zk=I.acesFilmicToneMapping,Bk=I.acos,Vk=I.add,Hk=I.addNodeElement,Uk=I.agxToneMapping,Wk=I.all,Gk=I.alphaT,Kk=I.and,qk=I.anisotropy,Jk=I.anisotropyB,Yk=I.anisotropyT,Xk=I.any,Zk=I.append,Qk=I.array,$k=I.arrayBuffer,eA=I.asin,tA=I.assign,nA=I.atan,rA=I.atan2,iA=I.atomicAdd,aA=I.atomicAnd,oA=I.atomicFunc,sA=I.atomicMax,cA=I.atomicMin,lA=I.atomicOr,uA=I.atomicStore,dA=I.atomicSub,fA=I.atomicXor,pA=I.atomicLoad,mA=I.attenuationColor,hA=I.attenuationDistance,gA=I.attribute,_A=I.attributeArray,vA=I.backgroundBlurriness,yA=I.backgroundIntensity,bA=I.backgroundRotation,xA=I.batch,SA=I.billboarding,CA=I.bitAnd,wA=I.bitNot,TA=I.bitOr,EA=I.bitXor,DA=I.bitangentGeometry,OA=I.bitangentLocal,kA=I.bitangentView,AA=I.bitangentWorld,jA=I.bitcast,MA=I.blendBurn,NA=I.blendColor,PA=I.blendDodge,FA=I.blendOverlay,IA=I.blendScreen,LA=I.blur,RA=I.bool,zA=I.buffer,BA=I.bufferAttribute,VA=I.bumpMap,HA=I.burn,UA=I.bvec2,WA=I.bvec3,GA=I.bvec4,KA=I.bypass,qA=I.cache,JA=I.call,YA=I.cameraFar,XA=I.cameraIndex,ZA=I.cameraNear,QA=I.cameraNormalMatrix,$A=I.cameraPosition,ej=I.cameraProjectionMatrix,tj=I.cameraProjectionMatrixInverse,nj=I.cameraViewMatrix,rj=I.cameraWorldMatrix,ij=I.cbrt,aj=I.cdl,oj=I.ceil,sj=I.checker,cj=I.cineonToneMapping,lj=I.clamp,uj=I.clearcoat,dj=I.clearcoatRoughness,fj=I.code,pj=I.color,mj=I.colorSpaceToWorking,hj=I.colorToDirection,gj=I.compute,_j=I.computeSkinning,vj=I.cond,yj=I.Const,bj=I.context,xj=I.convert,Sj=I.convertColorSpace,Cj=I.convertToTexture,wj=I.cos,Tj=I.cross,Ej=I.cubeTexture,Dj=I.dFdx,Oj=I.dFdy,kj=I.dashSize,Aj=I.debug,jj=I.decrement,Mj=I.decrementBefore,Nj=I.defaultBuildStages,Pj=I.defaultShaderStages,Fj=I.defined,Ij=I.degrees,Lj=I.deltaTime,Rj=I.densityFog,zj=I.densityFogFactor,Bj=I.depth,Vj=I.depthPass,Hj=I.difference,Uj=I.diffuseColor,Wj=I.directPointLight,Gj=I.directionToColor,Kj=I.dispersion,qj=I.distance,Jj=I.div,Yj=I.dodge,Xj=I.dot,Zj=I.drawIndex,Qj=I.dynamicBufferAttribute,$j=I.element,eM=I.emissive,tM=I.equal,nM=I.equals,rM=I.equirectUV,iM=I.exp,aM=I.exp2,oM=I.expression,sM=I.faceDirection,cM=I.faceForward,lM=I.faceforward,uM=I.float,dM=I.floor,fM=I.fog,pM=I.fract,mM=I.frameGroup,hM=I.frameId,gM=I.frontFacing,_M=I.fwidth,vM=I.gain,yM=I.gapSize,bM=I.getConstNodeType,xM=I.getCurrentStack,SM=I.getDirection,CM=I.getDistanceAttenuation,wM=I.getGeometryRoughness,TM=I.getNormalFromDepth,EM=I.getParallaxCorrectNormal,DM=I.getRoughness,OM=I.getScreenPosition,kM=I.getShIrradianceAt,AM=I.getTextureIndex,jM=I.getViewPosition,MM=I.getShadowMaterial,NM=I.getShadowRenderObjectFunction,PM=I.glsl,FM=I.glslFn,Dne=I.grayscale,One=I.greaterThan,kne=I.greaterThanEqual,Ane=I.hash,jne=I.highpModelNormalViewMatrix,Mne=I.highpModelViewMatrix,Nne=I.hue,Pne=I.increment,Fne=I.incrementBefore,Ine=I.instance,Lne=I.instanceIndex,Rne=I.instancedArray,zne=I.instancedBufferAttribute,Bne=I.instancedDynamicBufferAttribute,Vne=I.instancedMesh,Hne=I.int,Une=I.inverseSqrt,Wne=I.inversesqrt,Gne=I.invocationLocalIndex,Kne=I.invocationSubgroupIndex,qne=I.ior,Jne=I.iridescence,Yne=I.iridescenceIOR,Xne=I.iridescenceThickness,Zne=I.ivec2,Qne=I.ivec3,$ne=I.ivec4,ere=I.js,tre=I.label,nre=I.length,rre=I.lengthSq,ire=I.lessThan,are=I.lessThanEqual,ore=I.lightPosition,sre=I.lightShadowMatrix,cre=I.lightTargetDirection,lre=I.lightTargetPosition,ure=I.lightViewPosition,dre=I.lightingContext,fre=I.lights,pre=I.linearDepth,mre=I.linearToneMapping,hre=I.localId,gre=I.globalId,_re=I.log,vre=I.log2,yre=I.logarithmicDepthToViewZ,bre=I.loop,xre=I.luminance,Sre=I.mediumpModelViewMatrix,Cre=I.mat2,wre=I.mat3,Tre=I.mat4,Ere=I.matcapUV,Dre=I.materialAO,Ore=I.materialAlphaTest,kre=I.materialAnisotropy,Are=I.materialAnisotropyVector,jre=I.materialAttenuationColor,Mre=I.materialAttenuationDistance,Nre=I.materialClearcoat,Pre=I.materialClearcoatNormal,Fre=I.materialClearcoatRoughness,Ire=I.materialColor,Lre=I.materialDispersion,Rre=I.materialEmissive,zre=I.materialIOR,Bre=I.materialIridescence,Vre=I.materialIridescenceIOR,Hre=I.materialIridescenceThickness,Ure=I.materialLightMap,Wre=I.materialLineDashOffset,Gre=I.materialLineDashSize,Kre=I.materialLineGapSize,qre=I.materialLineScale,Jre=I.materialLineWidth,Yre=I.materialMetalness,Xre=I.materialNormal,Zre=I.materialOpacity,Qre=I.materialPointSize,$re=I.materialReference,eie=I.materialReflectivity,tie=I.materialRefractionRatio,nie=I.materialRotation,rie=I.materialRoughness,iie=I.materialSheen,aie=I.materialSheenRoughness,oie=I.materialShininess,sie=I.materialSpecular,cie=I.materialSpecularColor,lie=I.materialSpecularIntensity,uie=I.materialSpecularStrength,die=I.materialThickness,fie=I.materialTransmission,IM=I.max,pie=I.maxMipLevel,mie=I.metalness,hie=I.min,LM=I.mix,gie=I.mixElement,_ie=I.mod,vie=I.modInt,yie=I.modelDirection,bie=I.modelNormalMatrix,xie=I.modelPosition,Sie=I.modelRadius,Cie=I.modelScale,wie=I.modelViewMatrix,Tie=I.modelViewPosition,Eie=I.modelViewProjection,Die=I.modelWorldMatrix,Oie=I.modelWorldMatrixInverse,kie=I.morphReference,Aie=I.mrt,RM=I.mul,jie=I.mx_aastep,Mie=I.mx_cell_noise_float,Nie=I.mx_contrast,Pie=I.mx_fractal_noise_float,Fie=I.mx_fractal_noise_vec2,Iie=I.mx_fractal_noise_vec3,Lie=I.mx_fractal_noise_vec4,Rie=I.mx_hsvtorgb,zie=I.mx_noise_float,Bie=I.mx_noise_vec3,Vie=I.mx_noise_vec4,Hie=I.mx_ramplr,Uie=I.mx_ramptb,Wie=I.mx_rgbtohsv,Gie=I.mx_safepower,Kie=I.mx_splitlr,qie=I.mx_splittb,Jie=I.mx_srgb_texture_to_lin_rec709,Yie=I.mx_transform_uv,Xie=I.mx_worley_noise_float,Zie=I.mx_worley_noise_vec2,Qie=I.mx_worley_noise_vec3,$ie=I.namespace,eae=I.negate,tae=I.neutralToneMapping,nae=I.nodeArray,rae=I.nodeImmutable,iae=I.nodeObject,aae=I.nodeObjects,oae=I.nodeProxy,sae=I.normalFlat,cae=I.normalGeometry,lae=I.normalLocal,uae=I.normalMap,dae=I.normalView,fae=I.normalWorld,pae=I.normalize,mae=I.not,hae=I.notEqual,gae=I.numWorkgroups,_ae=I.objectDirection,vae=I.objectGroup,yae=I.objectPosition,bae=I.objectRadius,xae=I.objectScale,Sae=I.objectViewPosition,Cae=I.objectWorldMatrix,wae=I.oneMinus,Tae=I.or,Eae=I.orthographicDepthToViewZ,Dae=I.oscSawtooth,Oae=I.oscSine,kae=I.oscSquare,Aae=I.oscTriangle,jae=I.output,Mae=I.outputStruct,Nae=I.overlay,Pae=I.overloadingFn,Fae=I.parabola,Iae=I.parallaxDirection,Lae=I.parallaxUV,Rae=I.parameter,zae=I.pass,Bae=I.passTexture,Vae=I.pcurve,Hae=I.perspectiveDepthToViewZ,Uae=I.pmremTexture,Wae=I.pointUV,Gae=I.pointWidth,Kae=I.positionGeometry,qae=I.positionLocal,Jae=I.positionPrevious,Yae=I.positionView,Xae=I.positionViewDirection,Zae=I.positionWorld,zM=I.positionWorldDirection,BM=I.posterize,VM=I.pow,HM=I.pow2,UM=I.pow3,WM=I.pow4,GM=I.premult,KM=I.property,qM=I.radians,JM=I.rand,YM=I.range,XM=I.rangeFog,ZM=I.rangeFogFactor,QM=I.reciprocal,$M=I.lightProjectionUV,eN=I.reference,tN=I.referenceBuffer,nN=I.reflect,rN=I.reflectVector,iN=I.reflectView,aN=I.reflector,oN=I.refract,sN=I.refractVector,cN=I.refractView,lN=I.reinhardToneMapping,uN=I.remainder,dN=I.remap,fN=I.remapClamp,pN=I.renderGroup,mN=I.renderOutput,hN=I.rendererReference,gN=I.rotate,_N=I.rotateUV,vN=I.roughness,yN=I.round,bN=I.rtt,xN=I.sRGBTransferEOTF,SN=I.sRGBTransferOETF,CN=I.sampler,wN=I.samplerComparison,TN=I.saturate,EN=I.saturation,DN=I.screen,ON=I.screenCoordinate,kN=I.screenSize,AN=I.screenUV,jN=I.scriptable,MN=I.scriptableValue,NN=I.select,PN=I.setCurrentStack,FN=I.shaderStages,IN=I.shadow,LN=I.pointShadow,RN=I.shadowPositionWorld,zN=I.sharedUniformGroup,BN=I.shapeCircle,VN=I.sheen,HN=I.sheenRoughness,UN=I.shiftLeft,WN=I.shiftRight,GN=I.shininess,KN=I.sign,qN=I.sin,JN=I.sinc,YN=I.skinning,XN=I.smoothstep,ZN=I.smoothstepElement,QN=I.specularColor,$N=I.specularF90,eP=I.spherizeUV,tP=I.split,nP=I.spritesheetUV,rP=I.sqrt,iP=I.stack,aP=I.step,oP=I.storage,sP=I.storageBarrier,cP=I.storageObject,lP=I.storageTexture,uP=I.string,dP=I.struct,fP=I.sub,pP=I.subgroupIndex,mP=I.subgroupSize,hP=I.tan,gP=I.tangentGeometry,_P=I.tangentLocal,vP=I.tangentView,yP=I.tangentWorld,bP=I.temp,xP=I.texture,SP=I.texture3D,CP=I.textureBarrier,wP=I.textureBicubic,TP=I.textureCubeUV,EP=I.textureLoad,DP=I.textureSize,OP=I.textureStore,kP=I.thickness,AP=I.time,jP=I.timerDelta,MP=I.timerGlobal,NP=I.timerLocal,PP=I.toneMapping,FP=I.toneMappingExposure,IP=I.toonOutlinePass,LP=I.transformDirection,RP=I.transformNormal,zP=I.transformNormalToView,BP=I.transformedBentNormalView,VP=I.transformedBitangentView,HP=I.transformedBitangentWorld,UP=I.transformedClearcoatNormalView,WP=I.transformedNormalView,GP=I.transformedNormalWorld,KP=I.transformedTangentView,qP=I.transformedTangentWorld,JP=I.transmission,YP=I.transpose,XP=I.triNoise3D,ZP=I.triplanarTexture,QP=I.triplanarTextures,$P=I.trunc,eF=I.tslFn,tF=I.uint,nF=I.uniform,rF=I.uniformCubeTexture,iF=I.uniformArray,aF=I.uniformGroup,oF=I.uniformTexture,sF=I.uniforms,cF=I.unpremult,lF=I.userData,uF=I.uv,dF=I.uvec2,fF=I.uvec3,pF=I.uvec4,mF=I.Var,hF=I.varying,gF=I.varyingProperty,_F=I.vec2,vF=I.vec3,yF=I.vec4,bF=I.vectorComponents,xF=I.velocity,SF=I.vertexColor,CF=I.vertexIndex,wF=I.vibrance,TF=I.viewZToLogarithmicDepth,EF=I.viewZToOrthographicDepth,DF=I.viewZToPerspectiveDepth,OF=I.viewport,kF=I.viewportBottomLeft,AF=I.viewportCoordinate,jF=I.viewportDepthTexture,MF=I.viewportLinearDepth,NF=I.viewportMipTexture,PF=I.viewportResolution,FF=I.viewportSafeUV,IF=I.viewportSharedTexture,LF=I.viewportSize,RF=I.viewportTexture,zF=I.viewportTopLeft,BF=I.viewportUV,VF=I.wgsl,HF=I.wgslFn,UF=I.workgroupArray,WF=I.workgroupBarrier,GF=I.workgroupId,KF=I.workingToColorSpace,qF=I.xor;function JF(e,t,n=1){let r=e.rgb,i=t.rgb,a=RM(r,i),o=RM(t.a,n),s=LM(r,a,o),c=IM(e.a,RM(t.a,n));return yF(s,c)}function YF(e,t,n=1){let r=RM(t.a,n),i=Vk(r,RM(e.a,fP(1,r))),a=Vk(RM(t.rgb,r),RM(e.rgb,RM(e.a,fP(1,r))));return yF(a,i)}const XF={normal:YF,multiply:JF};function ZF(e,t,n=`normal`,r=1){let i=XF[n]||XF.normal;return i(e,t,r)}function QF(e,t){let n=RM(e.a,t.a);return yF(e.rgb,n)}function $F(e,t){let n=fP(1,t.a),r=RM(e.a,n);return yF(e.rgb,r)}function eI(e,t){let n=vF(.2126,.7152,.0722),r=Xj(t.rgb,n),i=RM(e.a,r);return yF(e.rgb,i)}function tI(e,t){let n=vF(.2126,.7152,.0722),r=Xj(t.rgb,n),i=fP(1,r),a=RM(e.a,i);return yF(e.rgb,a)}const nI={alpha:QF,alphaInverted:$F,luminance:eI,luminanceInverted:tI};function rI(e,t,n=`alpha`){let r=nI[n]||nI.alpha;return r(e,t)}const iI={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let aI=null,oI=!1;const Qae=()=>{try{if(iI!==void 0){let{MODE:e,DEV:t}=iI;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 sI(){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 rI(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 yF(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:aI});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:ZF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:aI});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:ZF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:aI});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 ok?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(!aI)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=aI.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(aI=o,n=new ao,n.background=null,t=new _s(-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 ok({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 Q_({transparent:!0}),a.nodes.size===0?i.fragmentNode=yF(0,0,0,0):ie();let u=new Oo(2,2);r=new La(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=()=>{!Qae()||oI||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),oI=!0)},Se=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),aI&&(aI.removeEventListener(`mousemove`,ye),aI.removeEventListener(`touchmove`,ye),aI.removeEventListener(`mousedown`,()=>{x=!0}),aI.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 oa&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}aI=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:cI}=sk;function lI(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:cI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:uI,fract:dI,sin:fI,dot:pI}=sk,mI=e=>dI(fI(pI(e,uI(12.12345,78.12345))).mul(40000.12345)),$ae=(e=.03)=>t=>mI(t).mul(e).mul(.10012345),{vec2:hI}=sk,eoe=(e=hI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=sk,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)},toe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=sk,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)},noe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=sk,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 gI=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}({}),_I,vI;function yI(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 bI(e){return xI(e)===`string`}function xI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function SI(e,{precision:t,unit:n}){return CI(e)?`none`:TI(e,t)+(n??``)}function CI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function wI(e){return CI(e)?0:e}function TI(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 EI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function DI(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*EI[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 OI(e){return e[e.length-1]}function kI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function AI(e,t,n){return(n-e)/(t-e)}function jI(e,t,n){return kI(t[0],t[1],AI(e[0],e[1],n))}function MI(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 NI(e,t,n){return Math.max(Math.min(n,t),e)}function PI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function FI(e,t){return PI(Math.abs(e)**t,e)}function II(e,t){return t===0?0:e/t}function LI(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 RI=Object.freeze({__proto__:null,bisectLeft:LI,clamp:NI,copySign:PI,interpolate:kI,interpolateInv:AI,isNone:CI,isString:bI,last:OI,mapRange:jI,multiplyMatrices:yI,parseCoordGrammar:MI,parseFunction:DI,serializeNumber:SI,skipNone:wI,spow:FI,toPrecision:TI,type:xI,zdiv:II}),zI=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 BI=new zI;var VI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((_I=globalThis)==null||(_I=_I.process)==null||(_I=_I.env)==null||(_I=_I.NODE_ENV)==null?void 0:_I.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 HI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function UI(e){return Array.isArray(e)?e:HI[e]}function WI(e,t,n,r={}){if(e=UI(e),t=UI(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(BI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===HI.D65&&i.W2===HI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===HI.D50&&i.W2===HI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),BI.run(`chromatic-adaptation-end`,i),i.M)return yI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const GI=new Set([`<number>`,`<percentage>`,`<angle>`]);function KI(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=>GI.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]=jI(u,d,r[a])),l});return i}function qI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(BI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=DI(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 XI.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=KI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&VI.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(`--`)&&VI.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 XI.registry?e:n;if(u in XI.registry){var s;let e=(s=XI.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 XI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||OI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=KI(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 XI.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 JI(e){if(Array.isArray(e))return e.map(JI);if(!e)throw TypeError(`Empty color reference`);bI(e)&&(e=qI(e));let t=e.space||e.spaceId;return t instanceof XI||(e.space=XI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const YI=75e-6;var XI=(vI=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=UI(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:ZI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),BI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=YI}={}){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=QI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=QI(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=JI(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=JI(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=xI(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=xI(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=xI(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(`, `)}`)}},gI.defineProperty(vI,`registry`,{}),gI.defineProperty(vI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),vI);function ZI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function QI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=MI(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=jI(i,a,e)),e=SI(e,{precision:t,unit:o}),e})}return e}var $I=new XI({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`]}),eL=class extends XI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=$I,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=yI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=WI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=WI(this.base.white,this.white,t),yI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function tL(e,t){return e=JI(e),!t||e.space.equals(t)?e.coords.slice():(t=XI.get(t),t.from(e))}function nL(e,t){e=JI(e);let{space:n,index:r}=XI.resolveCoord(t,e.space),i=tL(e,n);return i[r]}function rL(e,t,n){return e=JI(e),t=XI.get(t),e.coords=t.to(e.space,n),e}rL.returns=`color`;function iL(e,t,n){if(e=JI(e),arguments.length===2&&xI(arguments[1])===`object`){let t=arguments[1];for(let n in t)iL(e,n,t[n])}else{typeof n==`function`&&(n=n(nL(e,t)));let{space:r,index:i}=XI.resolveCoord(t,e.space),a=tL(e,r);a[i]=n,rL(e,r,a)}return e}iL.returns=`color`;var aL=new XI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:$I,fromBase:e=>WI($I.white,`D50`,e),toBase:e=>WI(`D50`,$I.white,e)});const oL=216/24389,sL=24/116,cL=24389/27;let lL=HI.D50;var uL=new XI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:lL,base:aL,fromBase(e){let t=e.map((e,t)=>e/lL[t]),n=t.map(e=>e>oL?Math.cbrt(e):(cL*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]>sL?t[0]**3:(116*t[0]-16)/cL,e[0]>8?((e[0]+16)/116)**3:e[0]/cL,t[2]>sL?t[2]**3:(116*t[2]-16)/cL];return n.map((e,t)=>e*lL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function dL(e){return(e%360+360)%360}function fL(e,t){if(e===`raw`)return t;let[n,r]=t.map(dL),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 pL=new XI({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:uL,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),dL(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 mL=25**7,hL=Math.PI,gL=180/hL,_L=hL/180;function vL(e){let t=e*e,n=t*t*t*e;return n}function yL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=JI([e,t]);let[a,o,s]=uL.from(e),c=pL.from(uL,[a,o,s])[1],[l,u,d]=uL.from(t),f=pL.from(uL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=vL(p),h=.5*(1-Math.sqrt(m/(m+mL))),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*hL),x<0&&(x+=2*hL),b*=gL,x*=gL;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:VI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*_L/2),oe=(a+l)/2,se=(v+y)/2,ce=vL(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)*_L),pe+=.24*Math.cos(2*le*_L),pe+=.32*Math.cos((3*le+6)*_L),pe-=.2*Math.cos((4*le-63)*_L);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+mL)),_e=-1*Math.sin(2*he*_L)*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 bL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],xL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],SL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],CL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var wL=new XI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:$I,fromBase(e){let t=yI(bL,e),n=t.map(e=>Math.cbrt(e));return yI(SL,n)},toBase(e){let t=yI(CL,e),n=t.map(e=>e**3);return yI(xL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function TL(e,t){[e,t]=JI([e,t]);let[n,r,i]=wL.from(e),[a,o,s]=wL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const EL=75e-6;function DL(e,t,{epsilon:n=EL}={}){e=JI(e),t||=e.space,t=XI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function OL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function kL(e,t,n=`lab`){n=XI.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 AL(e,t){return kL(e,t,`lab`)}const jL=Math.PI,ML=jL/180;function NL(e,t,{l:n=2,c:r=1}={}){[e,t]=JI([e,t]);let[i,a,o]=uL.from(e),[,s,c]=pL.from(uL,[i,a,o]),[l,u,d]=uL.from(t),f=pL.from(uL,[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)*ML)):.36+Math.abs(.4*Math.cos((c+35)*ML));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 PL=203;var FL=new XI({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:$I,fromBase(e){return e.map(e=>Math.max(e*PL,0))},toBase(e){return e.map(e=>Math.max(e/PL,0))}});const IL=1.15,LL=.66,RL=2610/2**14,zL=2**14/2610,BL=3424/2**12,VL=2413/2**7,HL=2392/2**7,UL=1.7*2523/2**5,WL=2**5/(1.7*2523),GL=-.56,KL=16295499532821565e-27,qL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],JL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],YL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],XL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var ZL=new XI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:FL,fromBase(e){let[t,n,r]=e,i=IL*t-(IL-1)*r,a=LL*n-(LL-1)*t,o=yI(qL,[i,a,r]),s=o.map(function(e){let t=BL+VL*(e/1e4)**RL,n=1+HL*(e/1e4)**RL;return(t/n)**UL}),[c,l,u]=yI(YL,s),d=(1+GL)*c/(1+GL*c)-KL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+KL)/(1+GL-GL*(t+KL)),a=yI(XL,[i,n,r]),o=a.map(function(e){let t=BL-e**WL,n=HL*e**WL-VL,r=1e4*(t/n)**zL;return r}),[s,c,l]=yI(JL,o),u=(s+(IL-1)*l)/IL,d=(c+(LL-1)*u)/LL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),QL=new XI({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:ZL,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),dL(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 $L(e,t){[e,t]=JI([e,t]);let[n,r,i]=QL.from(e),[a,o,s]=QL.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 eR=3424/4096,tR=2413/128,nR=2392/128,rR=2610/16384,iR=2523/32,aR=16384/2610,oR=32/2523,sR=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],cR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],lR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],uR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var dR=new XI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:FL,fromBase(e){let t=yI(sR,e);return fR(t)},toBase(e){let t=pR(e);return yI(uR,t)}});function fR(e){let t=e.map(function(e){let t=eR+tR*(e/1e4)**rR,n=1+nR*(e/1e4)**rR;return(t/n)**iR});return yI(cR,t)}function pR(e){let t=yI(lR,e),n=t.map(function(e){let t=Math.max(e**oR-eR,0),n=tR-nR*e**oR;return 1e4*(t/n)**aR});return n}function mR(e,t){[e,t]=JI([e,t]);let[n,r,i]=dR.from(e),[a,o,s]=dR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const hR=HI.D65,gR=.42,_R=1/gR,vR=2*Math.PI,yR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],bR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],xR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],SR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},CR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},wR=180/Math.PI,TR=Math.PI/180;function ER(e,t){let n=e.map(e=>{let n=FI(t*Math.abs(e)*.01,gR);return 400*PI(n,e)/(n+27.13)});return n}function DR(e,t){let n=100/t*27.13**_R;return e.map(e=>{let t=Math.abs(e);return PI(n*FI(t/(400-t),_R),e)})}function OR(e){let t=dL(e);t<=CR.h[0]&&(t+=360);let n=LI(CR.h,t)-1,[r,i]=CR.h.slice(n,n+2),[a,o]=CR.e.slice(n,n+2),s=CR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function kR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=CR.h.slice(n,n+2),[a,o]=CR.e.slice(n,n+2);return dL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function AR(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=yI(yR,o);r=SR[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=>kI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=ER(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const jR=AR(hR,64/Math.PI*.2,20,`average`,!1);function MR(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?kR(e.H)*TR:dL(e.h)*TR;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=FI(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=FI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*FI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*II(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=DR(yI(xR,[d,p,m]).map(e=>e*1/1403),t.fl);return yI(bR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function NR(e,t){let n=e.map(e=>e*100),r=ER(yI(yR,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)%vR+vR)%vR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*II(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=FI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=FI(u/t.aW,.5*t.c*t.z),f=100*FI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=dL(o*wR),_=OR(g),v=50*FI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var PR=new XI({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:$I,fromBase(e){let t=NR(e,jR);return[t.J,t.M,t.h]},toBase(e){return MR({J:e[0],M:e[1],h:e[2]},jR)}});const FR=HI.D65,IR=216/24389,LR=24389/27;function RR(e){let t=e>IR?Math.cbrt(e):(LR*e+16)/116;return 116*t-16}function zR(e){return e>8?((e+16)/116)**3:e/LR}function BR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=zR(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=MR({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 MR({J:o,C:r,h:n},t)}function VR(e,t){let n=RR(e[1]);if(n===0)return[0,0,0];let r=NR(e,HR);return[dL(r.h),r.C,n]}const HR=AR(FR,200/Math.PI*zR(50),zR(50)*100,`average`,!1);var UR=new XI({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:$I,fromBase(e){return VR(e)},toBase(e){return BR(e,HR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const WR=Math.PI/180,GR=[1,.007,.0228];function KR(e){e[1]<0&&(e=UR.fromBase(UR.toBase(e)));let t=Math.log(Math.max(1+GR[2]*e[1]*HR.flRoot,1))/GR[2],n=e[0]*WR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function qR(e,t){[e,t]=JI([e,t]);let[n,r,i]=KR(UR.from(e)),[a,o,s]=KR(UR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var JR={deltaE76:AL,deltaECMC:NL,deltaE2000:yL,deltaEJz:$L,deltaEITP:mR,deltaEOK:TL,deltaEHCT:qR};function YR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const XR={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 ZR(e,{method:t=VI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=JI(e),bI(arguments[1])?n=arguments[1]:n||=e.space,n=XI.get(n),DL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=$R(e,{space:n});else{if(t!==`clip`&&!DL(e,n)){Object.prototype.hasOwnProperty.call(XR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=XR[t]);let s=yL;if(r!==``){for(let e in JR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=JR[e];break}}let c=ZR(ez(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=XI.resolveCoord(a.channel),n=nL(ez(e,t.space),t.id);if(CI(n)&&(n=0),n>=a.max)return ez({space:`xyz-d65`,coords:HI.D65},e.space);if(n<=a.min)return ez({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=XI.resolveCoord(t),c=r.space,l=r.id,u=ez(e,c);u.coords.forEach((e,t)=>{CI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=YR(i),m=f,h=nL(u,l);for(;h-m>p;){let e=OL(u);e=ZR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=nL(u,l):h=nL(u,l),iL(u,l,(m+h)/2)}o=ez(u,n)}else o=c}else o=ez(e,n);if(t===`clip`||!DL(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=ez(o,e.space)),e.coords=o.coords,e}ZR.returns=`color`;const QR={WHITE:{space:wL,coords:[1,0,0]},BLACK:{space:wL,coords:[0,0,0]}};function $R(e,{space:t}={}){let n=.02,r=1e-4;e=JI(e),t||=e.space,t=XI.get(t);let i=XI.get(`oklch`);if(t.isUnbounded)return ez(e,t);let a=ez(e,i),o=a.coords[0];if(o>=1){let n=ez(QR.WHITE,t);return n.alpha=e.alpha,ez(n,t)}if(o<=0){let n=ez(QR.BLACK,t);return n.alpha=e.alpha,ez(n,t)}if(DL(a,t,{epsilon:0}))return ez(a,t);function s(e){let n=ez(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 NI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=OL(a),f=s(d),p=TL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&DL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=TL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function ez(e,t,{inGamut:n}={}){e=JI(e),t=XI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=ZR(i,n===!0?void 0:n)),i}ez.returns=`color`;function tz(e,{precision:t=VI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=JI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??XI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!DL(e)&&(s=ZR(OL(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=>SI(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=SI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const nz=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],rz=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var iz=new eL({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:nz,fromXYZ_M:rz});const az=1.09929682680944,oz=.018053968510807;var sz=new eL({id:`rec2020`,name:`REC.2020`,base:iz,toBase(e){return e.map(function(e){return e<oz*4.5?e/4.5:((e+az-1)/az)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=oz?az*e**.45-(az-1):4.5*e})}});const cz=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],lz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var uz=new eL({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:cz,fromXYZ_M:lz});const dz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var pz=new eL({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:dz,fromXYZ_M:fz}),mz={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 hz=[,,,].fill(`<percentage> | <number>[0, 255]`),gz=[,,,].fill(`<number>[0, 255]`);var _z=new eL({id:`srgb`,name:`sRGB`,base:pz,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:hz},rgb_number:{name:`rgb`,commas:!0,coords:gz,noAlpha:!0},color:{},rgba:{coords:hz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:gz},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=mz.black,t.alpha=0):t.coords=mz[e],t.coords)return t}}}}),vz=new eL({id:`p3`,cssId:`display-p3`,name:`P3`,base:uz,fromBase:_z.fromBase,toBase:_z.toBase});VI.display_space=_z;let yz;if(typeof CSS<`u`&&CSS.supports)for(let e of[uL,sz,vz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=tz(n);if(CSS.supports(`color`,r)){VI.display_space=e;break}}function bz(e,{space:t=VI.display_space,...n}={}){let r=tz(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!VI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(CI)||CI(e.alpha);if(a&&!(yz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=OL(e),i.coords=i.coords.map(wI),i.alpha=wI(i.alpha),r=tz(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=ez(i,t),r=new String(tz(i,n)),r.color=i}return r}function xz(e,t){return e=JI(e),t=JI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function Sz(e){return nL(e,[$I,`y`])}function Cz(e,t){iL(e,[$I,`y`],t)}function wz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return Sz(this)},set(e){Cz(this,e)}})}var Tz=Object.freeze({__proto__:null,getLuminance:Sz,register:wz,setLuminance:Cz});function Ez(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const Dz=.56,Oz=.57,kz=.62,Az=.65,jz=.022,Mz=1.414,Nz=.1,Pz=5e-4,Fz=1.14,Iz=.027,Lz=1.14;function Rz(e){return e>=jz?e:e+(jz-e)**Mz}function zz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Bz(e,t){t=JI(t),e=JI(e);let n,r,i,a,o,s;t=ez(t,`srgb`),[a,o,s]=t.coords;let c=zz(a)*.2126729+zz(o)*.7151522+zz(s)*.072175;e=ez(e,`srgb`),[a,o,s]=e.coords;let l=zz(a)*.2126729+zz(o)*.7151522+zz(s)*.072175,u=Rz(c),d=Rz(l),f=d>u;return Math.abs(d-u)<Pz?r=0:f?(n=d**Dz-u**Oz,r=n*Fz):(n=d**Az-u**kz,r=n*Lz),i=Math.abs(r)<Nz?0:r>0?r-Iz:r+Iz,i*100}function Vz(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Hz=5e4;function Uz(e,t){e=JI(e),t=JI(t);let n=Math.max(Sz(e),0),r=Math.max(Sz(t),0);return r>n&&([n,r]=[r,n]),r===0?Hz:(n-r)/r}function Wz(e,t){e=JI(e),t=JI(t);let n=nL(e,[uL,`l`]),r=nL(t,[uL,`l`]);return Math.abs(n-r)}const Gz=216/24389,Kz=24/116,qz=24389/27;let Jz=HI.D65;var Yz=new XI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Jz,base:$I,fromBase(e){let t=e.map((e,t)=>e/Jz[t]),n=t.map(e=>e>Gz?Math.cbrt(e):(qz*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]>Kz?t[0]**3:(116*t[0]-16)/qz,e[0]>8?((e[0]+16)/116)**3:e[0]/qz,t[2]>Kz?t[2]**3:(116*t[2]-16)/qz];return n.map((e,t)=>e*Jz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Xz=5**.5*.5+.5;function Zz(e,t){e=JI(e),t=JI(t);let n=nL(e,[Yz,`l`]),r=nL(t,[Yz,`l`]),i=Math.abs(n**+Xz-r**+Xz),a=i**(1/Xz)*Math.SQRT2-40;return a<7.5?0:a}var Qz=Object.freeze({__proto__:null,contrastAPCA:Bz,contrastDeltaPhi:Zz,contrastLstar:Wz,contrastMichelson:Vz,contrastWCAG21:Ez,contrastWeber:Uz});function $z(e,t,n={}){bI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(Qz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=JI(e),t=JI(t),Qz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return Qz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function eB(e){let[t,n,r]=tL(e,$I),i=t+15*n+3*r;return[4*t/i,9*n/i]}function tB(e){let[t,n,r]=tL(e,$I),i=t+n+r;return[t/i,n/i]}function nB(e){Object.defineProperty(e.prototype,`uv`,{get(){return eB(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return tB(this)}})}var rB=Object.freeze({__proto__:null,register:nB,uv:eB,xy:tB});function iB(e,t,n={}){bI(n)&&(n={method:n});let{method:r=VI.deltaE,...i}=n;for(let n in JR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return JR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function aB(e,t=.25){let n=XI.get(`oklch`,`lch`),r=[n,`l`];return iL(e,r,e=>e*(1+t))}function oB(e,t=.25){let n=XI.get(`oklch`,`lch`),r=[n,`l`];return iL(e,r,e=>e*(1-t))}var sB=Object.freeze({__proto__:null,darken:oB,lighten:aB});function cB(e,t,n=.5,r={}){[e,t]=[JI(e),JI(t)],xI(n)===`object`&&([n,r]=[.5,n]);let i=uB(e,t,r);return i(n)}function lB(e,t,n={}){let r;dB(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]=[JI(e),JI(t)],r=uB(e,t,c));let l=iB(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=iB(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,iB(o,n.color),iB(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function uB(e,t,n={}){if(dB(e)){let[n,r]=[e,t];return uB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=JI(e),t=JI(t),e=OL(e),t=OL(t);let s={colors:[e,t],options:n};if(r=r?XI.get(r):XI.registry[VI.interpolationSpace]||e.space,i=i?XI.get(i):r,e=ez(e,r),t=ez(t,r),e=ZR(e),t=ZR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[nL(e,a),nL(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=fL(i,[o,s]),iL(e,a,o),iL(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 kI(e,i,n)}),c=kI(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=ez(l,i)),l},{rangeArgs:s})}function dB(e){return xI(e)===`function`&&!!e.rangeArgs}VI.interpolationSpace=`lab`;function fB(e){e.defineFunction(`mix`,cB,{returns:`color`}),e.defineFunction(`range`,uB,{returns:`function<color>`}),e.defineFunction(`steps`,lB,{returns:`array<color>`})}var pB=Object.freeze({__proto__:null,isRange:dB,mix:cB,range:uB,register:fB,steps:lB}),mB=new XI({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:_z,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}}}),hB=new XI({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:mB,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>`]}}}),gB=new XI({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:hB,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 _B=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],vB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var yB=new eL({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:_B,fromXYZ_M:vB}),bB=new eL({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:yB,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 xB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],SB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var CB=new eL({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:aL,toXYZ_M:xB,fromXYZ_M:SB});const wB=1/512,TB=16/512;var EB=new eL({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:CB,toBase(e){return e.map(e=>e<TB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=wB?e**(1/1.8):16*e)}}),DB=new XI({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:wL,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),dL(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 OB=HI.D65;const kB=216/24389,AB=24389/27,[jB,MB]=eB({space:$I,coords:OB});var NB=new XI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:OB,base:$I,fromBase(e){let t=[wI(e[0]),wI(e[1]),wI(e[2])],n=t[1],[r,i]=eB({space:$I,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=kB?AB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-jB),13*a*(i-MB)]},toBase(e){let[t,n,r]=e;if(t===0||CI(t))return[0,0,0];n=wI(n),r=wI(r);let i=n/(13*t)+jB,a=r/(13*t)+MB,o=t<=8?t/AB:((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]`]}}}),PB=new XI({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:NB,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),dL(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 FB=216/24389,IB=24389/27,LB=fz[0][0],RB=fz[0][1],zB=fz[0][2],BB=fz[1][0],VB=fz[1][1],HB=fz[1][2],UB=fz[2][0],WB=fz[2][1],GB=fz[2][2];function KB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function qB(e){let t=(e+16)**3/1560896,n=t>FB?t:e/IB,r=n*(284517*LB-94839*zB),i=n*(838422*zB+769860*RB+731718*LB),a=n*(632260*zB-126452*RB),o=n*(284517*BB-94839*HB),s=n*(838422*HB+769860*VB+731718*BB),c=n*(632260*HB-126452*VB),l=n*(284517*UB-94839*GB),u=n*(838422*GB+769860*WB+731718*UB),d=n*(632260*GB-126452*WB);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 JB(e,t){let n=t/360*Math.PI*2,r=KB(e.r0s,e.r0i,n),i=KB(e.r1s,e.r1i,n),a=KB(e.g0s,e.g0i,n),o=KB(e.g1s,e.g1i,n),s=KB(e.b0s,e.b0i,n),c=KB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var YB=new XI({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:PB,gamutSpace:_z,fromBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=qB(t),a=JB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=qB(r),a=JB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});fz[0][0],fz[0][1],fz[0][2],fz[1][0],fz[1][1],fz[1][2],fz[2][0],fz[2][1],fz[2][2];function XB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function ZB(e){let t=XB(e.r0s,e.r0i),n=XB(e.r1s,e.r1i),r=XB(e.g0s,e.g0i),i=XB(e.g1s,e.g1i),a=XB(e.b0s,e.b0i),o=XB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var QB=new XI({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:PB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=qB(t),r=ZB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[wI(e[0]),wI(e[1]),wI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=qB(r),t=ZB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const $B=203,eV=2610/2**14,tV=2**14/2610,nV=2523/2**5,rV=2**5/2523,iV=3424/2**12,aV=2413/2**7,oV=2392/2**7;var sV=new eL({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:iz,toBase(e){return e.map(function(e){let t=(Math.max(e**rV-iV,0)/(aV-oV*e**rV))**tV;return t*1e4/$B})},fromBase(e){return e.map(function(e){let t=Math.max(e*$B/1e4,0),n=iV+aV*t**eV,r=1+oV*t**eV;return(n/r)**nV})}});const cV=.17883277,lV=.28466892,uV=.55991073,dV=3.7743;var fV=new eL({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:iz,toBase(e){return e.map(function(e){return e<=.5?e**2/3*dV:(Math.exp((e-uV)/cV)+lV)/12*dV})},fromBase(e){return e.map(function(e){return e/=dV,e<=1/12?Math.sqrt(3*e):cV*Math.log(12*e-lV)+uV})}});const pV={};BI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=hV(e.W1,e.W2,e.options.method))}),BI.add(`chromatic-adaptation-end`,e=>{e.M||=hV(e.W1,e.W2,e.options.method)});function mV({id:e,toCone_M:t,fromCone_M:n}){pV[e]=arguments[0]}function hV(e,t,n=`Bradford`){let r=pV[n],[i,a,o]=yI(r.toCone_M,e),[s,c,l]=yI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=yI(u,r.toCone_M),f=yI(r.fromCone_M,d);return f}mV({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]]}),mV({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]]}),mV({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]]}),mV({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(HI,{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]}),HI.ACES=[.32168/.33767,1,.34065/.33767];const gV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],_V=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var vV=new eL({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:HI.ACES,toXYZ_M:gV,fromXYZ_M:_V});const yV=2**-16,bV=-.35828683,xV=(Math.log2(65504)+9.72)/17.52;var SV=new eL({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[bV,xV],name:`Red`},g:{range:[bV,xV],name:`Green`},b:{range:[bV,xV],name:`Blue`}},referred:`scene`,base:vV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-yV)*2:e<xV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(yV)+9.72)/17.52:e<yV?(Math.log2(yV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),CV=Object.freeze({__proto__:null,A98RGB:bB,A98RGB_Linear:yB,ACEScc:SV,ACEScg:vV,CAM16_JMh:PR,HCT:UR,HPLuv:QB,HSL:mB,HSLuv:YB,HSV:hB,HWB:gB,ICTCP:dR,JzCzHz:QL,Jzazbz:ZL,LCH:pL,LCHuv:PB,Lab:uL,Lab_D65:Yz,Luv:NB,OKLCH:DB,OKLab:wL,P3:vz,P3_Linear:uz,ProPhoto:EB,ProPhoto_Linear:CB,REC_2020:sz,REC_2020_Linear:iz,REC_2100_HLG:fV,REC_2100_PQ:sV,XYZ_ABS_D65:FL,XYZ_D50:aL,XYZ_D65:$I,sRGB:_z,sRGB_Linear:pz}),wV=class e{constructor(...e){let t;e.length===1&&(t=JI(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:XI.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=bz(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])}};wV.defineFunctions({get:nL,getAll:tL,set:iL,setAll:rL,to:ez,equals:xz,inGamut:DL,toGamut:ZR,distance:kL,toString:tz}),Object.assign(wV,{util:RI,hooks:BI,WHITES:HI,Space:XI,spaces:XI.registry,parse:qI,defaults:VI});for(let e of Object.keys(CV))XI.register(CV[e]);for(let e in XI.registry)TV(e,XI.registry[e]);BI.add(`colorspace-init-end`,e=>{var t,n;TV(e.id,e),(t=n=e.aliases)?.forEach(t=>{TV(t,e)})});function TV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(wV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return XI.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}=XI.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}=XI.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})}wV.extend(JR),wV.extend({deltaE:iB}),Object.assign(wV,{deltaEMethods:JR}),wV.extend(sB),wV.extend({contrast:$z}),wV.extend(rB),wV.extend(Tz),wV.extend(pB),wV.extend(Qz);const{vec2:EV,vec4:DV}=sk,OV=e=>{let t=new wV(e);return DV(...t.to(`p3-linear`).coords,t.alpha).value},kV=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 EV(t,1-n).value},{vec2:AV,viewportSize:jV}=sk,MV=(e=AV(0))=>{let t=jV,n=t.x.div(t.y),r=e.x.mul(n);return AV(r,e.y)},NV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:OV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:OV,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:kV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=sk,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=MV(o()),l=MV(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 PV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${NV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(NV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=lI(NV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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,NV.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`)}}),FV=PV;const IV={name:`FilmGrain`,props:{intensity:{type:Number,default:.25,description:`Grain intensity (0-1)`},power:{type:Number,default:.645,description:`Controls blending based on brightness`},speed:{type:Number,default:.5,description:`Animation speed of grain noise`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||yF(0,0,0,0),r=uF(),i=e=>pM(qN(Xj(e,_F(12.9898,78.233))).mul(43758.5453)),a=e=>Xj(e,yF(.299,.587,.114,0)),o=i(r).add(AP.mul(e.speed.uniform)),s=pM(qN(o.mul(43758.5453))),c=LM(uM(.5),uM(.75),s).mul(e.intensity.uniform),l=VM(a(n),e.power.uniform),u=n.mul(c),d=lj(l,0,1),f=LM(u,n,d);return yF(f.x,f.y,f.z,n.w)}};var LV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{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=lI(IV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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}=sk;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=lI(BV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> 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`],roe=[...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),ioe=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
397
|
|
|
398
398
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
399
399
|
|