shaders 0.0.1 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/dist/react/components/Circle.d.ts +22 -0
- package/dist/react/components/Circle.d.ts.map +1 -0
- package/dist/react/components/GlassTiles.d.ts +22 -0
- package/dist/react/components/GlassTiles.d.ts.map +1 -0
- package/dist/react/components/Grayscale.d.ts +22 -0
- package/dist/react/components/Grayscale.d.ts.map +1 -0
- package/dist/react/components/HueShift.d.ts +22 -0
- package/dist/react/components/HueShift.d.ts.map +1 -0
- package/dist/react/components/Invert.d.ts +22 -0
- package/dist/react/components/Invert.d.ts.map +1 -0
- package/dist/react/components/LinearGradient.d.ts +22 -0
- package/dist/react/components/LinearGradient.d.ts.map +1 -0
- package/dist/react/components/Posterize.d.ts +22 -0
- package/dist/react/components/Posterize.d.ts.map +1 -0
- package/dist/react/components/Saturation.d.ts +22 -0
- package/dist/react/components/Saturation.d.ts.map +1 -0
- package/dist/react/components/SolidColor.d.ts +22 -0
- package/dist/react/components/SolidColor.d.ts.map +1 -0
- package/dist/react/components/Twirl.d.ts +22 -0
- package/dist/react/components/Twirl.d.ts.map +1 -0
- package/dist/react/components/Vibrance.d.ts +22 -0
- package/dist/react/components/Vibrance.d.ts.map +1 -0
- package/dist/react/engine/Ombre.d.ts +22 -0
- package/dist/react/engine/Ombre.d.ts.map +1 -0
- package/dist/react/engine/component.template.d.ts +22 -0
- package/dist/react/engine/component.template.d.ts.map +1 -0
- package/dist/react/index.cjs +168 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +35833 -0
- package/dist/react/index.js.map +1 -0
- package/dist/svelte/components/Circle.svelte +202 -0
- package/dist/svelte/components/Circle.svelte.d.ts +39 -0
- package/dist/svelte/components/GlassTiles.svelte +202 -0
- package/dist/svelte/components/GlassTiles.svelte.d.ts +39 -0
- package/dist/svelte/components/Grayscale.svelte +202 -0
- package/dist/svelte/components/Grayscale.svelte.d.ts +39 -0
- package/dist/svelte/components/HueShift.svelte +202 -0
- package/dist/svelte/components/HueShift.svelte.d.ts +39 -0
- package/dist/svelte/components/Invert.svelte +202 -0
- package/dist/svelte/components/Invert.svelte.d.ts +39 -0
- package/dist/svelte/components/LinearGradient.svelte +202 -0
- package/dist/svelte/components/LinearGradient.svelte.d.ts +39 -0
- package/dist/svelte/components/Posterize.svelte +202 -0
- package/dist/svelte/components/Posterize.svelte.d.ts +39 -0
- package/dist/svelte/components/Saturation.svelte +202 -0
- package/dist/svelte/components/Saturation.svelte.d.ts +39 -0
- package/dist/svelte/components/SolidColor.svelte +202 -0
- package/dist/svelte/components/SolidColor.svelte.d.ts +39 -0
- package/dist/svelte/components/Twirl.svelte +202 -0
- package/dist/svelte/components/Twirl.svelte.d.ts +39 -0
- package/dist/svelte/components/Vibrance.svelte +202 -0
- package/dist/svelte/components/Vibrance.svelte.d.ts +39 -0
- package/dist/svelte/engine/Ombre.svelte +101 -0
- package/dist/svelte/engine/Ombre.svelte.d.ts +31 -0
- package/dist/svelte/engine/component.template.svelte +202 -0
- package/dist/svelte/engine/component.template.svelte.d.ts +39 -0
- package/dist/svelte/index.d.ts +12 -0
- package/dist/svelte/index.js +12 -0
- package/dist/vue/components/Circle.vue.d.ts +51 -0
- package/dist/vue/components/Circle.vue.d.ts.map +1 -0
- package/dist/vue/components/GlassTiles.vue.d.ts +51 -0
- package/dist/vue/components/GlassTiles.vue.d.ts.map +1 -0
- package/dist/vue/components/Grayscale.vue.d.ts +51 -0
- package/dist/vue/components/Grayscale.vue.d.ts.map +1 -0
- package/dist/vue/components/HueShift.vue.d.ts +51 -0
- package/dist/vue/components/HueShift.vue.d.ts.map +1 -0
- package/dist/vue/components/Invert.vue.d.ts +51 -0
- package/dist/vue/components/Invert.vue.d.ts.map +1 -0
- package/dist/vue/components/LinearGradient.vue.d.ts +51 -0
- package/dist/vue/components/LinearGradient.vue.d.ts.map +1 -0
- package/dist/vue/components/Posterize.vue.d.ts +51 -0
- package/dist/vue/components/Posterize.vue.d.ts.map +1 -0
- package/dist/vue/components/Saturation.vue.d.ts +51 -0
- package/dist/vue/components/Saturation.vue.d.ts.map +1 -0
- package/dist/vue/components/SolidColor.vue.d.ts +51 -0
- package/dist/vue/components/SolidColor.vue.d.ts.map +1 -0
- package/dist/vue/components/Twirl.vue.d.ts +51 -0
- package/dist/vue/components/Twirl.vue.d.ts.map +1 -0
- package/dist/vue/components/Vibrance.vue.d.ts +51 -0
- package/dist/vue/components/Vibrance.vue.d.ts.map +1 -0
- package/dist/vue/engine/Ombre.vue.d.ts +38 -0
- package/dist/vue/engine/Ombre.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +13 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +456 -0
- package/package.json +34 -7
- package/README.md +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vr=require("react/jsx-runtime"),J=require("react"),Ms=require("shaders-core");var GA=Object.defineProperty,XA=(r,t)=>{for(var e in t)GA(r,e,{get:t[e],enumerable:!0})};const hx="177",YA=0,cd=3,Df=0,Ha=1,Ug=0,Uf=1,cx=100,dx=204,px=205,mx=3,$g=0,$f=0,jg=300,Uu=301,Sd=302,Jv=303,Qv=304,ZA=306,fx=1e3,bu=1001,gx=1002,Xn=1003,Da=1006,op=1008,JA=1008,QA=1009,KA=1013,Kv=1014,tw=1015,Bn=1016,ew=1023,yx=1026,tz=1027,qh=1030,Yn=0,ez=1,_d="",ks="srgb",Ad="srgb-linear",xx="linear",zu="srgb",eo=7680,bx=519,rz=513,zd=35044,vu=35048,ds=2e3,tn=2001;var Ga=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){let s=this._listeners;return s===void 0?!1:s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){let s=this._listeners;if(s===void 0)return;let i=s[t];if(i!==void 0){let n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let s=e[t.type];if(s!==void 0){t.target=this;let i=s.slice(0);for(let n=0,a=i.length;n<a;n++)i[n].call(this,t);t.target=null}}};const dr="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 vx=1234567;const Cu=Math.PI/180,Cd=180/Math.PI;function Hi(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(dr[r&255]+dr[r>>8&255]+dr[r>>16&255]+dr[r>>24&255]+"-"+dr[t&255]+dr[t>>8&255]+"-"+dr[t>>16&15|64]+dr[t>>24&255]+"-"+dr[e&63|128]+dr[e>>8&255]+"-"+dr[e>>16&255]+dr[e>>24&255]+dr[s&255]+dr[s>>8&255]+dr[s>>16&255]+dr[s>>24&255]).toLowerCase()}function _t(r,t,e){return Math.max(t,Math.min(e,r))}function Wg(r,t){return(r%t+t)%t}function sz(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function iz(r,t,e){return r===t?0:(e-r)/(t-r)}function Eu(r,t,e){return(1-e)*r+e*t}function nz(r,t,e,s){return Eu(r,t,1-Math.exp(-e*s))}function az(r,t=1){return t-Math.abs(Wg(r,t*2)-t)}function oz(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function lz(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function uz(r,t){return r+Math.floor(Math.random()*(t-r+1))}function hz(r,t){return r+Math.random()*(t-r)}function cz(r){return r*(.5-Math.random())}function dz(r){r!==void 0&&(vx=r);let t=vx+=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 pz(r){return r*Cu}function mz(r){return r*Cd}function fz(r){return(r&r-1)==0&&r!==0}function gz(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function yz(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function xz(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function $s(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Wt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const rw={DEG2RAD:Cu,RAD2DEG:Cd,generateUUID:Hi,clamp:_t,euclideanModulo:Wg,mapLinear:sz,inverseLerp:iz,lerp:Eu,damp:nz,pingpong:az,smoothstep:oz,smootherstep:lz,randInt:uz,randFloat:hz,randFloatSpread:cz,seededRandom:dz,degToRad:pz,radToDeg:mz,isPowerOfTwo:fz,ceilPowerOfTwo:gz,floorPowerOfTwo:yz,setQuaternionFromProperEuler:xz,normalize:Wt,denormalize:$s};var jt=class sw{constructor(t=0,e=0){sw.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=_t(this.x,t.x,e.x),this.y=_t(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=_t(this.x,t,e),this.y=_t(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(_t(s,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(_t(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ih=class{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,a,o){let l=s[i+0],h=s[i+1],u=s[i+2],c=s[i+3],d=n[a+0],p=n[a+1],m=n[a+2],f=n[a+3];if(o===0){t[e+0]=l,t[e+1]=h,t[e+2]=u,t[e+3]=c;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=m,t[e+3]=f;return}if(c!==f||l!==d||h!==p||u!==m){let x=1-o,b=l*d+h*p+u*m+c*f,w=b>=0?1:-1,S=1-b*b;if(S>2**-52){let V=Math.sqrt(S),z=Math.atan2(V,b*w);x=Math.sin(x*z)/V,o=Math.sin(o*z)/V}let _=o*w;if(l=l*x+d*_,h=h*x+p*_,u=u*x+m*_,c=c*x+f*_,x===1-o){let V=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=V,h*=V,u*=V,c*=V}}t[e]=l,t[e+1]=h,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,s,i,n,a){let o=s[i],l=s[i+1],h=s[i+2],u=s[i+3],c=n[a],d=n[a+1],p=n[a+2],m=n[a+3];return t[e]=o*m+u*c+l*p-h*d,t[e+1]=l*m+u*d+h*c-o*p,t[e+2]=h*m+u*p+o*d-l*c,t[e+3]=u*m-o*c-l*d-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let s=t._x,i=t._y,n=t._z,a=t._order,o=Math.cos,l=Math.sin,h=o(s/2),u=o(i/2),c=o(n/2),d=l(s/2),p=l(i/2),m=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c-d*p*m;break;case"YXZ":this._x=d*u*c+h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c+d*p*m;break;case"ZXY":this._x=d*u*c-h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c-d*p*m;break;case"ZYX":this._x=d*u*c-h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c+d*p*m;break;case"YZX":this._x=d*u*c+h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c-d*p*m;break;case"XZY":this._x=d*u*c-h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,s=e[0],i=e[4],n=e[8],a=e[1],o=e[5],l=e[9],h=e[2],u=e[6],c=e[10],d=s+o+c;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(n-h)*p,this._z=(a-i)*p}else if(s>o&&s>c){let p=2*Math.sqrt(1+s-o-c);this._w=(u-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(n+h)/p}else if(o>c){let p=2*Math.sqrt(1+o-s-c);this._w=(n-h)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+u)/p}else{let p=2*Math.sqrt(1+c-s-o);this._w=(a-i)/p,this._x=(n+h)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<2**-52?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(_t(this.dot(t),-1,1)))}rotateTowards(t,e){let s=this.angleTo(t);if(s===0)return this;let i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x*=t,this._y*=t,this._z*=t,this._w*=t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let s=t._x,i=t._y,n=t._z,a=t._w,o=e._x,l=e._y,h=e._z,u=e._w;return this._x=s*u+a*o+i*h-n*l,this._y=i*u+a*l+n*o-s*h,this._z=n*u+a*h+s*l-i*o,this._w=a*u-s*o-i*l-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let s=this._x,i=this._y,n=this._z,a=this._w,o=a*t._w+s*t._x+i*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=s,this._y=i,this._z=n,this;let l=1-o*o;if(l<=2**-52){let p=1-e;return this._w=p*a+e*this._w,this._x=p*s+e*this._x,this._y=p*i+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}let h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-e)*u)/h,d=Math.sin(e*u)/h;return this._w=a*c+this._w*d,this._x=s*c+this._x*d,this._y=i*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},B=class iw{constructor(t=0,e=0,s=0){iw.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(wx.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(wx.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=_t(this.x,t.x,e.x),this.y=_t(this.y,t.y,e.y),this.z=_t(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=_t(this.x,t,e),this.y=_t(this.y,t,e),this.z=_t(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(_t(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Kp.copy(this).projectOnVector(t),this.sub(Kp)}reflect(t){return this.sub(Kp.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(_t(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Kp=new B,wx=new ih;var Ti=class nw{constructor(t,e,s,i,n,a,o,l,h){nw.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],V=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*V,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*V,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*V,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(tm.makeScale(t,e)),this}rotate(t){return this.premultiply(tm.makeRotation(-t)),this}translate(t,e){return this.premultiply(tm.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const tm=new Ti;function bz(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Mx(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Tx={};function Nx(r){r in Tx||(Tx[r]=!0,console.warn(r))}const Sx=new Ti().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_x=new Ti().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vz(){let r={enabled:!0,workingColorSpace:Ad,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===zu&&(i.r=Gi(i.r),i.g=Gi(i.g),i.b=Gi(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===zu&&(i.r=sl(i.r),i.g=sl(i.g),i.b=sl(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===_d?xx:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return Nx("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return Nx("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[Ad]:{primaries:t,whitePoint:s,transfer:xx,toXYZ:Sx,fromXYZ:_x,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:ks},outputColorSpaceConfig:{drawingBufferColorSpace:ks}},[ks]:{primaries:t,whitePoint:s,transfer:zu,toXYZ:Sx,fromXYZ:_x,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:ks}}}),r}const Me=vz();function Gi(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function sl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}let ro;var wz=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let s;if(t instanceof HTMLCanvasElement)s=t;else{ro===void 0&&(ro=Mx("canvas")),ro.width=t.width,ro.height=t.height;let i=ro.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),s=ro}return s.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=Mx("canvas");e.width=t.width,e.height=t.height;let s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);let i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let a=0;a<n.length;a++)n[a]=Gi(n[a]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(Gi(e[s]/255)*255):e[s]=Gi(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}};let Mz=0;var qg=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Mz++}),this.uuid=Hi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight):e===null?t.set(0,0,0):t.set(e.width,e.height,e.depth||0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?n.push(em(i[a].image)):n.push(em(i[a]))}else n=em(i);s.url=n}return e||(t.images[this.uuid]=s),s}};function em(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?wz.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Tz=0;const rm=new B;var oi=class dd extends Ga{constructor(t=dd.DEFAULT_IMAGE,e=dd.DEFAULT_MAPPING,s=bu,i=bu,n=Da,a=op,o=ew,l=QA,h=dd.DEFAULT_ANISOTROPY,u=_d){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tz++}),this.uuid=Hi(),this.name="",this.source=new qg(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new jt(0,0),this.repeat=new jt(1,1),this.center=new jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ti,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(rm).x}get height(){return this.source.getSize(rm).y}get depth(){return this.source.getSize(rm).z}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let s=t[e];if(s===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[e]=s}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==jg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case fx:t.x-=Math.floor(t.x);break;case bu:t.x=t.x<0?0:1;break;case gx:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x-=Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case fx:t.y-=Math.floor(t.y);break;case bu:t.y=t.y<0?0:1;break;case gx:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y-=Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};oi.DEFAULT_IMAGE=null,oi.DEFAULT_MAPPING=jg,oi.DEFAULT_ANISOTROPY=1;var wr=class aw{constructor(t=0,e=0,s=0,i=1){aw.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,V=(b+1)/2,z=(u+d)/4,A=(c+f)/4,I=(m+x)/4;return S>_&&S>V?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>V?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=I/i):V<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(V),s=A/n,i=I/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=_t(this.x,t.x,e.x),this.y=_t(this.y,t.y,e.y),this.z=_t(this.z,t.z,e.z),this.w=_t(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=_t(this.x,t,e),this.y=_t(this.y,t,e),this.z=_t(this.z,t,e),this.w=_t(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(_t(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}},Ol=class extends Ga{constructor(t=1,e=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Da,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},s),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=s.depth,this.scissor=new wr(0,0,t,e),this.scissorTest=!1,this.viewport=new wr(0,0,t,e);let i={width:t,height:e,depth:s.depth},n=new oi(i);this.textures=[];let a=s.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview}_setTextureOptions(t={}){let e={minFilter:Da,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let i=0,n=this.textures.length;i<n;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=s,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,s=t.textures.length;e<s;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new qg(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Nz=class extends Ol{constructor(t=1,e=1,s={}){super(t,e,s),this.isWebGLRenderTarget=!0}},Sz=class extends oi{constructor(t=null,e=1,s=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:s,depth:i},this.magFilter=Xn,this.minFilter=Xn,this.wrapR=bu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},nh=class{constructor(t=new B(1/0,1/0,1/0),e=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Cs.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(Cs.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let s=Cs.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let s=t.geometry;if(s!==void 0){let n=s.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Cs):Cs.fromBufferAttribute(n,a),Cs.applyMatrix4(t.matrixWorld),this.expandByPoint(Cs);else t.boundingBox===void 0?(s.boundingBox===null&&s.computeBoundingBox(),Hh.copy(s.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),Hh.copy(t.boundingBox)),Hh.applyMatrix4(t.matrixWorld),this.union(Hh)}let i=t.children;for(let n=0,a=i.length;n<a;n++)this.expandByObject(i[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Cs),Cs.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Xl),Gh.subVectors(this.max,Xl),so.subVectors(t.a,Xl),io.subVectors(t.b,Xl),no.subVectors(t.c,Xl),fn.subVectors(io,so),gn.subVectors(no,io),la.subVectors(so,no);let e=[0,-fn.z,fn.y,0,-gn.z,gn.y,0,-la.z,la.y,fn.z,0,-fn.x,gn.z,0,-gn.x,la.z,0,-la.x,-fn.y,fn.x,0,-gn.y,gn.x,0,-la.y,la.x,0];return!sm(e,so,io,no,Gh)||(e=[1,0,0,0,1,0,0,0,1],!sm(e,so,io,no,Gh))?!1:(Xh.crossVectors(fn,gn),e=[Xh.x,Xh.y,Xh.z],sm(e,so,io,no,Gh))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Cs).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Cs).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ci),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}};const Ci=[new B,new B,new B,new B,new B,new B,new B,new B],Cs=new B,Hh=new nh,so=new B,io=new B,no=new B,fn=new B,gn=new B,la=new B,Xl=new B,Gh=new B,Xh=new B,ua=new B;function sm(r,t,e,s,i){for(let n=0,a=r.length-3;n<=a;n+=3){ua.fromArray(r,n);let o=i.x*Math.abs(ua.x)+i.y*Math.abs(ua.y)+i.z*Math.abs(ua.z),l=t.dot(ua),h=e.dot(ua),u=s.dot(ua);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const _z=new nh,Yl=new B,im=new B;var lp=class{constructor(t=new B,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let s=this.center;e===void 0?_z.setFromPoints(t).getCenter(s):s.copy(e);let i=0;for(let n=0,a=t.length;n<a;n++)i=Math.max(i,s.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius*=t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Yl.subVectors(t,this.center);let e=Yl.lengthSq();if(e>this.radius*this.radius){let s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(Yl,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(im.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yl.copy(t.center).add(im)),this.expandByPoint(Yl.copy(t.center).sub(im))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}};const Ei=new B,nm=new B,Yh=new B,yn=new B,am=new B,Zh=new B,om=new B;var Az=class{constructor(t=new B,e=new B(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ei)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Ei.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ei.copy(this.origin).addScaledVector(this.direction,e),Ei.distanceToSquared(t))}distanceSqToSegment(t,e,s,i){nm.copy(t).add(e).multiplyScalar(.5),Yh.copy(e).sub(t).normalize(),yn.copy(this.origin).sub(nm);let n=t.distanceTo(e)*.5,a=-this.direction.dot(Yh),o=yn.dot(this.direction),l=-yn.dot(Yh),h=yn.lengthSq(),u=Math.abs(1-a*a),c,d,p,m;if(u>0)if(c=a*l-o,d=a*o-l,m=n*u,c>=0)if(d>=-m)if(d<=m){let f=1/u;c*=f,d*=f,p=c*(c+a*d+2*o)+d*(a*c+d+2*l)+h}else d=n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;else d=-n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;else d<=-m?(c=Math.max(0,-(-a*n+o)),d=c>0?-n:Math.min(Math.max(-n,-l),n),p=-c*c+d*(d+2*l)+h):d<=m?(c=0,d=Math.min(Math.max(-n,-l),n),p=d*(d+2*l)+h):(c=Math.max(0,-(a*n+o)),d=c>0?n:Math.min(Math.max(-n,-l),n),p=-c*c+d*(d+2*l)+h);else d=a>0?-n:n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(nm).addScaledVector(Yh,d),p}intersectSphere(t,e){Ei.subVectors(t.center,this.origin);let s=Ei.dot(this.direction),i=Ei.dot(Ei)-s*s,n=t.radius*t.radius;if(i>n)return null;let a=Math.sqrt(n-i),o=s-a,l=s+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){let s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0?!0:t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,i,n,a,o,l,h=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,d=this.origin;return h>=0?(s=(t.min.x-d.x)*h,i=(t.max.x-d.x)*h):(s=(t.max.x-d.x)*h,i=(t.min.x-d.x)*h),u>=0?(n=(t.min.y-d.y)*u,a=(t.max.y-d.y)*u):(n=(t.max.y-d.y)*u,a=(t.min.y-d.y)*u),s>a||n>i||((n>s||isNaN(s))&&(s=n),(a<i||isNaN(i))&&(i=a),c>=0?(o=(t.min.z-d.z)*c,l=(t.max.z-d.z)*c):(o=(t.max.z-d.z)*c,l=(t.min.z-d.z)*c),s>l||o>i)||((o>s||s!==s)&&(s=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(s>=0?s:i,e)}intersectsBox(t){return this.intersectBox(t,Ei)!==null}intersectTriangle(t,e,s,i,n){am.subVectors(e,t),Zh.subVectors(s,t),om.crossVectors(am,Zh);let a=this.direction.dot(om),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;yn.subVectors(this.origin,t);let l=o*this.direction.dot(Zh.crossVectors(yn,Zh));if(l<0)return null;let h=o*this.direction.dot(am.cross(yn));if(h<0||l+h>a)return null;let u=-o*yn.dot(om);return u<0?null:this.at(u/a,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Lt=class jf{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){jf.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,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=x,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 jf().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/ao.setFromMatrixColumn(t,0).length(),n=1/ao.setFromMatrixColumn(t,1).length(),a=1/ao.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(zz,t,Cz)}lookAt(t,e,s){let i=this.elements;return Br.subVectors(t,e),Br.lengthSq()===0&&(Br.z=1),Br.normalize(),xn.crossVectors(s,Br),xn.lengthSq()===0&&(Math.abs(s.z)===1?Br.x+=1e-4:Br.z+=1e-4,Br.normalize(),xn.crossVectors(s,Br)),xn.normalize(),Jh.crossVectors(Br,xn),i[0]=xn.x,i[4]=Jh.x,i[8]=Br.x,i[1]=xn.y,i[5]=Jh.y,i[9]=Br.y,i[2]=xn.z,i[6]=Jh.z,i[10]=Br.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],V=s[15],z=i[0],A=i[4],I=i[8],et=i[12],nt=i[1],it=i[5],vt=i[9],mt=i[13],Rt=i[2],Vt=i[6],Yt=i[10],se=i[14],te=i[3],ft=i[7],bt=i[11],Et=i[15];return n[0]=a*z+o*nt+l*Rt+h*te,n[4]=a*A+o*it+l*Vt+h*ft,n[8]=a*I+o*vt+l*Yt+h*bt,n[12]=a*et+o*mt+l*se+h*Et,n[1]=u*z+c*nt+d*Rt+p*te,n[5]=u*A+c*it+d*Vt+p*ft,n[9]=u*I+c*vt+d*Yt+p*bt,n[13]=u*et+c*mt+d*se+p*Et,n[2]=m*z+f*nt+x*Rt+b*te,n[6]=m*A+f*it+x*Vt+b*ft,n[10]=m*I+f*vt+x*Yt+b*bt,n[14]=m*et+f*mt+x*se+b*Et,n[3]=w*z+S*nt+_*Rt+V*te,n[7]=w*A+S*it+_*Vt+V*ft,n[11]=w*I+S*vt+_*Yt+V*bt,n[15]=w*et+S*mt+_*se+V*Et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,V=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*V;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=V*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,V=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*V,i[1]=(p+_)*V,i[2]=(m-S)*V,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=ao.set(i[0],i[1],i[2]).length(),a=ao.set(i[4],i[5],i[6]).length(),o=ao.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Es.copy(this);let h=1/n,u=1/a,c=1/o;return Es.elements[0]*=h,Es.elements[1]*=h,Es.elements[2]*=h,Es.elements[4]*=u,Es.elements[5]*=u,Es.elements[6]*=u,Es.elements[8]*=c,Es.elements[9]*=c,Es.elements[10]*=c,e.setFromRotationMatrix(Es),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=ds){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===ds)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===tn)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,s,i,n,a,o=ds){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===ds)m=(a+n)*c,f=-2*c;else if(o===tn)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const ao=new B,Es=new Lt,zz=new B(0,0,0),Cz=new B(1,1,1),xn=new B,Jh=new B,Br=new B,Ax=new Lt,zx=new ih;var mi=class ow{constructor(t=0,e=0,s=0,i=ow.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){let i=t.elements,n=i[0],a=i[4],o=i[8],l=i[1],h=i[5],u=i[9],c=i[2],d=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(_t(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-_t(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(_t(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-_t(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(_t(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-_t(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return Ax.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ax,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return zx.setFromEuler(this),this.setFromQuaternion(zx,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};mi.DEFAULT_ORDER="XYZ";var Ez=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!=0}};let Vz=0;const Cx=new B,oo=new ih,Vi=new Lt,Qh=new B,Zl=new B,Rz=new B,Lz=new ih,Ex=new B(1,0,0),Vx=new B(0,1,0),Rx=new B(0,0,1),Lx={type:"added"},Iz={type:"removed"},lo={type:"childadded",child:null},lm={type:"childremoved",child:null};var Xi=class pd extends Ga{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vz++}),this.uuid=Hi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pd.DEFAULT_UP.clone();let t=new B,e=new mi,s=new ih,i=new B(1,1,1);function n(){s.setFromEuler(e,!1)}function a(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Lt},normalMatrix:{value:new Ti}}),this.matrix=new Lt,this.matrixWorld=new Lt,this.matrixAutoUpdate=pd.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=pd.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ez,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(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return oo.setFromAxisAngle(t,e),this.quaternion.multiply(oo),this}rotateOnWorldAxis(t,e){return oo.setFromAxisAngle(t,e),this.quaternion.premultiply(oo),this}rotateX(t){return this.rotateOnAxis(Ex,t)}rotateY(t){return this.rotateOnAxis(Vx,t)}rotateZ(t){return this.rotateOnAxis(Rx,t)}translateOnAxis(t,e){return Cx.copy(t).applyQuaternion(this.quaternion),this.position.add(Cx.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ex,t)}translateY(t){return this.translateOnAxis(Vx,t)}translateZ(t){return this.translateOnAxis(Rx,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Vi.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Qh.copy(t):Qh.set(t,e,s);let i=this.parent;this.updateWorldMatrix(!0,!1),Zl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vi.lookAt(Zl,Qh,this.up):Vi.lookAt(Qh,Zl,this.up),this.quaternion.setFromRotationMatrix(Vi),i&&(Vi.extractRotation(i.matrixWorld),oo.setFromRotationMatrix(Vi),this.quaternion.premultiply(oo.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Lx),lo.child=t,this.dispatchEvent(lo),lo.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Iz),lm.child=t,this.dispatchEvent(lm),lm.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Vi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Vi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Vi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Lx),lo.child=t,this.dispatchEvent(lo),lo.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){let n=this.children[s],a=n.getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);let i=this.children;for(let n=0,a=i.length;n<a;n++)i[n].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zl,t,Rz),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zl,Lz,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){let s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){let i=this.children;for(let n=0,a=i.length;n<a;n++)i[n].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let h=0,u=l.length;h<u;h++){let c=l[h];n(t.shapes,c)}else n(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(t.materials,this.material[l]));i.material=o}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];i.animations.push(n(t.animations,l))}}if(e){let o=a(t.geometries),l=a(t.materials),h=a(t.textures),u=a(t.images),c=a(t.shapes),d=a(t.skeletons),p=a(t.animations),m=a(t.nodes);o.length>0&&(s.geometries=o),l.length>0&&(s.materials=l),h.length>0&&(s.textures=h),u.length>0&&(s.images=u),c.length>0&&(s.shapes=c),d.length>0&&(s.skeletons=d),p.length>0&&(s.animations=p),m.length>0&&(s.nodes=m)}return s.object=i,s;function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){let i=t.children[s];this.add(i.clone())}return this}};Xi.DEFAULT_UP=new B(0,1,0),Xi.DEFAULT_MATRIX_AUTO_UPDATE=!0,Xi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Vs=new B,Ri=new B,um=new B,Li=new B,uo=new B,ho=new B,Ix=new B,hm=new B,cm=new B,dm=new B,pm=new wr,mm=new wr,fm=new wr;var Jl=class qo{constructor(t=new B,e=new B,s=new B){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),Vs.subVectors(t,e),i.cross(Vs);let n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,e,s,i,n){Vs.subVectors(i,e),Ri.subVectors(s,e),um.subVectors(t,e);let a=Vs.dot(Vs),o=Vs.dot(Ri),l=Vs.dot(um),h=Ri.dot(Ri),u=Ri.dot(um),c=a*h-o*o;if(c===0)return n.set(0,0,0),null;let d=1/c,p=(h*l-o*u)*d,m=(a*u-o*l)*d;return n.set(1-p-m,m,p)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,Li)===null?!1:Li.x>=0&&Li.y>=0&&Li.x+Li.y<=1}static getInterpolation(t,e,s,i,n,a,o,l){return this.getBarycoord(t,e,s,i,Li)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(n,Li.x),l.addScaledVector(a,Li.y),l.addScaledVector(o,Li.z),l)}static getInterpolatedAttribute(t,e,s,i,n,a){return pm.setScalar(0),mm.setScalar(0),fm.setScalar(0),pm.fromBufferAttribute(t,e),mm.fromBufferAttribute(t,s),fm.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(pm,n.x),a.addScaledVector(mm,n.y),a.addScaledVector(fm,n.z),a}static isFrontFacing(t,e,s,i){return Vs.subVectors(s,e),Ri.subVectors(t,e),Vs.cross(Ri).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Vs.subVectors(this.c,this.b),Ri.subVectors(this.a,this.b),Vs.cross(Ri).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return qo.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return qo.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,n){return qo.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return qo.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return qo.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let s=this.a,i=this.b,n=this.c,a,o;uo.subVectors(i,s),ho.subVectors(n,s),hm.subVectors(t,s);let l=uo.dot(hm),h=ho.dot(hm);if(l<=0&&h<=0)return e.copy(s);cm.subVectors(t,i);let u=uo.dot(cm),c=ho.dot(cm);if(u>=0&&c<=u)return e.copy(i);let d=l*c-u*h;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),e.copy(s).addScaledVector(uo,a);dm.subVectors(t,n);let p=uo.dot(dm),m=ho.dot(dm);if(m>=0&&p<=m)return e.copy(n);let f=p*h-l*m;if(f<=0&&h>=0&&m<=0)return o=h/(h-m),e.copy(s).addScaledVector(ho,o);let x=u*m-p*c;if(x<=0&&c-u>=0&&p-m>=0)return Ix.subVectors(n,i),o=(c-u)/(c-u+(p-m)),e.copy(i).addScaledVector(Ix,o);let b=1/(x+f+d);return a=f*b,o=d*b,e.copy(s).addScaledVector(uo,a).addScaledVector(ho,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}};const lw={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},bn={h:0,s:0,l:0},Kh={h:0,s:0,l:0};function gm(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var Kt=class{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ks){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Me.colorSpaceToWorking(this,e),this}setRGB(t,e,s,i=Me.workingColorSpace){return this.r=t,this.g=e,this.b=s,Me.colorSpaceToWorking(this,i),this}setHSL(t,e,s,i=Me.workingColorSpace){if(t=Wg(t,1),e=_t(e,0,1),s=_t(s,0,1),e===0)this.r=this.g=this.b=s;else{let n=s<=.5?s*(1+e):s+e-s*e,a=2*s-n;this.r=gm(a,n,t+1/3),this.g=gm(a,n,t),this.b=gm(a,n,t-1/3)}return Me.colorSpaceToWorking(this,i),this}setStyle(t,e=ks){function s(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let n,a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let n=i[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ks){let s=lw[t.toLowerCase()];return s===void 0?console.warn("THREE.Color: Unknown color "+t):this.setHex(s,e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Gi(t.r),this.g=Gi(t.g),this.b=Gi(t.b),this}copyLinearToSRGB(t){return this.r=sl(t.r),this.g=sl(t.g),this.b=sl(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ks){return Me.workingToColorSpace(pr.copy(this),t),Math.round(_t(pr.r*255,0,255))*65536+Math.round(_t(pr.g*255,0,255))*256+Math.round(_t(pr.b*255,0,255))}getHexString(t=ks){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Me.workingColorSpace){Me.workingToColorSpace(pr.copy(this),e);let s=pr.r,i=pr.g,n=pr.b,a=Math.max(s,i,n),o=Math.min(s,i,n),l,h,u=(o+a)/2;if(o===a)l=0,h=0;else{let c=a-o;switch(h=u<=.5?c/(a+o):c/(2-a-o),a){case s:l=(i-n)/c+(i<n?6:0);break;case i:l=(n-s)/c+2;break;case n:l=(s-i)/c+4;break}l/=6}return t.h=l,t.s=h,t.l=u,t}getRGB(t,e=Me.workingColorSpace){return Me.workingToColorSpace(pr.copy(this),e),t.r=pr.r,t.g=pr.g,t.b=pr.b,t}getStyle(t=ks){Me.workingToColorSpace(pr.copy(this),t);let e=pr.r,s=pr.g,i=pr.b;return t===ks?`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(i*255)})`:`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`}offsetHSL(t,e,s){return this.getHSL(bn),this.setHSL(bn.h+t,bn.s+e,bn.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(bn),t.getHSL(Kh);let s=Eu(bn.h,Kh.h,e),i=Eu(bn.s,Kh.s,e),n=Eu(bn.l,Kh.l,e);return this.setHSL(s,i,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,s=this.g,i=this.b,n=t.elements;return this.r=n[0]*e+n[3]*s+n[6]*i,this.g=n[1]*e+n[4]*s+n[7]*i,this.b=n[2]*e+n[5]*s+n[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const pr=new Kt;Kt.NAMES=lw;let Pz=0;var Lr=class extends Ga{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Pz++}),this.uuid=Hi(),this.name="",this.type="Material",this.blending=Uf,this.side=Df,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=dx,this.blendDst=px,this.blendEquation=cx,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=mx,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bx,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=eo,this.stencilZFail=eo,this.stencilZPass=eo,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let s=t[e];if(s===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[e]=s}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(t).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(t).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(t).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(t).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(t).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==Uf&&(s.blending=this.blending),this.side!==Df&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==dx&&(s.blendSrc=this.blendSrc),this.blendDst!==px&&(s.blendDst=this.blendDst),this.blendEquation!==cx&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==mx&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==bx&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==eo&&(s.stencilFail=this.stencilFail),this.stencilZFail!==eo&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==eo&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(n){let a=[];for(let o in n){let l=n[o];delete l.metadata,a.push(l)}return a}if(e){let n=i(t.textures),a=i(t.images);n.length>0&&(s.textures=n),a.length>0&&(s.images=a)}return s}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,s=null;if(e!==null){let i=e.length;s=Array(i);for(let n=0;n!==i;++n)s[n]=e[n].clone()}return this.clippingPlanes=s,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Hg=class extends Lr{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kt(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 mi,this.combine=$g,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};Fz();function Fz(){let r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),s=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(s[l]=0,s[l|256]=32768,i[l]=24,i[l|256]=24):h<-14?(s[l]=1024>>-h-14,s[l|256]=1024>>-h-14|32768,i[l]=-h-1,i[l|256]=-h-1):h<=15?(s[l]=h+15<<10,s[l|256]=h+15<<10|32768,i[l]=13,i[l|256]=13):h<128?(s[l]=31744,s[l|256]=64512,i[l]=24,i[l|256]=24):(s[l]=31744,s[l|256]=64512,i[l]=13,i[l|256]=13)}let n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,u=0;for(;!(h&8388608);)h<<=1,u-=8388608;h&=-8388609,u+=947912704,n[l]=h|u}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:e,baseTable:s,shiftTable:i,mantissaTable:n,exponentTable:a,offsetTable:o}}const Ie=new B,tc=new jt;let Oz=0;var ms=class{constructor(r,t,e=!1){if(Array.isArray(r))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Oz++}),this.name="",this.array=r,this.itemSize=t,this.count=r===void 0?0:r.length/t,this.normalized=e,this.usage=zd,this.updateRanges=[],this.gpuType=tw,this.version=0}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,t){this.updateRanges.push({start:r,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.name=r.name,this.array=new r.array.constructor(r.array),this.itemSize=r.itemSize,this.count=r.count,this.normalized=r.normalized,this.usage=r.usage,this.gpuType=r.gpuType,this}copyAt(r,t,e){r*=this.itemSize,e*=t.itemSize;for(let s=0,i=this.itemSize;s<i;s++)this.array[r+s]=t.array[e+s];return this}copyArray(r){return this.array.set(r),this}applyMatrix3(r){if(this.itemSize===2)for(let t=0,e=this.count;t<e;t++)tc.fromBufferAttribute(this,t),tc.applyMatrix3(r),this.setXY(t,tc.x,tc.y);else if(this.itemSize===3)for(let t=0,e=this.count;t<e;t++)Ie.fromBufferAttribute(this,t),Ie.applyMatrix3(r),this.setXYZ(t,Ie.x,Ie.y,Ie.z);return this}applyMatrix4(r){for(let t=0,e=this.count;t<e;t++)Ie.fromBufferAttribute(this,t),Ie.applyMatrix4(r),this.setXYZ(t,Ie.x,Ie.y,Ie.z);return this}applyNormalMatrix(r){for(let t=0,e=this.count;t<e;t++)Ie.fromBufferAttribute(this,t),Ie.applyNormalMatrix(r),this.setXYZ(t,Ie.x,Ie.y,Ie.z);return this}transformDirection(r){for(let t=0,e=this.count;t<e;t++)Ie.fromBufferAttribute(this,t),Ie.transformDirection(r),this.setXYZ(t,Ie.x,Ie.y,Ie.z);return this}set(r,t=0){return this.array.set(r,t),this}getComponent(r,t){let e=this.array[r*this.itemSize+t];return this.normalized&&(e=$s(e,this.array)),e}setComponent(r,t,e){return this.normalized&&(e=Wt(e,this.array)),this.array[r*this.itemSize+t]=e,this}getX(r){let t=this.array[r*this.itemSize];return this.normalized&&(t=$s(t,this.array)),t}setX(r,t){return this.normalized&&(t=Wt(t,this.array)),this.array[r*this.itemSize]=t,this}getY(r){let t=this.array[r*this.itemSize+1];return this.normalized&&(t=$s(t,this.array)),t}setY(r,t){return this.normalized&&(t=Wt(t,this.array)),this.array[r*this.itemSize+1]=t,this}getZ(r){let t=this.array[r*this.itemSize+2];return this.normalized&&(t=$s(t,this.array)),t}setZ(r,t){return this.normalized&&(t=Wt(t,this.array)),this.array[r*this.itemSize+2]=t,this}getW(r){let t=this.array[r*this.itemSize+3];return this.normalized&&(t=$s(t,this.array)),t}setW(r,t){return this.normalized&&(t=Wt(t,this.array)),this.array[r*this.itemSize+3]=t,this}setXY(r,t,e){return r*=this.itemSize,this.normalized&&(t=Wt(t,this.array),e=Wt(e,this.array)),this.array[r+0]=t,this.array[r+1]=e,this}setXYZ(r,t,e,s){return r*=this.itemSize,this.normalized&&(t=Wt(t,this.array),e=Wt(e,this.array),s=Wt(s,this.array)),this.array[r+0]=t,this.array[r+1]=e,this.array[r+2]=s,this}setXYZW(r,t,e,s,i){return r*=this.itemSize,this.normalized&&(t=Wt(t,this.array),e=Wt(e,this.array),s=Wt(s,this.array),i=Wt(i,this.array)),this.array[r+0]=t,this.array[r+1]=e,this.array[r+2]=s,this.array[r+3]=i,this}onUpload(r){return this.onUploadCallback=r,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let r={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(r.name=this.name),this.usage!==zd&&(r.usage=this.usage),r}},Bz=class extends ms{constructor(r,t,e){super(new Uint16Array(r),t,e)}},kz=class extends ms{constructor(r,t,e){super(new Uint32Array(r),t,e)}},il=class extends ms{constructor(r,t,e){super(new Float32Array(r),t,e)}};let Dz=0;const is=new Lt,ym=new Xi,co=new B,kr=new nh,Ql=new nh,er=new B;var up=class uw extends Ga{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Dz++}),this.uuid=Hi(),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(t){return Array.isArray(t)?this.index=new(bz(t)?kz:Bz)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let s=this.attributes.normal;if(s!==void 0){let n=new Ti().getNormalMatrix(t);s.applyNormalMatrix(n),s.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return is.makeRotationFromQuaternion(t),this.applyMatrix4(is),this}rotateX(t){return is.makeRotationX(t),this.applyMatrix4(is),this}rotateY(t){return is.makeRotationY(t),this.applyMatrix4(is),this}rotateZ(t){return is.makeRotationZ(t),this.applyMatrix4(is),this}translate(t,e,s){return is.makeTranslation(t,e,s),this.applyMatrix4(is),this}scale(t,e,s){return is.makeScale(t,e,s),this.applyMatrix4(is),this}lookAt(t){return ym.lookAt(t),ym.updateMatrix(),this.applyMatrix4(ym.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(co).negate(),this.translate(co.x,co.y,co.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let s=[];for(let i=0,n=t.length;i<n;i++){let a=t[i];s.push(a.x,a.y,a.z||0)}this.setAttribute("position",new il(s,3))}else{let s=Math.min(t.length,e.count);for(let i=0;i<s;i++){let n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new nh);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){let n=e[s];kr.setFromBufferAttribute(n),this.morphTargetsRelative?(er.addVectors(this.boundingBox.min,kr.min),this.boundingBox.expandByPoint(er),er.addVectors(this.boundingBox.max,kr.max),this.boundingBox.expandByPoint(er)):(this.boundingBox.expandByPoint(kr.min),this.boundingBox.expandByPoint(kr.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 lp);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new B,1/0);return}if(t){let s=this.boundingSphere.center;if(kr.setFromBufferAttribute(t),e)for(let n=0,a=e.length;n<a;n++){let o=e[n];Ql.setFromBufferAttribute(o),this.morphTargetsRelative?(er.addVectors(kr.min,Ql.min),kr.expandByPoint(er),er.addVectors(kr.max,Ql.max),kr.expandByPoint(er)):(kr.expandByPoint(Ql.min),kr.expandByPoint(Ql.max))}kr.getCenter(s);let i=0;for(let n=0,a=t.count;n<a;n++)er.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(er));if(e)for(let n=0,a=e.length;n<a;n++){let o=e[n],l=this.morphTargetsRelative;for(let h=0,u=o.count;h<u;h++)er.fromBufferAttribute(o,h),l&&(co.fromBufferAttribute(t,h),er.add(co)),i=Math.max(i,s.distanceToSquared(er))}this.boundingSphere.radius=Math.sqrt(i),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 t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let s=e.position,i=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ms(new Float32Array(4*s.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<s.count;I++)o[I]=new B,l[I]=new B;let h=new B,u=new B,c=new B,d=new jt,p=new jt,m=new jt,f=new B,x=new B;function b(I,et,nt){h.fromBufferAttribute(s,I),u.fromBufferAttribute(s,et),c.fromBufferAttribute(s,nt),d.fromBufferAttribute(n,I),p.fromBufferAttribute(n,et),m.fromBufferAttribute(n,nt),u.sub(h),c.sub(h),p.sub(d),m.sub(d);let it=1/(p.x*m.y-m.x*p.y);isFinite(it)&&(f.copy(u).multiplyScalar(m.y).addScaledVector(c,-p.y).multiplyScalar(it),x.copy(c).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(it),o[I].add(f),o[et].add(f),o[nt].add(f),l[I].add(x),l[et].add(x),l[nt].add(x))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let I=0,et=w.length;I<et;++I){let nt=w[I],it=nt.start,vt=nt.count;for(let mt=it,Rt=it+vt;mt<Rt;mt+=3)b(t.getX(mt+0),t.getX(mt+1),t.getX(mt+2))}let S=new B,_=new B,V=new B,z=new B;function A(I){V.fromBufferAttribute(i,I),z.copy(V);let et=o[I];S.copy(et),S.sub(V.multiplyScalar(V.dot(et))).normalize(),_.crossVectors(z,et);let nt=_.dot(l[I]),it=nt<0?-1:1;a.setXYZW(I,S.x,S.y,S.z,it)}for(let I=0,et=w.length;I<et;++I){let nt=w[I],it=nt.start,vt=nt.count;for(let mt=it,Rt=it+vt;mt<Rt;mt+=3)A(t.getX(mt+0)),A(t.getX(mt+1)),A(t.getX(mt+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new ms(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,p=s.count;d<p;d++)s.setXYZ(d,0,0,0);let i=new B,n=new B,a=new B,o=new B,l=new B,h=new B,u=new B,c=new B;if(t)for(let d=0,p=t.count;d<p;d+=3){let m=t.getX(d+0),f=t.getX(d+1),x=t.getX(d+2);i.fromBufferAttribute(e,m),n.fromBufferAttribute(e,f),a.fromBufferAttribute(e,x),u.subVectors(a,n),c.subVectors(i,n),u.cross(c),o.fromBufferAttribute(s,m),l.fromBufferAttribute(s,f),h.fromBufferAttribute(s,x),o.add(u),l.add(u),h.add(u),s.setXYZ(m,o.x,o.y,o.z),s.setXYZ(f,l.x,l.y,l.z),s.setXYZ(x,h.x,h.y,h.z)}else for(let d=0,p=e.count;d<p;d+=3)i.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),u.subVectors(a,n),c.subVectors(i,n),u.cross(c),s.setXYZ(d+0,u.x,u.y,u.z),s.setXYZ(d+1,u.x,u.y,u.z),s.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)er.fromBufferAttribute(t,e),er.normalize(),t.setXYZ(e,er.x,er.y,er.z)}toNonIndexed(){function t(o,l){let h=o.array,u=o.itemSize,c=o.normalized,d=new h.constructor(l.length*u),p=0,m=0;for(let f=0,x=l.length;f<x;f++){p=o.isInterleavedBufferAttribute?l[f]*o.data.stride+o.offset:l[f]*u;for(let b=0;b<u;b++)d[m++]=h[p++]}return new ms(d,u,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new uw,s=this.index.array,i=this.attributes;for(let o in i){let l=i[o],h=t(l,s);e.setAttribute(o,h)}let n=this.morphAttributes;for(let o in n){let l=[],h=n[o];for(let u=0,c=h.length;u<c;u++){let d=h[u],p=t(d,s);l.push(p)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let h=a[o];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let h in l)l[h]!==void 0&&(t[h]=l[h]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let s=this.attributes;for(let l in s){let h=s[l];t.data.attributes[l]=h.toJSON(t.data)}let i={},n=!1;for(let l in this.morphAttributes){let h=this.morphAttributes[l],u=[];for(let c=0,d=h.length;c<d;c++){let p=h[c];u.push(p.toJSON(t.data))}u.length>0&&(i[l]=u,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let s=t.index;s!==null&&this.setIndex(s.clone());let i=t.attributes;for(let h in i){let u=i[h];this.setAttribute(h,u.clone(e))}let n=t.morphAttributes;for(let h in n){let u=[],c=n[h];for(let d=0,p=c.length;d<p;d++)u.push(c[d].clone(e));this.morphAttributes[h]=u}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let h=0,u=a.length;h<u;h++){let c=a[h];this.addGroup(c.start,c.count,c.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const Px=new Lt,ha=new Az,ec=new lp,Fx=new B,rc=new B,sc=new B,ic=new B,xm=new B,nc=new B,Ox=new B,ac=new B;var zl=class extends Xi{constructor(r=new up,t=new Hg){super(),this.isMesh=!0,this.type="Mesh",this.geometry=r,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(r,t){return super.copy(r,t),r.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=r.morphTargetInfluences.slice()),r.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},r.morphTargetDictionary)),this.material=Array.isArray(r.material)?r.material.slice():r.material,this.geometry=r.geometry,this}updateMorphTargets(){let r=this.geometry,t=r.morphAttributes,e=Object.keys(t);if(e.length>0){let s=t[e[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,n=s.length;i<n;i++){let a=s[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=i}}}}getVertexPosition(r,t){let e=this.geometry,s=e.attributes.position,i=e.morphAttributes.position,n=e.morphTargetsRelative;t.fromBufferAttribute(s,r);let a=this.morphTargetInfluences;if(i&&a){nc.set(0,0,0);for(let o=0,l=i.length;o<l;o++){let h=a[o],u=i[o];h!==0&&(xm.fromBufferAttribute(u,r),n?nc.addScaledVector(xm,h):nc.addScaledVector(xm.sub(t),h))}t.add(nc)}return t}raycast(r,t){let e=this.geometry,s=this.material,i=this.matrixWorld;s!==void 0&&(e.boundingSphere===null&&e.computeBoundingSphere(),ec.copy(e.boundingSphere),ec.applyMatrix4(i),ha.copy(r.ray).recast(r.near),!(ec.containsPoint(ha.origin)===!1&&(ha.intersectSphere(ec,Fx)===null||ha.origin.distanceToSquared(Fx)>(r.far-r.near)**2))&&(Px.copy(i).invert(),ha.copy(r.ray).applyMatrix4(Px),!(e.boundingBox!==null&&ha.intersectsBox(e.boundingBox)===!1)&&this._computeIntersections(r,t,ha)))}_computeIntersections(r,t,e){let s,i=this.geometry,n=this.material,a=i.index,o=i.attributes.position,l=i.attributes.uv,h=i.attributes.uv1,u=i.attributes.normal,c=i.groups,d=i.drawRange;if(a!==null)if(Array.isArray(n))for(let p=0,m=c.length;p<m;p++){let f=c[p],x=n[f.materialIndex],b=Math.max(f.start,d.start),w=Math.min(a.count,Math.min(f.start+f.count,d.start+d.count));for(let S=b,_=w;S<_;S+=3){let V=a.getX(S),z=a.getX(S+1),A=a.getX(S+2);s=oc(this,x,r,e,l,h,u,V,z,A),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=f.materialIndex,t.push(s))}}else{let p=Math.max(0,d.start),m=Math.min(a.count,d.start+d.count);for(let f=p,x=m;f<x;f+=3){let b=a.getX(f),w=a.getX(f+1),S=a.getX(f+2);s=oc(this,n,r,e,l,h,u,b,w,S),s&&(s.faceIndex=Math.floor(f/3),t.push(s))}}else if(o!==void 0)if(Array.isArray(n))for(let p=0,m=c.length;p<m;p++){let f=c[p],x=n[f.materialIndex],b=Math.max(f.start,d.start),w=Math.min(o.count,Math.min(f.start+f.count,d.start+d.count));for(let S=b,_=w;S<_;S+=3){let V=S,z=S+1,A=S+2;s=oc(this,x,r,e,l,h,u,V,z,A),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=f.materialIndex,t.push(s))}}else{let p=Math.max(0,d.start),m=Math.min(o.count,d.start+d.count);for(let f=p,x=m;f<x;f+=3){let b=f,w=f+1,S=f+2;s=oc(this,n,r,e,l,h,u,b,w,S),s&&(s.faceIndex=Math.floor(f/3),t.push(s))}}}};function Uz(r,t,e,s,i,n,a,o){let l;if(l=t.side===Ha?s.intersectTriangle(a,n,i,!0,o):s.intersectTriangle(i,n,a,t.side===Df,o),l===null)return null;ac.copy(o),ac.applyMatrix4(r.matrixWorld);let h=e.ray.origin.distanceTo(ac);return h<e.near||h>e.far?null:{distance:h,point:ac.clone(),object:r}}function oc(r,t,e,s,i,n,a,o,l,h){r.getVertexPosition(o,rc),r.getVertexPosition(l,sc),r.getVertexPosition(h,ic);let u=Uz(r,t,e,s,rc,sc,ic,Ox);if(u){let c=new B;Jl.getBarycoord(Ox,rc,sc,ic,c),i&&(u.uv=Jl.getInterpolatedAttribute(i,o,l,h,c,new jt)),n&&(u.uv1=Jl.getInterpolatedAttribute(n,o,l,h,c,new jt)),a&&(u.normal=Jl.getInterpolatedAttribute(a,o,l,h,c,new B),u.normal.dot(s.direction)>0&&u.normal.multiplyScalar(-1));let d={a:o,b:l,c:h,normal:new B,materialIndex:0};Jl.getNormal(rc,sc,ic,d.normal),u.face=d,u.barycoord=c}return u}var Gg=class hw extends up{constructor(t=1,e=1,s=1,i=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:s,widthSegments:i,heightSegments:n,depthSegments:a};let o=this;i=Math.floor(i),n=Math.floor(n),a=Math.floor(a);let l=[],h=[],u=[],c=[],d=0,p=0;m("z","y","x",-1,-1,s,e,t,a,n,0),m("z","y","x",1,-1,s,e,-t,a,n,1),m("x","z","y",1,1,t,s,e,i,a,2),m("x","z","y",1,-1,t,s,-e,i,a,3),m("x","y","z",1,-1,t,e,s,i,n,4),m("x","y","z",-1,-1,t,e,-s,i,n,5),this.setIndex(l),this.setAttribute("position",new il(h,3)),this.setAttribute("normal",new il(u,3)),this.setAttribute("uv",new il(c,2));function m(f,x,b,w,S,_,V,z,A,I,et){let nt=_/A,it=V/I,vt=_/2,mt=V/2,Rt=z/2,Vt=A+1,Yt=I+1,se=0,te=0,ft=new B;for(let bt=0;bt<Yt;bt++){let Et=bt*it-mt;for(let Tr=0;Tr<Vt;Tr++){let zs=Tr*nt-vt;ft[f]=zs*w,ft[x]=Et*S,ft[b]=Rt,h.push(ft.x,ft.y,ft.z),ft[f]=0,ft[x]=0,ft[b]=z>0?1:-1,u.push(ft.x,ft.y,ft.z),c.push(Tr/A),c.push(1-bt/I),se+=1}}for(let bt=0;bt<I;bt++)for(let Et=0;Et<A;Et++){let Tr=d+Et+Vt*bt,zs=d+Et+Vt*(bt+1),Gl=d+(Et+1)+Vt*(bt+1),ei=d+(Et+1)+Vt*bt;l.push(Tr,zs,ei),l.push(zs,Gl,ei),te+=6}o.addGroup(p,te,et),p+=te,d+=se}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hw(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function cw(r){let t={};for(let e in r)for(let s in t[e]={},r[e]){let i=r[e][s];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[e][s]=null):t[e][s]=i.clone():Array.isArray(i)?t[e][s]=i.slice():t[e][s]=i}return t}function $z(r){let t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}var jz=`void main() {
|
|
2
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
+
}`,Wz=`void main() {
|
|
4
|
+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
+
}`,qz=class extends Lr{constructor(r){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jz,this.fragmentShader=Wz,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,r!==void 0&&this.setValues(r)}copy(r){return super.copy(r),this.fragmentShader=r.fragmentShader,this.vertexShader=r.vertexShader,this.uniforms=cw(r.uniforms),this.uniformsGroups=$z(r.uniformsGroups),this.defines=Object.assign({},r.defines),this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.fog=r.fog,this.lights=r.lights,this.clipping=r.clipping,this.extensions=Object.assign({},r.extensions),this.glslVersion=r.glslVersion,this}toJSON(r){let t=super.toJSON(r);for(let s in t.glslVersion=this.glslVersion,t.uniforms={},this.uniforms){let i=this.uniforms[s],n=i.value;n&&n.isTexture?t.uniforms[s]={type:"t",value:n.toJSON(r).uuid}:n&&n.isColor?t.uniforms[s]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[s]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[s]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[s]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[s]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[s]={type:"m4",value:n.toArray()}:t.uniforms[s]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let e={};for(let s in this.extensions)this.extensions[s]===!0&&(e[s]=!0);return Object.keys(e).length>0&&(t.extensions=e),t}},Xg=class extends Xi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Lt,this.projectionMatrix=new Lt,this.projectionMatrixInverse=new Lt,this.coordinateSystem=ds}copy(r,t){return super.copy(r,t),this.matrixWorldInverse.copy(r.matrixWorldInverse),this.projectionMatrix.copy(r.projectionMatrix),this.projectionMatrixInverse.copy(r.projectionMatrixInverse),this.coordinateSystem=r.coordinateSystem,this}getWorldDirection(r){return super.getWorldDirection(r).negate()}updateMatrixWorld(r){super.updateMatrixWorld(r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(r,t){super.updateWorldMatrix(r,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const vn=new B,Bx=new jt,kx=new jt;var wa=class extends Xg{constructor(r=50,t=1,e=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=r,this.zoom=1,this.near=e,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(r,t){return super.copy(r,t),this.fov=r.fov,this.zoom=r.zoom,this.near=r.near,this.far=r.far,this.focus=r.focus,this.aspect=r.aspect,this.view=r.view===null?null:Object.assign({},r.view),this.filmGauge=r.filmGauge,this.filmOffset=r.filmOffset,this}setFocalLength(r){let t=.5*this.getFilmHeight()/r;this.fov=Cd*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let r=Math.tan(Cu*.5*this.fov);return .5*this.getFilmHeight()/r}getEffectiveFOV(){return Cd*2*Math.atan(Math.tan(Cu*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(r,t,e){vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(vn.x,vn.y).multiplyScalar(-r/vn.z),vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vn.x,vn.y).multiplyScalar(-r/vn.z)}getViewSize(r,t){return this.getViewBounds(r,Bx,kx),t.subVectors(kx,Bx)}setViewOffset(r,t,e,s,i,n){this.aspect=r/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=r,this.view.fullHeight=t,this.view.offsetX=e,this.view.offsetY=s,this.view.width=i,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let r=this.near,t=r*Math.tan(Cu*.5*this.fov)/this.zoom,e=2*t,s=this.aspect*e,i=-.5*s,n=this.view;if(this.view!==null&&this.view.enabled){let o=n.fullWidth,l=n.fullHeight;i+=n.offsetX*s/o,t-=n.offsetY*e/l,s*=n.width/o,e*=n.height/l}let a=this.filmOffset;a!==0&&(i+=r*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+s,t,t-e,r,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(r){let t=super.toJSON(r);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 po=-90,mo=1;var dw=class extends Xi{constructor(r,t,e){super(),this.type="CubeCamera",this.renderTarget=e,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new wa(po,mo,r,t);s.layers=this.layers,this.add(s);let i=new wa(po,mo,r,t);i.layers=this.layers,this.add(i);let n=new wa(po,mo,r,t);n.layers=this.layers,this.add(n);let a=new wa(po,mo,r,t);a.layers=this.layers,this.add(a);let o=new wa(po,mo,r,t);o.layers=this.layers,this.add(o);let l=new wa(po,mo,r,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let r=this.coordinateSystem,t=this.children.concat(),[e,s,i,n,a,o]=t;for(let l of t)this.remove(l);if(r===ds)e.up.set(0,1,0),e.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(r===tn)e.up.set(0,-1,0),e.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+r);for(let l of t)this.add(l),l.updateMatrixWorld()}update(r,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:e,activeMipmapLevel:s}=this;this.coordinateSystem!==r.coordinateSystem&&(this.coordinateSystem=r.coordinateSystem,this.updateCoordinateSystem());let[i,n,a,o,l,h]=this.children,u=r.getRenderTarget(),c=r.getActiveCubeFace(),d=r.getActiveMipmapLevel(),p=r.xr.enabled;r.xr.enabled=!1;let m=e.texture.generateMipmaps;e.texture.generateMipmaps=!1,r.setRenderTarget(e,0,s),r.render(t,i),r.setRenderTarget(e,1,s),r.render(t,n),r.setRenderTarget(e,2,s),r.render(t,a),r.setRenderTarget(e,3,s),r.render(t,o),r.setRenderTarget(e,4,s),r.render(t,l),e.texture.generateMipmaps=m,r.setRenderTarget(e,5,s),r.render(t,h),r.setRenderTarget(u,c,d),r.xr.enabled=p,e.texture.needsPMREMUpdate=!0}},Yg=class extends oi{constructor(r=[],t=Uu,e,s,i,n,a,o,l,h){super(r,t,e,s,i,n,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(r){this.image=r}},Hz=class extends Nz{constructor(r=1,t={}){super(r,r,t),this.isWebGLCubeRenderTarget=!0;let e={width:r,height:r,depth:1},s=[e,e,e,e,e,e];this.texture=new Yg(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(r,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 e={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
6
|
+
|
|
7
|
+
varying vec3 vWorldDirection;
|
|
8
|
+
|
|
9
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
10
|
+
|
|
11
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
|
|
17
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
18
|
+
|
|
19
|
+
#include <begin_vertex>
|
|
20
|
+
#include <project_vertex>
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
`,fragmentShader:`
|
|
24
|
+
|
|
25
|
+
uniform sampler2D tEquirect;
|
|
26
|
+
|
|
27
|
+
varying vec3 vWorldDirection;
|
|
28
|
+
|
|
29
|
+
#include <common>
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
|
|
33
|
+
vec3 direction = normalize( vWorldDirection );
|
|
34
|
+
|
|
35
|
+
vec2 sampleUV = equirectUv( direction );
|
|
36
|
+
|
|
37
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
`},s=new Gg(5,5,5),i=new qz({name:"CubemapFromEquirect",uniforms:cw(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:Ha,blending:Ug});i.uniforms.tEquirect.value=t;let n=new zl(s,i),a=t.minFilter;return t.minFilter===op&&(t.minFilter=Da),new dw(1,10,this).update(r,n),t.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(r,t=!0,e=!0,s=!0){let i=r.getRenderTarget();for(let n=0;n<6;n++)r.setRenderTarget(this,n),r.clear(t,e,s);r.setRenderTarget(i)}},Zg=class extends Xi{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 mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(r,t){return super.copy(r,t),r.background!==null&&(this.background=r.background.clone()),r.environment!==null&&(this.environment=r.environment.clone()),r.fog!==null&&(this.fog=r.fog.clone()),this.backgroundBlurriness=r.backgroundBlurriness,this.backgroundIntensity=r.backgroundIntensity,this.backgroundRotation.copy(r.backgroundRotation),this.environmentIntensity=r.environmentIntensity,this.environmentRotation.copy(r.environmentRotation),r.overrideMaterial!==null&&(this.overrideMaterial=r.overrideMaterial.clone()),this.matrixAutoUpdate=r.matrixAutoUpdate,this}toJSON(r){let t=super.toJSON(r);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}},pw=class{constructor(r,t){this.isInterleavedBuffer=!0,this.array=r,this.stride=t,this.count=r===void 0?0:r.length/t,this.usage=zd,this.updateRanges=[],this.version=0,this.uuid=Hi()}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,t){this.updateRanges.push({start:r,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.array=new r.array.constructor(r.array),this.count=r.count,this.stride=r.stride,this.usage=r.usage,this}copyAt(r,t,e){r*=this.stride,e*=t.stride;for(let s=0,i=this.stride;s<i;s++)this.array[r+s]=t.array[e+s];return this}set(r,t=0){return this.array.set(r,t),this}clone(r){r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Hi()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(r.arrayBuffers[this.array.buffer._uuid]),e=new this.constructor(t,this.stride);return e.setUsage(this.usage),e}onUpload(r){return this.onUploadCallback=r,this}toJSON(r){return r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Hi()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.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 Nr=new B;var Gz=class mw{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)Nr.fromBufferAttribute(this,e),Nr.applyMatrix4(t),this.setXYZ(e,Nr.x,Nr.y,Nr.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)Nr.fromBufferAttribute(this,e),Nr.applyNormalMatrix(t),this.setXYZ(e,Nr.x,Nr.y,Nr.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)Nr.fromBufferAttribute(this,e),Nr.transformDirection(t),this.setXYZ(e,Nr.x,Nr.y,Nr.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=$s(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=Wt(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=$s(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=$s(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=$s(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=$s(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),s=Wt(s,this.array),i=Wt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),s=Wt(s,this.array),i=Wt(i,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=n,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 s=0;s<this.count;s++){let i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return new ms(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 mw(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let s=0;s<this.count;s++){let i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Xz=class extends Lr{constructor(r){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Kt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.alphaMap=r.alphaMap,this.rotation=r.rotation,this.sizeAttenuation=r.sizeAttenuation,this.fog=r.fog,this}},nl=class extends ms{constructor(r,t,e,s=1){super(r,t,e),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(r){return super.copy(r),this.meshPerAttribute=r.meshPerAttribute,this}toJSON(){let r=super.toJSON();return r.meshPerAttribute=this.meshPerAttribute,r.isInstancedBufferAttribute=!0,r}};const bm=new B,Yz=new B,Zz=new Ti;var Vn=class{constructor(r=new B(1,0,0),t=0){this.isPlane=!0,this.normal=r,this.constant=t}set(r,t){return this.normal.copy(r),this.constant=t,this}setComponents(r,t,e,s){return this.normal.set(r,t,e),this.constant=s,this}setFromNormalAndCoplanarPoint(r,t){return this.normal.copy(r),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(r,t,e){let s=bm.subVectors(e,t).cross(Yz.subVectors(r,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,r),this}copy(r){return this.normal.copy(r.normal),this.constant=r.constant,this}normalize(){let r=1/this.normal.length();return this.normal.multiplyScalar(r),this.constant*=r,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(r){return this.normal.dot(r)+this.constant}distanceToSphere(r){return this.distanceToPoint(r.center)-r.radius}projectPoint(r,t){return t.copy(r).addScaledVector(this.normal,-this.distanceToPoint(r))}intersectLine(r,t){let e=r.delta(bm),s=this.normal.dot(e);if(s===0)return this.distanceToPoint(r.start)===0?t.copy(r.start):null;let i=-(r.start.dot(this.normal)+this.constant)/s;return i<0||i>1?null:t.copy(r.start).addScaledVector(e,i)}intersectsLine(r){let t=this.distanceToPoint(r.start),e=this.distanceToPoint(r.end);return t<0&&e>0||e<0&&t>0}intersectsBox(r){return r.intersectsPlane(this)}intersectsSphere(r){return r.intersectsPlane(this)}coplanarPoint(r){return r.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(r,t){let e=t||Zz.getNormalMatrix(r),s=this.coplanarPoint(bm).applyMatrix4(r),i=this.normal.applyMatrix3(e).normalize();return this.constant=-s.dot(i),this}translate(r){return this.constant-=r.dot(this.normal),this}equals(r){return r.normal.equals(this.normal)&&r.constant===this.constant}clone(){return new this.constructor().copy(this)}};const ca=new lp,lc=new B;var fw=class{constructor(r=new Vn,t=new Vn,e=new Vn,s=new Vn,i=new Vn,n=new Vn){this.planes=[r,t,e,s,i,n]}set(r,t,e,s,i,n){let a=this.planes;return a[0].copy(r),a[1].copy(t),a[2].copy(e),a[3].copy(s),a[4].copy(i),a[5].copy(n),this}copy(r){let t=this.planes;for(let e=0;e<6;e++)t[e].copy(r.planes[e]);return this}setFromProjectionMatrix(r,t=ds){let e=this.planes,s=r.elements,i=s[0],n=s[1],a=s[2],o=s[3],l=s[4],h=s[5],u=s[6],c=s[7],d=s[8],p=s[9],m=s[10],f=s[11],x=s[12],b=s[13],w=s[14],S=s[15];if(e[0].setComponents(o-i,c-l,f-d,S-x).normalize(),e[1].setComponents(o+i,c+l,f+d,S+x).normalize(),e[2].setComponents(o+n,c+h,f+p,S+b).normalize(),e[3].setComponents(o-n,c-h,f-p,S-b).normalize(),e[4].setComponents(o-a,c-u,f-m,S-w).normalize(),t===ds)e[5].setComponents(o+a,c+u,f+m,S+w).normalize();else if(t===tn)e[5].setComponents(a,u,m,w).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(r){if(r.boundingSphere!==void 0)r.boundingSphere===null&&r.computeBoundingSphere(),ca.copy(r.boundingSphere).applyMatrix4(r.matrixWorld);else{let t=r.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ca.copy(t.boundingSphere).applyMatrix4(r.matrixWorld)}return this.intersectsSphere(ca)}intersectsSprite(r){return ca.center.set(0,0,0),ca.radius=.7071067811865476,ca.applyMatrix4(r.matrixWorld),this.intersectsSphere(ca)}intersectsSphere(r){let t=this.planes,e=r.center,s=-r.radius;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<s)return!1;return!0}intersectsBox(r){let t=this.planes;for(let e=0;e<6;e++){let s=t[e];if(lc.x=s.normal.x>0?r.max.x:r.min.x,lc.y=s.normal.y>0?r.max.y:r.min.y,lc.z=s.normal.z>0?r.max.z:r.min.z,s.distanceToPoint(lc)<0)return!1}return!0}containsPoint(r){let t=this.planes;for(let e=0;e<6;e++)if(t[e].distanceToPoint(r)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};new Lt;new fw;var gw=class extends Lr{constructor(r){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Kt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.linewidth=r.linewidth,this.linecap=r.linecap,this.linejoin=r.linejoin,this.fog=r.fog,this}},Jz=class extends Lr{constructor(r){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Kt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.alphaMap=r.alphaMap,this.size=r.size,this.sizeAttenuation=r.sizeAttenuation,this.fog=r.fog,this}},yw=class extends oi{constructor(r,t){super({width:r,height:t}),this.isFramebufferTexture=!0,this.magFilter=Xn,this.minFilter=Xn,this.generateMipmaps=!1,this.needsUpdate=!0}},ah=class extends oi{constructor(r,t,e=Kv,s,i,n,a=Xn,o=Xn,l,h=yx,u=1){if(h!==yx&&h!==tz)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let c={width:r,height:t,depth:u};super(c,s,i,n,a,o,h,e,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(r){return super.copy(r),this.source=new qg(Object.assign({},r.image)),this.compareFunction=r.compareFunction,this}toJSON(r){let t=super.toJSON(r);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Qz=class extends Lr{constructor(r){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Kt(0),this.transparent=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.fog=r.fog,this}},xw=class extends Lr{constructor(r){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Kt(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 Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(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 mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.defines={STANDARD:""},this.color.copy(r.color),this.roughness=r.roughness,this.metalness=r.metalness,this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.roughnessMap=r.roughnessMap,this.metalnessMap=r.metalnessMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.envMapIntensity=r.envMapIntensity,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}},Kz=class extends xw{constructor(r){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 jt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return _t(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Kt(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 Kt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Kt(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(r)}get anisotropy(){return this._anisotropy}set anisotropy(r){this._anisotropy>0!=r>0&&this.version++,this._anisotropy=r}get clearcoat(){return this._clearcoat}set clearcoat(r){this._clearcoat>0!=r>0&&this.version++,this._clearcoat=r}get iridescence(){return this._iridescence}set iridescence(r){this._iridescence>0!=r>0&&this.version++,this._iridescence=r}get dispersion(){return this._dispersion}set dispersion(r){this._dispersion>0!=r>0&&this.version++,this._dispersion=r}get sheen(){return this._sheen}set sheen(r){this._sheen>0!=r>0&&this.version++,this._sheen=r}get transmission(){return this._transmission}set transmission(r){this._transmission>0!=r>0&&this.version++,this._transmission=r}copy(r){return super.copy(r),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=r.anisotropy,this.anisotropyRotation=r.anisotropyRotation,this.anisotropyMap=r.anisotropyMap,this.clearcoat=r.clearcoat,this.clearcoatMap=r.clearcoatMap,this.clearcoatRoughness=r.clearcoatRoughness,this.clearcoatRoughnessMap=r.clearcoatRoughnessMap,this.clearcoatNormalMap=r.clearcoatNormalMap,this.clearcoatNormalScale.copy(r.clearcoatNormalScale),this.dispersion=r.dispersion,this.ior=r.ior,this.iridescence=r.iridescence,this.iridescenceMap=r.iridescenceMap,this.iridescenceIOR=r.iridescenceIOR,this.iridescenceThicknessRange=[...r.iridescenceThicknessRange],this.iridescenceThicknessMap=r.iridescenceThicknessMap,this.sheen=r.sheen,this.sheenColor.copy(r.sheenColor),this.sheenColorMap=r.sheenColorMap,this.sheenRoughness=r.sheenRoughness,this.sheenRoughnessMap=r.sheenRoughnessMap,this.transmission=r.transmission,this.transmissionMap=r.transmissionMap,this.thickness=r.thickness,this.thicknessMap=r.thicknessMap,this.attenuationDistance=r.attenuationDistance,this.attenuationColor.copy(r.attenuationColor),this.specularIntensity=r.specularIntensity,this.specularIntensityMap=r.specularIntensityMap,this.specularColor.copy(r.specularColor),this.specularColorMap=r.specularColorMap,this}},tC=class extends Lr{constructor(r){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Kt(16777215),this.specular=new Kt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=$g,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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.specular.copy(r.specular),this.shininess=r.shininess,this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.specularMap=r.specularMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.combine=r.combine,this.reflectivity=r.reflectivity,this.refractionRatio=r.refractionRatio,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}},eC=class extends Lr{constructor(r){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.gradientMap=r.gradientMap,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.alphaMap=r.alphaMap,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.fog=r.fog,this}},rC=class extends Lr{constructor(r){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(r)}copy(r){return super.copy(r),this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.flatShading=r.flatShading,this}},sC=class extends Lr{constructor(r){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=$g,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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.specularMap=r.specularMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.combine=r.combine,this.reflectivity=r.reflectivity,this.refractionRatio=r.refractionRatio,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}},iC=class extends Lr{constructor(r){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Kt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new jt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.defines={MATCAP:""},this.color.copy(r.color),this.matcap=r.matcap,this.map=r.map,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.alphaMap=r.alphaMap,this.flatShading=r.flatShading,this.fog=r.fog,this}},nC=class extends gw{constructor(r){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(r)}copy(r){return super.copy(r),this.scale=r.scale,this.dashSize=r.dashSize,this.gapSize=r.gapSize,this}};new Lt;new B;new B;new Lt;new B;new B;var bw=class extends Xg{constructor(r=-1,t=1,e=1,s=-1,i=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=r,this.right=t,this.top=e,this.bottom=s,this.near=i,this.far=n,this.updateProjectionMatrix()}copy(r,t){return super.copy(r,t),this.left=r.left,this.right=r.right,this.top=r.top,this.bottom=r.bottom,this.near=r.near,this.far=r.far,this.zoom=r.zoom,this.view=r.view===null?null:Object.assign({},r.view),this}setViewOffset(r,t,e,s,i,n){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=r,this.view.fullHeight=t,this.view.offsetX=e,this.view.offsetY=s,this.view.width=i,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let r=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),e=(this.right+this.left)/2,s=(this.top+this.bottom)/2,i=e-r,n=e+r,a=s+t,o=s-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=l*this.view.offsetX,n=i+l*this.view.width,a-=h*this.view.offsetY,o=a-h*this.view.height}this.projectionMatrix.makeOrthographic(i,n,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(r){let t=super.toJSON(r);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const vw="\\[\\]\\.:\\/",Jg="[^"+vw+"]",aC="[^"+vw.replace("\\.","")+"]";/((?:WC+[\/:])*)/.source.replace("WC",Jg);/(WCOD+)?/.source.replace("WCOD",aC);/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Jg);/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Jg);var oC=class extends pw{constructor(t,e,s=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){let e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){let e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},lC=class ww{constructor(t,e,s,i){ww.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hx}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hx);const uC="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 hC=class{constructor(r){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(r),this.hasAnimation=r.object.isSkinnedMesh===!0,this.refreshUniforms=uC,this.renderId=0}firstInitialization(r){return this.renderObjects.has(r)===!1?(this.getRenderObjectData(r),!0):!1}needsVelocity(r){let t=r.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(r){let t=this.renderObjects.get(r);if(t===void 0){let{geometry:e,material:s,object:i}=r;if(t={material:this.getMaterialData(s),geometry:{id:e.id,attributes:this.getAttributesData(e.attributes),indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),r.bundle!==null&&(t.version=r.bundle.version),t.material.transmission>0){let{width:n,height:a}=r.context;t.bufferWidth=n,t.bufferHeight=a}this.renderObjects.set(r,t)}return t}getAttributesData(r){let t={};for(let e in r){let s=r[e];t[e]={version:s.version}}return t}containsNode(r){let t=r.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return r.renderer.overrideNodes.modelViewMatrix!==null||r.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(r){let t={};for(let e of this.refreshUniforms){let s=r[e];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[e]={id:s.id,version:s.version}:t[e]=s.clone():t[e]=s)}return t}equals(r){let{object:t,material:e,geometry:s}=r,i=this.getRenderObjectData(r);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let n=i.material;for(let m in n){let f=n[m],x=e[m];if(f.equals!==void 0){if(f.equals(x)===!1)return f.copy(x),!1}else if(x.isTexture===!0){if(f.id!==x.id||f.version!==x.version)return f.id=x.id,f.version=x.version,!1}else if(f!==x)return n[m]=x,!1}if(n.transmission>0){let{width:m,height:f}=r.context;if(i.bufferWidth!==m||i.bufferHeight!==f)return i.bufferWidth=m,i.bufferHeight=f,!1}let a=i.geometry,o=s.attributes,l=a.attributes,h=Object.keys(l),u=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(h.length!==u.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(let m of h){let f=l[m],x=o[m];if(x===void 0)return delete l[m],!1;if(f.version!==x.version)return f.version=x.version,!1}let c=s.index,d=a.indexVersion,p=c?c.version:null;if(d!==p)return a.indexVersion=p,!1;if(a.drawRange.start!==s.drawRange.start||a.drawRange.count!==s.drawRange.count)return a.drawRange.start=s.drawRange.start,a.drawRange.count=s.drawRange.count,!1;if(i.morphTargetInfluences){let m=!1;for(let f=0;f<i.morphTargetInfluences.length;f++)i.morphTargetInfluences[f]!==t.morphTargetInfluences[f]&&(m=!0);if(m)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(r.bundle!==null&&(i.version=r.bundle.version),!0)}needsRefresh(r,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(r)||this.needsVelocity(t.renderer))return!0;let{renderId:e}=t;if(this.renderId!==e)return this.renderId=e,!0;let s=r.object.static===!0,i=r.bundle!==null&&r.bundle.static===!0&&this.getRenderObjectData(r).version===r.bundle.version;return s||i?!1:this.equals(r)!==!0}};function $u(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const cC=r=>$u(r),Mw=r=>$u(r),Tw=(...r)=>$u(r);function Nw(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of Ed(r))e.push($u(s.slice(0,-4)),i.getCacheKey(t));return $u(e)}function*Ed(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}const dC=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Dx=new WeakMap;function pC(r){return dC.get(r)}function Vd(r){if(/[iu]?vec\d/.test(r))return r.startsWith("ivec")?Int32Array:r.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(r)||/float/.test(r))return Float32Array;if(/uint/.test(r))return Uint32Array;if(/int/.test(r))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${r}`)}function Sw(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 9;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function mC(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 12;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function fC(r){if(/float|int|uint/.test(r))return 4;if(/vec2/.test(r))return 8;if(/vec3/.test(r)||/vec4/.test(r))return 16;if(/mat2/.test(r))return 8;if(/mat3/.test(r))return 48;if(/mat4/.test(r))return 64;console.error("THREE.TSL: Unsupported type:",r)}function kn(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function _w(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new Kt(...t):e==="vec2"?new jt(...t):e==="vec3"?new B(...t):e==="vec4"?new wr(...t):e==="mat2"?new lC(...t):e==="mat3"?new Ti(...t):e==="mat4"?new Lt(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Cw(t[0]):null}function Aw(r){let t=Dx.get(r);return t===void 0&&(t={},Dx.set(r,t)),t}function zw(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Cw(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}const wu={VERTEX:"vertex",FRAGMENT:"fragment"},It={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},gC={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ii={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Ew=["fragment","vertex"],yC=["setup","analyze","generate"],xC=[...Ew,"compute"],Bl=["x","y","z","w"],bC={analyze:"setup",generate:"analyze"};let vC=0;var at=class extends Ga{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=It.NONE,this.updateBeforeType=It.NONE,this.updateAfterType=It.NONE,this.uuid=rw.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:vC++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,It.FRAME)}onRenderUpdate(t){return this.onUpdate(t,It.RENDER)}onObjectUpdate(t){return this.onUpdate(t,It.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of Ed(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t||(t=this.version!==this._cacheKeyVersion),(t===!0||this._cacheKey===null)&&(this._cacheKey=Tw(Nw(this,t),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(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){let e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){let e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){let e=t.getNodeProperties(this),s=0;for(let i of this.getChildren())e["node"+s++]=i;return e.outputNode||null}analyze(t,e=null){let s=t.increaseUsage(this);if(this.parents===!0){let i=t.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[t.shaderStage]=i.stages[t.shaderStage]||[],i.stages[t.shaderStage].push(e)}if(s===1){let i=t.getNodeProperties(this);for(let n of Object.values(i))n&&n.isNode===!0&&n.build(t,this)}}generate(t,e){let{outputNode:s}=t.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){let s=this.getShared(t);if(this!==s)return s.build(t,e);let i=t.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[t.buildStage]=!0;let n=bC[t.buildStage];if(n&&i.buildStages[n]!==!0){let l=t.getBuildStage();t.setBuildStage(n),this.build(t),t.setBuildStage(l)}t.addNode(this),t.addChain(this);let a=null,o=t.getBuildStage();if(o==="setup"){this.updateReference(t);let l=t.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(t)||l.outputNode||null;for(let h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){let u=t.getNodeProperties(h);u.parents=u.parents||[],u.parents.push(this)}h.build(t)}}a=l.outputNode}else if(o==="analyze")this.analyze(t,e);else if(o==="generate")if(this.generate.length===1){let h=this.getNodeType(t),u=t.getDataFromNode(this);a=u.snippet,a===void 0?u.generated===void 0?(u.generated=!0,a=this.generate(t)||"",u.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):u.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),a=t.format(a,h,e)}else a=this.generate(t,e)||"";return t.removeChain(this),t.addSequentialNode(this),a}getSerializeChildren(){return Ed(this)}serialize(t){let e=this.getSerializeChildren(),s={};for(let{property:i,index:n,childNode:a}of e)n===void 0?s[i]=a.toJSON(t.meta).uuid:(s[i]===void 0&&(s[i]=Number.isInteger(n)?[]:{}),s[i][n]=a.toJSON(t.meta).uuid);Object.keys(s).length>0&&(t.inputNodes=s)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let s in t.inputNodes)if(Array.isArray(t.inputNodes[s])){let i=[];for(let n of t.inputNodes[s])i.push(e[n]);this[s]=i}else if(typeof t.inputNodes[s]=="object"){let i={};for(let n in t.inputNodes[s]){let a=t.inputNodes[s][n];i[n]=e[a]}this[s]=i}else{let i=t.inputNodes[s];this[s]=e[i]}}}toJSON(t){let{uuid:e,type:s}=this,i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{},nodes:{}});let n=t.nodes[e];n===void 0&&(n={uuid:e,type:s,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(t.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}if(i){let o=a(t.textures),l=a(t.images),h=a(t.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}},Xa=class extends at{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},Vw=class extends at{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},we=class extends at{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},wC=class extends we{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}};const MC=Bl.join("");var Wf=class extends at{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max(Bl.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===MC.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},TC=class extends we{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=Bl[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},NC=class extends we{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=Bl[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},Qg=class extends at{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?kn(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=kn(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=zw(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?_w(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}};const Ux=/float|u?int/;var Qs=class extends Qg{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return Ux.test(e)&&Ux.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},SC=class extends at{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}};let Ua=null;const Zo=new Map;function D(r,t){if(Zo.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);Zo.set(r,t)}const Rw=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=r=>Rw(r).split("").sort().join(""),Lw={setup(r,t){let e=t.shift();return r(oh(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(Ua.assign(e,...s),e);if(Zo.has(t)){let s=Zo.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&Zo.has(t.slice(0,t.length-6))){let s=Zo.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=Rw(t),W(new Wf(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=$x(t.slice(3).toLowerCase()),s=>W(new TC(r,t,W(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=$x(t.slice(4).toLowerCase()),()=>W(new NC(W(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),W(new Wf(r,t));if(/^\d+$/.test(t)===!0)return W(new Xa(e,new Qs(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>W(new SC(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},vm=new WeakMap,jx=new WeakMap,_C=function(r,t=null){let e=kn(r);if(e==="node"){let s=vm.get(r);return s===void 0&&(s=new Proxy(r,Lw),vm.set(r,s),vm.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return W(qf(r,t));if(e==="shader")return C(r)}return r},AC=function(r,t=null){for(let e in r)r[e]=W(r[e],t);return r},zC=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=W(r[s],t);return r},CC=function(r,t=null,e=null,s=null){let i=u=>W(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return t===null?n=(...u)=>i(new r(...Ea(h(u)))):e===null?n=(...u)=>i(new r(t,...Ea(h(u)))):(e=W(e),n=(...u)=>i(new r(t,...Ea(h(u)),e))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n},EC=function(r,...t){return W(new r(...Ea(t)))};var VC=class extends at{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=jx.get(r.constructor);a===void 0&&(a=new WeakMap,jx.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=W(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=W(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=W(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},RC=class extends at{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return oh(r),W(new VC(this,r))}setup(){return this.call()}};const LC=[!1,!0],IC=[0,1,2,3],PC=[-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],Kg=new Map;for(let r of LC)Kg.set(r,new Qs(r));const ty=new Map;for(let r of IC)ty.set(r,new Qs(r,"uint"));const ey=new Map([...ty].map(r=>new Qs(r.value,"int")));for(let r of PC)ey.set(r,new Qs(r,"int"));const hp=new Map([...ey].map(r=>new Qs(r.value)));for(let r of Iw)hp.set(r,new Qs(r));for(let r of Iw)hp.set(-r,new Qs(-r));const cp={bool:Kg,uint:ty,ints:ey,float:hp},Wx=new Map([...Kg,...hp]),qf=(r,t)=>Wx.has(r)?Wx.get(r):r.isNode===!0?r:new Qs(r,t),FC=r=>{try{return r.getNodeType()}catch{return}},De=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[_w(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return W(t.get(e[0]));if(e.length===1){let i=qf(e[0],r);return FC(i)===r?W(i):W(new Vw(i,r))}let s=e.map(i=>qf(i));return W(new wC(s,r))}},ju=r=>typeof r=="object"&&r?r.value:r,Pw=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Jo(r,t){return new Proxy(new RC(r,t),Lw)}const W=(r,t=null)=>_C(r,t),oh=(r,t=null)=>new AC(r,t),Ea=(r,t=null)=>new zC(r,t),H=(...r)=>new CC(...r),Q=(...r)=>new EC(...r);let OC=0;const C=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Jo(r,e),i=(...n)=>{let a;oh(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+OC++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i},Hf=r=>{Ua=r},Fw=()=>Ua,xt=(...r)=>Ua.If(...r),BC=(...r)=>Ua.Switch(...r);function dp(r){return Ua&&Ua.add(r),r}D("toStack",dp);const Ow=new De("color"),v=new De("float",cp.float),T=new De("int",cp.ints),rt=new De("uint",cp.uint),fi=new De("bool",cp.bool),Y=new De("vec2"),Ge=new De("ivec2"),Bw=new De("uvec2"),kw=new De("bvec2"),E=new De("vec3"),Dw=new De("ivec3"),kl=new De("uvec3"),ry=new De("bvec3"),ut=new De("vec4"),Uw=new De("ivec4"),$w=new De("uvec4"),jw=new De("bvec4"),pp=new De("mat2"),Ir=new De("mat3"),Va=new De("mat4"),kC=(r="")=>W(new Qs(r,"string")),DC=r=>W(new Qs(r,"ArrayBuffer"));D("toColor",Ow),D("toFloat",v),D("toInt",T),D("toUint",rt),D("toBool",fi),D("toVec2",Y),D("toIVec2",Ge),D("toUVec2",Bw),D("toBVec2",kw),D("toVec3",E),D("toIVec3",Dw),D("toUVec3",kl),D("toBVec3",ry),D("toVec4",ut),D("toIVec4",Uw),D("toUVec4",$w),D("toBVec4",jw),D("toMat2",pp),D("toMat3",Ir),D("toMat4",Va);const Ww=H(Xa).setParameterLength(2),qw=(r,t)=>W(new Vw(W(r),t)),UC=(r,t)=>W(new Wf(W(r),t));D("element",Ww),D("convert",qw);const $C=r=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),dp(r));D("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),dp(r)));const jC=(...r)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),C(...r));var Ft=class extends at{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const Dl=(r,t)=>W(new Ft(r,t)),Wu=(r,t)=>W(new Ft(r,t,!0)),as=Q(Ft,"vec4","DiffuseColor"),Gf=Q(Ft,"vec3","EmissiveColor"),Hw=Q(Ft,"float","Roughness"),WC=Q(Ft,"float","Metalness"),qC=Q(Ft,"float","Clearcoat"),HC=Q(Ft,"float","ClearcoatRoughness"),Gw=Q(Ft,"vec3","Sheen"),Xw=Q(Ft,"float","SheenRoughness"),Yw=Q(Ft,"float","Iridescence"),GC=Q(Ft,"float","IridescenceIOR"),XC=Q(Ft,"float","IridescenceThickness"),Xf=Q(Ft,"float","AlphaT"),Zw=Q(Ft,"float","Anisotropy"),md=Q(Ft,"vec3","AnisotropyT"),al=Q(Ft,"vec3","AnisotropyB"),Jw=Q(Ft,"color","SpecularColor"),YC=Q(Ft,"float","SpecularF90"),Yf=Q(Ft,"float","Shininess"),ol=Q(Ft,"vec4","Output"),ZC=Q(Ft,"float","dashSize"),JC=Q(Ft,"float","gapSize"),QC=Q(Ft,"float","pointWidth"),KC=Q(Ft,"float","IOR"),tE=Q(Ft,"float","Transmission"),eE=Q(Ft,"float","Thickness"),rE=Q(Ft,"float","AttenuationDistance"),sE=Q(Ft,"color","AttenuationColor"),iE=Q(Ft,"float","Dispersion");var Qw=class extends at{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const Kw=r=>new Qw(r),mp=(r,t=0)=>new Qw(r,!0,t),nE=mp("frame"),Tt=mp("render"),tM=Kw("object");var lh=class extends Qg{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=tM}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const ct=(r,t)=>{let e=Pw(t||r),s=r&&r.isNode===!0?r.node&&r.node.value||r.value:r;return W(new lh(s,e))};var qx=class extends we{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const eM=(...r)=>{let t;if(r.length===1){let e=r[0];t=new qx(null,e.length,e)}else{let e=r[0],s=r[1];t=new qx(e,s)}return W(t)};D("toArray",(r,t)=>eM(Array(t).fill(r)));var aE=class extends we{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return Bl.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const rM=H(aE).setParameterLength(2);D("assign",rM);var oE=class extends we{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(v(0));for(let o=0;o<i.length;o++)t.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(n(v(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const sM=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Ea(t):oh(t[0]),W(new oE(W(r),t)));D("call",sM);const lE={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Ve=class Zf extends we{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new Zf(t,e,s);for(let a=0;a<i.length-1;a++)n=new Zf(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(lE[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===ds;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const Ce=H(Ve,"+").setParameterLength(2,1/0).setName("add"),zt=H(Ve,"-").setParameterLength(2,1/0).setName("sub"),gt=H(Ve,"*").setParameterLength(2,1/0).setName("mul"),Js=H(Ve,"/").setParameterLength(2,1/0).setName("div"),uh=H(Ve,"%").setParameterLength(2).setName("mod"),sy=H(Ve,"==").setParameterLength(2).setName("equal"),iM=H(Ve,"!=").setParameterLength(2).setName("notEqual"),nM=H(Ve,"<").setParameterLength(2).setName("lessThan"),iy=H(Ve,">").setParameterLength(2).setName("greaterThan"),aM=H(Ve,"<=").setParameterLength(2).setName("lessThanEqual"),oM=H(Ve,">=").setParameterLength(2).setName("greaterThanEqual"),lM=H(Ve,"&&").setParameterLength(2,1/0).setName("and"),uM=H(Ve,"||").setParameterLength(2,1/0).setName("or"),hM=H(Ve,"!").setParameterLength(1).setName("not"),cM=H(Ve,"^^").setParameterLength(2).setName("xor"),dM=H(Ve,"&").setParameterLength(2).setName("bitAnd"),pM=H(Ve,"~").setParameterLength(2).setName("bitNot"),mM=H(Ve,"|").setParameterLength(2).setName("bitOr"),fM=H(Ve,"^").setParameterLength(2).setName("bitXor"),gM=H(Ve,"<<").setParameterLength(2).setName("shiftLeft"),yM=H(Ve,">>").setParameterLength(2).setName("shiftRight"),xM=C(([r])=>(r.addAssign(1),r)),bM=C(([r])=>(r.subAssign(1),r)),vM=C(([r])=>{let t=T(r).toConst();return r.addAssign(1),t}),wM=C(([r])=>{let t=T(r).toConst();return r.subAssign(1),t});D("add",Ce),D("sub",zt),D("mul",gt),D("div",Js),D("mod",uh),D("equal",sy),D("notEqual",iM),D("lessThan",nM),D("greaterThan",iy),D("lessThanEqual",aM),D("greaterThanEqual",oM),D("and",lM),D("or",uM),D("not",hM),D("xor",cM),D("bitAnd",dM),D("bitNot",pM),D("bitOr",mM),D("bitXor",fM),D("shiftLeft",gM),D("shiftRight",yM),D("incrementBefore",xM),D("decrementBefore",bM),D("increment",vM),D("decrement",wM);const MM=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),uh(r,t)),TM=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),uh(T(r),T(t)));D("remainder",MM),D("modInt",TM);var F=class ee extends we{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===ee.MAX||t===ee.MIN)&&arguments.length>3){let n=new ee(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new ee(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===ee.LENGTH||e===ee.DISTANCE||e===ee.DOT?"float":e===ee.CROSS?"vec3":e===ee.ALL||e===ee.ANY?"bool":e===ee.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===ee.ONE_MINUS)n=zt(1,e);else if(i===ee.RECIPROCAL)n=Js(1,e);else if(i===ee.DIFFERENCE)n=Jt(zt(e,s));else if(i===ee.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=ut(E(o),0):a=ut(E(a),0);let l=gt(a,o).xyz;n=en(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===ee.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===ee.CROSS?c.push(o.build(t,n),l.build(t,n)):u===ds&&i===ee.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===ds&&(i===ee.MIN||i===ee.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===ee.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===ee.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===tn&&i===ee.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ee.DFDX||i===ee.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};F.ALL="all",F.ANY="any",F.RADIANS="radians",F.DEGREES="degrees",F.EXP="exp",F.EXP2="exp2",F.LOG="log",F.LOG2="log2",F.SQRT="sqrt",F.INVERSE_SQRT="inversesqrt",F.FLOOR="floor",F.CEIL="ceil",F.NORMALIZE="normalize",F.FRACT="fract",F.SIN="sin",F.COS="cos",F.TAN="tan",F.ASIN="asin",F.ACOS="acos",F.ATAN="atan",F.ABS="abs",F.SIGN="sign",F.LENGTH="length",F.NEGATE="negate",F.ONE_MINUS="oneMinus",F.DFDX="dFdx",F.DFDY="dFdy",F.ROUND="round",F.RECIPROCAL="reciprocal",F.TRUNC="trunc",F.FWIDTH="fwidth",F.TRANSPOSE="transpose",F.BITCAST="bitcast",F.EQUALS="equals",F.MIN="min",F.MAX="max",F.STEP="step",F.REFLECT="reflect",F.DISTANCE="distance",F.DIFFERENCE="difference",F.DOT="dot",F.CROSS="cross",F.POW="pow",F.TRANSFORM_DIRECTION="transformDirection",F.MIX="mix",F.CLAMP="clamp",F.REFRACT="refract",F.SMOOTHSTEP="smoothstep",F.FACEFORWARD="faceforward";const NM=v(1e-6),uE=v(1e6),Rd=v(Math.PI),hE=v(Math.PI*2),SM=H(F,F.ALL).setParameterLength(1),_M=H(F,F.ANY).setParameterLength(1),AM=H(F,F.RADIANS).setParameterLength(1),zM=H(F,F.DEGREES).setParameterLength(1),ny=H(F,F.EXP).setParameterLength(1),Cl=H(F,F.EXP2).setParameterLength(1),fp=H(F,F.LOG).setParameterLength(1),li=H(F,F.LOG2).setParameterLength(1),Ni=H(F,F.SQRT).setParameterLength(1),ay=H(F,F.INVERSE_SQRT).setParameterLength(1),ui=H(F,F.FLOOR).setParameterLength(1),gp=H(F,F.CEIL).setParameterLength(1),en=H(F,F.NORMALIZE).setParameterLength(1),cn=H(F,F.FRACT).setParameterLength(1),Xr=H(F,F.SIN).setParameterLength(1),ki=H(F,F.COS).setParameterLength(1),CM=H(F,F.TAN).setParameterLength(1),EM=H(F,F.ASIN).setParameterLength(1),VM=H(F,F.ACOS).setParameterLength(1),oy=H(F,F.ATAN).setParameterLength(1,2),Jt=H(F,F.ABS).setParameterLength(1),qu=H(F,F.SIGN).setParameterLength(1),hi=H(F,F.LENGTH).setParameterLength(1),RM=H(F,F.NEGATE).setParameterLength(1),LM=H(F,F.ONE_MINUS).setParameterLength(1),ly=H(F,F.DFDX).setParameterLength(1),uy=H(F,F.DFDY).setParameterLength(1),IM=H(F,F.ROUND).setParameterLength(1),PM=H(F,F.RECIPROCAL).setParameterLength(1),hy=H(F,F.TRUNC).setParameterLength(1),FM=H(F,F.FWIDTH).setParameterLength(1),OM=H(F,F.TRANSPOSE).setParameterLength(1),cE=H(F,F.BITCAST).setParameterLength(2),BM=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),sy(r,t)),ts=H(F,F.MIN).setParameterLength(2,1/0),ye=H(F,F.MAX).setParameterLength(2,1/0),yp=H(F,F.STEP).setParameterLength(2),kM=H(F,F.REFLECT).setParameterLength(2),DM=H(F,F.DISTANCE).setParameterLength(2),UM=H(F,F.DIFFERENCE).setParameterLength(2),ia=H(F,F.DOT).setParameterLength(2),xp=H(F,F.CROSS).setParameterLength(2),Xs=H(F,F.POW).setParameterLength(2),$M=H(F,F.POW,2).setParameterLength(1),jM=H(F,F.POW,3).setParameterLength(1),WM=H(F,F.POW,4).setParameterLength(1),qM=H(F,F.TRANSFORM_DIRECTION).setParameterLength(2),HM=r=>gt(qu(r),Xs(Jt(r),1/3)),cy=r=>ia(r,r),fe=H(F,F.MIX).setParameterLength(3),gi=(r,t=0,e=1)=>W(new F(F.CLAMP,W(r),W(t),W(e))),GM=r=>gi(r),dy=H(F,F.REFRACT).setParameterLength(3),rn=H(F,F.SMOOTHSTEP).setParameterLength(3),py=H(F,F.FACEFORWARD).setParameterLength(3),XM=C(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=ia(r.xy,Y(t,e)),n=uh(i,Rd);return cn(Xr(n).mul(s))}),YM=(r,t,e)=>fe(t,e,r),ZM=(r,t,e)=>rn(t,e,r),JM=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),oy(r,t)),dE=py,pE=ay;D("all",SM),D("any",_M),D("equals",BM),D("radians",AM),D("degrees",zM),D("exp",ny),D("exp2",Cl),D("log",fp),D("log2",li),D("sqrt",Ni),D("inverseSqrt",ay),D("floor",ui),D("ceil",gp),D("normalize",en),D("fract",cn),D("sin",Xr),D("cos",ki),D("tan",CM),D("asin",EM),D("acos",VM),D("atan",oy),D("abs",Jt),D("sign",qu),D("length",hi),D("lengthSq",cy),D("negate",RM),D("oneMinus",LM),D("dFdx",ly),D("dFdy",uy),D("round",IM),D("reciprocal",PM),D("trunc",hy),D("fwidth",FM),D("atan2",JM),D("min",ts),D("max",ye),D("step",yp),D("reflect",kM),D("distance",DM),D("dot",ia),D("cross",xp),D("pow",Xs),D("pow2",$M),D("pow3",jM),D("pow4",WM),D("transformDirection",qM),D("mix",YM),D("clamp",gi),D("refract",dy),D("smoothstep",ZM),D("faceForward",py),D("difference",UM),D("saturate",GM),D("cbrt",HM),D("transpose",OM),D("rand",XM);var mE=class extends at{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?Dl(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
41
|
+
${r.tab}if ( ${u} ) {
|
|
42
|
+
|
|
43
|
+
`).addFlowTab();let c=n.build(r,e);if(c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),r.removeFlowTab().addFlowCode(r.tab+" "+c+`
|
|
44
|
+
|
|
45
|
+
`+r.tab+"}"),a!==null){r.addFlowCode(` else {
|
|
46
|
+
|
|
47
|
+
`).addFlowTab();let d=a.build(r,e);d&&(l?d=h+" = "+d+";":(d="return "+d+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),d="// "+d))),r.removeFlowTab().addFlowCode(r.tab+" "+d+`
|
|
48
|
+
|
|
49
|
+
`+r.tab+`}
|
|
50
|
+
|
|
51
|
+
`)}else r.addFlowCode(`
|
|
52
|
+
|
|
53
|
+
`);return r.format(h,e,t)}};const Qe=H(mE).setParameterLength(2,3);D("select",Qe);const QM=(...r)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Qe(...r));D("cond",QM);var KM=class extends at{static get type(){return"ContextNode"}constructor(r,t={}){super(),this.isContextNode=!0,this.node=r,this.value=t}getScope(){return this.node.getScope()}getNodeType(r){return this.node.getNodeType(r)}analyze(r){let t=r.getContext();r.setContext({...r.context,...this.value}),this.node.build(r),r.setContext(t)}setup(r){let t=r.getContext();r.setContext({...r.context,...this.value}),this.node.build(r),r.setContext(t)}generate(r,t){let e=r.getContext();r.setContext({...r.context,...this.value});let s=this.node.build(r,t);return r.setContext(e),s}};const my=H(KM).setParameterLength(1,2),tT=(r,t)=>my(r,{label:t});D("context",my),D("label",tT);var fE=class extends at{static get type(){return"VarNode"}constructor(r,t=null,e=!1){super(),this.node=r,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=e,this.parents=!0}getMemberType(r,t){return this.node.getMemberType(r,t)}getElementType(r){return this.node.getElementType(r)}getNodeType(r){return this.node.getNodeType(r)}generate(r){let{node:t,name:e,readOnly:s}=this,{renderer:i}=r,n=i.backend.isWebGPUBackend===!0,a=!1,o=!1;s&&(a=r.isDeterministic(t),o=n?s:a);let l=r.getVectorType(this.getNodeType(r)),h=t.build(r,l),u=r.getVarFromNode(this,e,l,void 0,o),c=r.getPropertyName(u),d=c;if(o)if(n)d=a?`const ${c}`:`let ${c}`;else{let p=r.getArrayCount(t);d=`const ${r.getVar(u.type,c,p)}`}return r.addLineFlowCode(`${d} = ${h}`,this),c}};const fy=H(fE),eT=(r,t=null)=>fy(r,t).toStack(),rT=(r,t=null)=>fy(r,t,!0).toStack();D("toVar",eT),D("toConst",rT);const sT=r=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),fy(r));D("temp",sT);var gE=class extends at{static get type(){return"VaryingNode"}constructor(r,t=null){super(),this.node=r,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(r,t=null){return this.interpolationType=r,this.interpolationSampling=t,this}getHash(r){return this.name||super.getHash(r)}getNodeType(r){return this.node.getNodeType(r)}setupVarying(r){let t=r.getNodeProperties(this),e=t.varying;if(e===void 0){let s=this.name,i=this.getNodeType(r),n=this.interpolationType,a=this.interpolationSampling;t.varying=e=r.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return e.needsInterpolation||(e.needsInterpolation=r.shaderStage==="fragment"),e}setup(r){this.setupVarying(r),r.flowNodeFromShaderStage(wu.VERTEX,this.node)}analyze(r){this.setupVarying(r),r.flowNodeFromShaderStage(wu.VERTEX,this.node)}generate(r){let t=r.getNodeProperties(this),e=this.setupVarying(r);if(t.propertyName===void 0){let s=this.getNodeType(r),i=r.getPropertyName(e,wu.VERTEX);r.flowNodeFromShaderStage(wu.VERTEX,this.node,s,i),t.propertyName=i}return r.getPropertyName(e)}};const fs=H(gE).setParameterLength(1,2),iT=r=>fs(r);D("toVarying",fs),D("toVertexStage",iT),D("varying",(...r)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),fs(...r))),D("vertexStage",(...r)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),fs(...r)));const nT=C(([r])=>{let t=r.mul(.9478672986).add(.0521327014).pow(2.4),e=r.mul(.0773993808),s=r.lessThanEqual(.04045);return fe(t,e,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),aT=C(([r])=>{let t=r.pow(.41666).mul(1.055).sub(.055),e=r.mul(12.92),s=r.lessThanEqual(.0031308);return fe(t,e,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),gy="WorkingColorSpace",yE="OutputColorSpace";var yy=class extends we{static get type(){return"ColorSpaceNode"}constructor(r,t,e){super("vec4"),this.colorNode=r,this.source=t,this.target=e}resolveColorSpace(r,t){return t===gy?Me.workingColorSpace:t===yE?r.context.outputColorSpace||r.renderer.outputColorSpace:t}setup(r){let{colorNode:t}=this,e=this.resolveColorSpace(r,this.source),s=this.resolveColorSpace(r,this.target),i=t;return Me.enabled===!1||e===s||!e||!s||(Me.getTransfer(e)===zu&&(i=ut(nT(i.rgb),i.a)),Me.getPrimaries(e)!==Me.getPrimaries(s)&&(i=ut(Ir(Me._getMatrix(new Ti,e,s)).mul(i.rgb),i.a)),Me.getTransfer(s)===zu&&(i=ut(aT(i.rgb),i.a))),i}};const oT=(r,t)=>W(new yy(W(r),gy,t)),xy=(r,t)=>W(new yy(W(r),t,gy)),xE=(r,t,e)=>W(new yy(W(r),t,e));D("workingToColorSpace",oT),D("colorSpaceToWorking",xy);let bE=class extends Xa{static get type(){return"ReferenceElementNode"}constructor(r,t){super(r,t),this.referenceNode=r,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(r){let t=super.generate(r),e=this.referenceNode.getNodeType(),s=this.getNodeType();return r.format(t,e,s)}};var vE=class extends at{static get type(){return"ReferenceBaseNode"}constructor(r,t,e=null,s=null){super(),this.property=r,this.uniformType=t,this.object=e,this.count=s,this.properties=r.split("."),this.reference=e,this.node=null,this.group=null,this.updateType=It.OBJECT}setGroup(r){return this.group=r,this}element(r){return W(new bE(this,W(r)))}setNodeType(r){let t=ct(null,r).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(r){return this.node===null&&(this.updateReference(r),this.updateValue()),this.node.getNodeType(r)}getValueFromReference(r=this.reference){let{properties:t}=this,e=r[t[0]];for(let s=1;s<t.length;s++)e=e[t[s]];return e}updateReference(r){return this.reference=this.object===null?r.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let r=this.getValueFromReference();Array.isArray(r)?this.node.array=r:this.node.value=r}},wE=class extends vE{static get type(){return"RendererReferenceNode"}constructor(r,t,e=null){super(r,t,e),this.renderer=e,this.setGroup(Tt)}updateReference(r){return this.reference=this.renderer===null?r.renderer:this.renderer,this.reference}};const lT=(r,t,e=null)=>W(new wE(r,t,e));var ME=class extends we{static get type(){return"ToneMappingNode"}constructor(r,t=hT,e=null){super("vec3"),this.toneMapping=r,this.exposureNode=t,this.colorNode=e}customCacheKey(){return Tw(this.toneMapping)}setup(r){let t=this.colorNode||r.context.color,e=this.toneMapping;if(e===$f)return t;let s=null,i=r.renderer.library.getToneMappingFunction(e);return i===null?(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",e),s=t):s=ut(i(t.rgb,this.exposureNode),t.a),s}};const uT=(r,t,e)=>W(new ME(r,W(t),W(e))),hT=lT("toneMappingExposure","float");D("toneMapping",(r,t,e)=>uT(t,e,r));var TE=class extends Qg{static get type(){return"BufferAttributeNode"}constructor(r,t=null,e=0,s=0){super(r,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=e,this.bufferOffset=s,this.usage=zd,this.instanced=!1,this.attribute=null,this.global=!0,r&&r.isBufferAttribute===!0&&(this.attribute=r,this.usage=r.usage,this.instanced=r.isInstancedBufferAttribute)}getHash(r){if(this.bufferStride===0&&this.bufferOffset===0){let t=r.globalCache.getData(this.value);return t===void 0&&(t={node:this},r.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(r){return this.bufferType===null&&(this.bufferType=r.getTypeFromAttribute(this.attribute)),this.bufferType}setup(r){if(this.attribute!==null)return;let t=this.getNodeType(r),e=this.value,s=r.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=e.isInterleavedBuffer===!0?e:new pw(e,i),o=new Gz(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(r){let t=this.getNodeType(r),e=r.getBufferAttributeFromNode(this,t),s=r.getPropertyName(e),i=null;return r.shaderStage==="vertex"||r.shaderStage==="compute"?(this.name=s,i=s):i=fs(this).build(r,t),i}getInputType(){return"bufferAttribute"}setUsage(r){return this.usage=r,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=r),this}setInstanced(r){return this.instanced=r,this}};const hh=(r,t=null,e=0,s=0)=>W(new TE(r,t,e,s)),cT=(r,t=null,e=0,s=0)=>hh(r,t,e,s).setUsage(vu),Ld=(r,t=null,e=0,s=0)=>hh(r,t,e,s).setInstanced(!0),Jf=(r,t=null,e=0,s=0)=>cT(r,t,e,s).setInstanced(!0);D("toAttribute",r=>hh(r.value));var NE=class extends at{static get type(){return"ComputeNode"}constructor(r,t,e=[64]){super("void"),this.isComputeNode=!0,this.computeNode=r,this.count=t,this.workgroupSize=e,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=It.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(r){return this.name=r,this}updateDispatchCount(){let{count:r,workgroupSize:t}=this,e=t[0];for(let s=1;s<t.length;s++)e*=t[s];this.dispatchCount=Math.ceil(r/e)}onInit(r){return this.onInitFunction=r,this}updateBefore({renderer:r}){r.compute(this)}setup(r){let t=this.computeNode.build(r);if(t){let e=r.getNodeProperties(this);e.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(r,t){let{shaderStage:e}=r;if(e==="compute"){let s=this.computeNode.build(r,"void");s!==""&&r.addLineFlowCode(s,this)}else{let s=r.getNodeProperties(this),i=s.outputComputeNode;if(i)return i.build(r,t)}}};const dT=(r,t,e)=>W(new NE(W(r),t,e));D("compute",dT);var SE=class extends at{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){let e=t.getCache(),s=t.getCacheFromNode(this,this.parent);t.setCache(s);let i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){let s=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);let n=this.node.build(t,...e);return t.setCache(s),n}};const pT=(r,t)=>W(new SE(W(r),t)),mT=(r,t)=>r.context({namespace:t});D("cache",pT);var _E=class extends at{static get type(){return"BypassNode"}constructor(r,t){super(),this.isBypassNode=!0,this.outputNode=r,this.callNode=t}getNodeType(r){return this.outputNode.getNodeType(r)}generate(r){let t=this.callNode.build(r,"void");return t!==""&&r.addLineFlowCode(t,this),this.outputNode.build(r)}};const fT=H(_E).setParameterLength(2);D("bypass",fT);var gT=class extends at{static get type(){return"RemapNode"}constructor(r,t,e,s=v(0),i=v(1)){super(),this.node=r,this.inLowNode=t,this.inHighNode=e,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){let{node:r,inLowNode:t,inHighNode:e,outLowNode:s,outHighNode:i,doClamp:n}=this,a=r.sub(t).div(e.sub(t));return n===!0&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}};const yT=H(gT,null,null,{doClamp:!1}).setParameterLength(3,5),xT=H(gT).setParameterLength(3,5);D("remap",yT),D("remapClamp",xT);var AE=class extends at{static get type(){return"ExpressionNode"}constructor(r="",t="void"){super(t),this.snippet=r}generate(r,t){let e=this.getNodeType(r),s=this.snippet;if(e==="void")r.addLineFlowCode(s,this);else return r.format(s,e,t)}};const sn=H(AE).setParameterLength(1,2),bT=r=>(r?Qe(r,sn("discard")):sn("discard")).toStack(),zE=()=>sn("return").toStack();D("discard",bT);var CE=class extends we{static get type(){return"RenderOutputNode"}constructor(r,t,e){super("vec4"),this.colorNode=r,this.toneMapping=t,this.outputColorSpace=e,this.isRenderOutputNode=!0}setup({context:r}){let t=this.colorNode||r.color,e=(this.toneMapping===null?r.toneMapping:this.toneMapping)||$f,s=(this.outputColorSpace===null?r.outputColorSpace:this.outputColorSpace)||_d;return e!==$f&&(t=t.toneMapping(e)),s!==_d&&s!==Me.workingColorSpace&&(t=t.workingToColorSpace(s)),t}};const vT=(r,t=null,e=null)=>W(new CE(W(r),t,e));D("renderOutput",vT);var EE=class extends we{static get type(){return"DebugNode"}constructor(r,t=null){super(),this.node=r,this.callback=t}getNodeType(r){return this.node.getNodeType(r)}setup(r){return this.node.build(r)}analyze(r){return this.node.build(r)}generate(r){let t=this.callback,e=this.node.build(r),s="--- TSL debug - "+r.shaderStage+" shader ---",i="-".repeat(s.length),n="";return n+="// #"+s+`#
|
|
54
|
+
`,n+=r.flow.code.replace(/^\t/gm,"")+`
|
|
55
|
+
`,n+="/* ... */ "+e+` /* ... */
|
|
56
|
+
`,n+="// #"+i+`#
|
|
57
|
+
`,t===null?console.log(n):t(r,n),e}};const wT=(r,t=null)=>W(new EE(W(r),t));D("debug",wT);function VE(r){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",r)}var MT=class extends at{static get type(){return"AttributeNode"}constructor(r,t=null){super(t),this.global=!0,this._attributeName=r}getHash(r){return this.getAttributeName(r)}getNodeType(r){let t=this.nodeType;if(t===null){let e=this.getAttributeName(r);if(r.hasGeometryAttribute(e)){let s=r.geometry.getAttribute(e);t=r.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(r){return this._attributeName=r,this}getAttributeName(){return this._attributeName}generate(r){let t=this.getAttributeName(r),e=this.getNodeType(r);if(r.hasGeometryAttribute(t)===!0){let i=r.geometry.getAttribute(t),n=r.getTypeFromAttribute(i),a=r.getAttribute(t,n);return r.shaderStage==="vertex"?r.format(a.name,n,e):fs(this).build(r,e)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),r.generateConst(e)}serialize(r){super.serialize(r),r.global=this.global,r._attributeName=this._attributeName}deserialize(r){super.deserialize(r),this.global=r.global,this._attributeName=r._attributeName}};const Zn=(r,t=null)=>W(new MT(r,t)),oe=(r=0)=>Zn("uv"+(r>0?r:""),"vec2");var RE=class extends at{static get type(){return"TextureSizeNode"}constructor(r,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=r,this.levelNode=t}generate(r,t){let e=this.textureNode.build(r,"property"),s=this.levelNode===null?"0":this.levelNode.build(r,"int");return r.format(`${r.getMethod("textureDimensions")}( ${e}, ${s} )`,this.getNodeType(r),t)}};const $n=H(RE).setParameterLength(1,2);var LE=class extends lh{static get type(){return"MaxMipLevelNode"}constructor(r){super(0),this._textureNode=r,this.updateType=It.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let r=this.texture,t=r.images,e=t&&t.length>0?t[0]&&t[0].image||t[0]:r.image;if(e&&e.width!==void 0){let{width:s,height:i}=e;this.value=Math.log2(Math.max(s,i))}}};const TT=H(LE).setParameterLength(1),by=new oi;var nn=class extends lh{static get type(){return"TextureNode"}constructor(r=by,t=null,e=null,s=null){super(r),this.isTextureNode=!0,this.uvNode=t,this.levelNode=e,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=It.NONE,this.referenceNode=null,this._value=r,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(r){this.referenceNode?this.referenceNode.value=r:this._value=r}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===Kv?"uvec4":this.value.type===KA?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return oe(this.value.channel)}updateReference(){return this.value}getTransformedUV(r){return this._matrixUniform===null&&(this._matrixUniform=ct(this.value.matrix)),this._matrixUniform.mul(E(r,1)).xy}setUpdateMatrix(r){return this.updateMatrix=r,this.updateType=r?It.OBJECT:It.NONE,this}setupUV(r,t){let e=this.value;return r.isFlipY()&&(e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(T($n(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(r){let t=r.getNodeProperties(this);t.referenceNode=this.referenceNode;let e=this.value;if(!e||e.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;(s===null||r.context.forceUVContext===!0)&&r.context.getUV&&(s=r.context.getUV(this,r)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(r,s);let i=this.levelNode;i===null&&r.context.getTextureLevel&&(i=r.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(r,t){return t.build(r,this.sampler===!0?"vec2":"ivec2")}generateSnippet(r,t,e,s,i,n,a,o){let l=this.value,h;return h=s?r.generateTextureLevel(l,t,e,s,n):i?r.generateTextureBias(l,t,e,i,n):o?r.generateTextureGrad(l,t,e,o,n):a?r.generateTextureCompare(l,t,e,a,n):this.sampler===!1?r.generateTextureLoad(l,t,e,n):r.generateTexture(l,t,e,n),h}generate(r,t){let e=this.value,s=r.getNodeProperties(this),i=super.generate(r,"property");if(/^sampler/.test(t))return i+"_sampler";if(r.isReference(t))return i;{let n=r.getDataFromNode(this),a=n.propertyName;if(a===void 0){let{uvNode:h,levelNode:u,biasNode:c,compareNode:d,depthNode:p,gradNode:m}=s,f=this.generateUV(r,h),x=u?u.build(r,"float"):null,b=c?c.build(r,"float"):null,w=p?p.build(r,"int"):null,S=d?d.build(r,"float"):null,_=m?[m[0].build(r,"vec2"),m[1].build(r,"vec2")]:null,V=r.getVarFromNode(this);a=r.getPropertyName(V);let z=this.generateSnippet(r,i,f,x,b,w,S,_);r.addLineFlowCode(`${a} = ${z}`,this),n.snippet=z,n.propertyName=a}let o=a,l=this.getNodeType(r);return r.needsToWorkingColorSpace(e)&&(o=xy(sn(o,l),e.colorSpace).setup(r).build(r,l)),r.format(o,l,t)}}setSampler(r){return this.sampler=r,this}getSampler(){return this.sampler}uv(r){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(r)}sample(r){let t=this.clone();return t.uvNode=W(r),t.referenceNode=this.getSelf(),W(t)}blur(r){let t=this.clone();t.biasNode=W(r).mul(TT(t)),t.referenceNode=this.getSelf();let e=t.value;return t.generateMipmaps===!1&&(e&&e.generateMipmaps===!1||e.minFilter===Xn||e.magFilter===Xn)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),W(t)}level(r){let t=this.clone();return t.levelNode=W(r),t.referenceNode=this.getSelf(),W(t)}size(r){return $n(this,r)}bias(r){let t=this.clone();return t.biasNode=W(r),t.referenceNode=this.getSelf(),W(t)}compare(r){let t=this.clone();return t.compareNode=W(r),t.referenceNode=this.getSelf(),W(t)}grad(r,t){let e=this.clone();return e.gradNode=[W(r),W(t)],e.referenceNode=this.getSelf(),W(e)}depth(r){let t=this.clone();return t.depthNode=W(r),t.referenceNode=this.getSelf(),W(t)}serialize(r){super.serialize(r),r.value=this.value.toJSON(r.meta).uuid,r.sampler=this.sampler,r.updateMatrix=this.updateMatrix,r.updateType=this.updateType}deserialize(r){super.deserialize(r),this.value=r.meta.textures[r.value],this.sampler=r.sampler,this.updateMatrix=r.updateMatrix,this.updateType=r.updateType}update(){let r=this.value,t=this._matrixUniform;t!==null&&(t.value=r.matrix),r.matrixAutoUpdate===!0&&r.updateMatrix()}clone(){let r=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return r.sampler=this.sampler,r.depthNode=this.depthNode,r.compareNode=this.compareNode,r.gradNode=this.gradNode,r}};const IE=H(nn).setParameterLength(1,4).setName("texture"),Bt=(r=by,t=null,e=null,s=null)=>{let i;return r&&r.isTextureNode===!0?(i=W(r.clone()),i.referenceNode=r.getSelf(),t!==null&&(i.uvNode=W(t)),e!==null&&(i.levelNode=W(e)),s!==null&&(i.biasNode=W(s))):i=IE(r,t,e,s),i},PE=(r=by)=>Bt(r),be=(...r)=>Bt(...r).setSampler(!1),FE=r=>(r.isNode===!0?r:Bt(r)).convert("sampler"),OE=r=>(r.isNode===!0?r:Bt(r)).convert("samplerComparison");var vy=class extends lh{static get type(){return"BufferNode"}constructor(r,t,e=0){super(r,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=e}getElementType(r){return this.getNodeType(r)}getInputType(){return"buffer"}};const ch=(r,t,e)=>W(new vy(r,t,e));var BE=class extends Xa{static get type(){return"UniformArrayElementNode"}constructor(r,t){super(r,t),this.isArrayBufferElementNode=!0}generate(r){let t=super.generate(r),e=this.getNodeType(),s=this.node.getPaddedType();return r.format(t,s,e)}},NT=class extends vy{static get type(){return"UniformArrayNode"}constructor(r,t=null){super(null),this.array=r,this.elementType=t===null?kn(r[0]):t,this.paddedType=this.getPaddedType(),this.updateType=It.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let r=this.elementType,t="vec4";return r==="mat2"?t="mat2":/mat/.test(r)===!0?t="mat4":r.charAt(0)==="i"?t="ivec4":r.charAt(0)==="u"&&(t="uvec4"),t}update(){let{array:r,value:t}=this,e=this.elementType;if(e==="float"||e==="int"||e==="uint")for(let s=0;s<r.length;s++){let i=s*4;t[i]=r[s]}else if(e==="color")for(let s=0;s<r.length;s++){let i=s*4,n=r[s];t[i]=n.r,t[i+1]=n.g,t[i+2]=n.b||0}else if(e==="mat2")for(let s=0;s<r.length;s++){let i=s*4,n=r[s];t[i]=n.elements[0],t[i+1]=n.elements[1],t[i+2]=n.elements[2],t[i+3]=n.elements[3]}else if(e==="mat3")for(let s=0;s<r.length;s++){let i=s*16,n=r[s];t[i]=n.elements[0],t[i+1]=n.elements[1],t[i+2]=n.elements[2],t[i+4]=n.elements[3],t[i+5]=n.elements[4],t[i+6]=n.elements[5],t[i+8]=n.elements[6],t[i+9]=n.elements[7],t[i+10]=n.elements[8],t[i+15]=1}else if(e==="mat4")for(let s=0;s<r.length;s++){let i=s*16,n=r[s];for(let a=0;a<n.elements.length;a++)t[i+a]=n.elements[a]}else for(let s=0;s<r.length;s++){let i=s*4,n=r[s];t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z||0,t[i+3]=n.w||0}}setup(r){let t=this.array.length,e=this.elementType,s=Float32Array,i=this.paddedType,n=r.getTypeLength(i);return e.charAt(0)==="i"&&(s=Int32Array),e.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(t*n),this.bufferCount=t,this.bufferType=i,super.setup(r)}element(r){return W(new BE(this,W(r)))}};const js=(r,t)=>W(new NT(r,t)),kE=(r,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),W(new NT(r,t)));var DE=class extends at{constructor(r){super("float"),this.name=r,this.isBuiltinNode=!0}generate(){return this.name}};const bp=H(DE).setParameterLength(1),vp=ct(0,"uint").label("u_cameraIndex").setGroup(mp("cameraIndex")).toVarying("v_cameraIndex"),Ln=ct("float").label("cameraNear").setGroup(Tt).onRenderUpdate(({camera:r})=>r.near),In=ct("float").label("cameraFar").setGroup(Tt).onRenderUpdate(({camera:r})=>r.far),dh=C(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){let e=[];for(let i of r.cameras)e.push(i.projectionMatrix);t=js(e).setGroup(Tt).label("cameraProjectionMatrices").element(r.isMultiViewCamera?bp("gl_ViewID_OVR"):vp).toVar("cameraProjectionMatrix")}else t=ct("mat4").label("cameraProjectionMatrix").setGroup(Tt).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),UE=C(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){let e=[];for(let i of r.cameras)e.push(i.projectionMatrixInverse);t=js(e).setGroup(Tt).label("cameraProjectionMatricesInverse").element(r.isMultiViewCamera?bp("gl_ViewID_OVR"):vp).toVar("cameraProjectionMatrixInverse")}else t=ct("mat4").label("cameraProjectionMatrixInverse").setGroup(Tt).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Ts=C(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){let e=[];for(let i of r.cameras)e.push(i.matrixWorldInverse);t=js(e).setGroup(Tt).label("cameraViewMatrices").element(r.isMultiViewCamera?bp("gl_ViewID_OVR"):vp).toVar("cameraViewMatrix")}else t=ct("mat4").label("cameraViewMatrix").setGroup(Tt).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),$E=ct("mat4").label("cameraWorldMatrix").setGroup(Tt).onRenderUpdate(({camera:r})=>r.matrixWorld),jE=ct("mat3").label("cameraNormalMatrix").setGroup(Tt).onRenderUpdate(({camera:r})=>r.normalMatrix),WE=ct(new B).label("cameraPosition").setGroup(Tt).onRenderUpdate(({camera:r},t)=>t.value.setFromMatrixPosition(r.matrixWorld)),Hx=new lp;var Je=class We extends at{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=It.OBJECT,this.uniformNode=new lh(null)}getNodeType(){let t=this.scope;if(t===We.WORLD_MATRIX)return"mat4";if(t===We.POSITION||t===We.VIEW_POSITION||t===We.DIRECTION||t===We.SCALE)return"vec3";if(t===We.RADIUS)return"float"}update(t){let e=this.object3d,s=this.uniformNode,i=this.scope;if(i===We.WORLD_MATRIX)s.value=e.matrixWorld;else if(i===We.POSITION)s.value=s.value||new B,s.value.setFromMatrixPosition(e.matrixWorld);else if(i===We.SCALE)s.value=s.value||new B,s.value.setFromMatrixScale(e.matrixWorld);else if(i===We.DIRECTION)s.value=s.value||new B,e.getWorldDirection(s.value);else if(i===We.VIEW_POSITION){let n=t.camera;s.value=s.value||new B,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(n.matrixWorldInverse)}else if(i===We.RADIUS){let n=t.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Hx.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),s.value=Hx.radius}}generate(t){let e=this.scope;return e===We.WORLD_MATRIX?this.uniformNode.nodeType="mat4":e===We.POSITION||e===We.VIEW_POSITION||e===We.DIRECTION||e===We.SCALE?this.uniformNode.nodeType="vec3":e===We.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}};Je.WORLD_MATRIX="worldMatrix",Je.POSITION="position",Je.SCALE="scale",Je.VIEW_POSITION="viewPosition",Je.DIRECTION="direction",Je.RADIUS="radius";const qE=H(Je,Je.DIRECTION).setParameterLength(1),HE=H(Je,Je.WORLD_MATRIX).setParameterLength(1),ST=H(Je,Je.POSITION).setParameterLength(1),GE=H(Je,Je.SCALE).setParameterLength(1),XE=H(Je,Je.VIEW_POSITION).setParameterLength(1),YE=H(Je,Je.RADIUS).setParameterLength(1);var xs=class extends Je{static get type(){return"ModelNode"}constructor(r){super(r)}update(r){this.object3d=r.object,super.update(r)}};const ZE=Q(xs,xs.DIRECTION),ji=Q(xs,xs.WORLD_MATRIX),JE=Q(xs,xs.POSITION),QE=Q(xs,xs.SCALE),KE=Q(xs,xs.VIEW_POSITION),tV=Q(xs,xs.RADIUS),_T=ct(new Ti).onObjectUpdate(({object:r},t)=>t.value.getNormalMatrix(r.matrixWorld)),eV=ct(new Lt).onObjectUpdate(({object:r},t)=>t.value.copy(r.matrixWorld).invert()),ph=C(r=>r.renderer.overrideNodes.modelViewMatrix||AT).once()().toVar("modelViewMatrix"),AT=Ts.mul(ji),rV=C(r=>(r.context.isHighPrecisionModelViewMatrix=!0,ct("mat4").onObjectUpdate(({object:t,camera:e})=>t.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld)))).once()().toVar("highpModelViewMatrix"),sV=C(r=>{let t=r.context.isHighPrecisionModelViewMatrix;return ct("mat3").onObjectUpdate(({object:e,camera:s})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),wy=Zn("position","vec3"),Se=wy.toVarying("positionLocal"),Id=wy.toVarying("positionPrevious"),Ra=C(r=>ji.mul(Se).xyz.toVarying(r.getNamespace("v_positionWorld")),"vec3").once("POSITION")(),My=C(r=>Se.transformDirection(ji).toVarying(r.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection"),"vec3").once("POSITION")(),ar=C(r=>r.context.setupPositionView().toVarying(r.getNamespace("v_positionView")),"vec3").once("POSITION")(),lr=ar.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");var iV=class extends at{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(r){let{renderer:t,material:e}=r;return t.coordinateSystem===ds&&e.side===Ha?"false":r.getFrontFacing()}};const zT=Q(iV),mh=v(zT).mul(2).sub(1),Ty=Zn("normal","vec3"),Pr=C(r=>r.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),E(0,1,0)):Ty,"vec3").once()().toVar("normalLocal"),CT=ar.dFdx().cross(ar.dFdy()).normalize().toVar("normalFlat"),yi=C(r=>{let t;return t=r.material.flatShading===!0?CT:fs(Ny(Pr),"v_normalView").normalize(),t},"vec3").once()().toVar("normalView"),ET=C(r=>{let t=yi.transformDirection(Ts);return r.material.flatShading!==!0&&(t=fs(t,"v_normalWorld")),t},"vec3").once()().normalize().toVar("normalWorld"),Kr=C(r=>{let t=r.context.setupNormal().context({getUV:null});return r.material.flatShading!==!0&&(t=t.mul(mh)),t},"vec3").once()().toVar("transformedNormalView"),VT=Kr.transformDirection(Ts).toVar("transformedNormalWorld"),nV=C(r=>{let t=r.context.setupClearcoatNormal().context({getUV:null});return r.material.flatShading!==!0&&(t=t.mul(mh)),t},"vec3").once()().toVar("transformedClearcoatNormalView"),RT=C(([r,t=ji])=>{let e=Ir(t),s=r.div(E(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2])));return e.mul(s).xyz}),Ny=C(([r],t)=>{let e=t.renderer.overrideNodes.modelNormalViewMatrix;if(e!==null)return e.transformDirection(r);let s=_T.mul(r);return Ts.transformDirection(s)}),Gx=new mi,wm=new Lt,LT=ct(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),aV=ct(1).onReference(({material:r})=>r).onObjectUpdate(function({material:r,scene:t}){return r.envMap?r.envMapIntensity:t.environmentIntensity}),Sy=ct(new Lt).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:t}){let e=t.environment!==null&&r.envMap===null?t.environmentRotation:r.envMapRotation;return e?(Gx.copy(e),wm.makeRotationFromEuler(Gx)):wm.identity(),wm}),IT=lr.negate().reflect(Kr),PT=lr.negate().refract(Kr,LT),FT=IT.transformDirection(Ts).toVar("reflectVector"),OT=PT.transformDirection(Ts).toVar("reflectVector"),BT=new Yg;var oV=class extends nn{static get type(){return"CubeTextureNode"}constructor(r,t=null,e=null,s=null){super(r,t,e,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){let r=this.value;return r.mapping===Uu?FT:r.mapping===Sd?OT:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',r.mapping),E(0,0,0))}setUpdateMatrix(){}setupUV(r,t){let e=this.value;return(r.renderer.coordinateSystem===tn||!e.isRenderTargetTexture)&&(t=E(t.x.negate(),t.yz)),Sy.mul(t)}generateUV(r,t){return t.build(r,"vec3")}};const _y=H(oV).setParameterLength(1,4).setName("cubeTexture"),wp=(r=BT,t=null,e=null,s=null)=>{let i;return r&&r.isCubeTextureNode===!0?(i=W(r.clone()),i.referenceNode=r.getSelf(),t!==null&&(i.uvNode=W(t)),e!==null&&(i.levelNode=W(e)),s!==null&&(i.biasNode=W(s))):i=_y(r,t,e,s),i},lV=(r=BT)=>_y(r);var uV=class extends Xa{static get type(){return"ReferenceElementNode"}constructor(r,t){super(r,t),this.referenceNode=r,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(r){let t=super.generate(r),e=this.referenceNode.getNodeType(),s=this.getNodeType();return r.format(t,e,s)}},Mp=class extends at{static get type(){return"ReferenceNode"}constructor(r,t,e=null,s=null){super(),this.property=r,this.uniformType=t,this.object=e,this.count=s,this.properties=r.split("."),this.reference=e,this.node=null,this.group=null,this.name=null,this.updateType=It.OBJECT}element(r){return W(new uV(this,W(r)))}setGroup(r){return this.group=r,this}label(r){return this.name=r,this}setNodeType(r){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?js(null,r):r==="texture"?Bt(null):r==="cubeTexture"?wp(null):ct(null,r):ch(null,r,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(r){return this.node===null&&(this.updateReference(r),this.updateValue()),this.node.getNodeType(r)}getValueFromReference(r=this.reference){let{properties:t}=this,e=r[t[0]];for(let s=1;s<t.length;s++)e=e[t[s]];return e}updateReference(r){return this.reference=this.object===null?r.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let r=this.getValueFromReference();Array.isArray(r)?this.node.array=r:this.node.value=r}};const pe=(r,t,e)=>W(new Mp(r,t,e)),Qf=(r,t,e,s)=>W(new Mp(r,t,s,e));var hV=class extends Mp{static get type(){return"MaterialReferenceNode"}constructor(r,t,e=null){super(r,t,e),this.material=e,this.isMaterialReferenceNode=!0}updateReference(r){return this.reference=this.material===null?r.material:this.material,this.reference}};const Pn=(r,t,e=null)=>W(new hV(r,t,e)),Tp=C(r=>(r.geometry.hasAttribute("tangent")===!1&&r.geometry.computeTangents(),Zn("tangent","vec4")))(),fh=Tp.xyz.toVar("tangentLocal"),gh=ph.mul(ut(fh,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),kT=gh.transformDirection(Ts).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),Ay=gh.toVar("transformedTangentView"),cV=Ay.transformDirection(Ts).normalize().toVar("transformedTangentWorld"),yh=C(([r,t],e)=>{let s=r.mul(Tp.w).xyz;return e.material.flatShading!==!0&&(s=fs(s,t)),s}).once(),dV=yh(Ty.cross(Tp),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),pV=yh(Pr.cross(fh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),DT=yh(yi.cross(gh),"v_bitangentView").normalize().toVar("bitangentView"),mV=yh(ET.cross(kT),"v_bitangentWorld").normalize().toVar("bitangentWorld"),UT=yh(Kr.cross(Ay),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),fV=UT.transformDirection(Ts).normalize().toVar("transformedBitangentWorld"),zy=Ir(gh,DT,yi),$T=lr.mul(zy),gV=(r,t)=>r.sub($T.mul(t)),yV=(()=>{let r=al.cross(lr);return r=r.cross(al).normalize(),r=fe(r,Kr,Zw.mul(Hw.oneMinus()).oneMinus().pow2().pow2()).normalize(),r})(),xV=C(r=>{let{eye_pos:t,surf_norm:e,mapN:s,uv:i}=r,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),l=i.dFdy(),h=e,u=a.cross(h),c=h.cross(n),d=u.mul(o.x).add(c.mul(l.x)),p=u.mul(o.y).add(c.mul(l.y)),m=d.dot(d).max(p.dot(p)),f=mh.mul(m.inverseSqrt());return Ce(d.mul(s.x,f),p.mul(s.y,f),h.mul(s.z)).normalize()});var bV=class extends we{static get type(){return"NormalMapNode"}constructor(r,t=null){super("vec3"),this.node=r,this.scaleNode=t,this.normalMapType=Yn}setup(r){let{normalMapType:t,scaleNode:e}=this,s=this.node.mul(2).sub(1);e!==null&&(s=E(s.xy.mul(e),s.z));let i=null;return t===ez?i=Ny(s):t===Yn&&(i=r.hasGeometryAttribute("tangent")===!0?zy.mul(s).normalize():xV({eye_pos:ar,surf_norm:yi,mapN:s,uv:oe()})),i}};const Kf=H(bV).setParameterLength(1,2),vV=C(({textureNode:r,bumpScale:t})=>{let e=i=>r.cache().context({getUV:n=>i(n.uvNode||oe()),forceUVContext:!0}),s=v(e(i=>i));return Y(v(e(i=>i.add(i.dFdx()))).sub(s),v(e(i=>i.add(i.dFdy()))).sub(s)).mul(t)}),wV=C(r=>{let{surf_pos:t,surf_norm:e,dHdxy:s}=r,i=t.dFdx().normalize(),n=t.dFdy().normalize(),a=e,o=n.cross(a),l=a.cross(i),h=i.dot(o).mul(mh),u=h.sign().mul(s.x.mul(o).add(s.y.mul(l)));return h.abs().mul(e).sub(u).normalize()});var MV=class extends we{static get type(){return"BumpMapNode"}constructor(r,t=null){super("vec3"),this.textureNode=r,this.scaleNode=t}setup(){let r=this.scaleNode===null?1:this.scaleNode,t=vV({textureNode:this.textureNode,bumpScale:r});return wV({surf_pos:ar,surf_norm:yi,dHdxy:t})}};const jT=H(MV).setParameterLength(1,2),Xx=new Map;var X=class de extends at{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let s=Xx.get(t);return s===void 0&&(s=Pn(t,e),Xx.set(t,s)),s}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){let e=t.context.material,s=this.scope,i=null;if(s===de.COLOR){let n=e.color===void 0?E():this.getColor(s);i=e.map&&e.map.isTexture===!0?n.mul(this.getTexture("map")):n}else if(s===de.OPACITY){let n=this.getFloat(s);i=e.alphaMap&&e.alphaMap.isTexture===!0?n.mul(this.getTexture("alpha")):n}else if(s===de.SPECULAR_STRENGTH)i=e.specularMap&&e.specularMap.isTexture===!0?this.getTexture("specular").r:v(1);else if(s===de.SPECULAR_INTENSITY){let n=this.getFloat(s);i=e.specularIntensityMap&&e.specularIntensityMap.isTexture===!0?n.mul(this.getTexture(s).a):n}else if(s===de.SPECULAR_COLOR){let n=this.getColor(s);i=e.specularColorMap&&e.specularColorMap.isTexture===!0?n.mul(this.getTexture(s).rgb):n}else if(s===de.ROUGHNESS){let n=this.getFloat(s);i=e.roughnessMap&&e.roughnessMap.isTexture===!0?n.mul(this.getTexture(s).g):n}else if(s===de.METALNESS){let n=this.getFloat(s);i=e.metalnessMap&&e.metalnessMap.isTexture===!0?n.mul(this.getTexture(s).b):n}else if(s===de.EMISSIVE){let n=this.getFloat("emissiveIntensity"),a=this.getColor(s).mul(n);i=e.emissiveMap&&e.emissiveMap.isTexture===!0?a.mul(this.getTexture(s)):a}else if(s===de.NORMAL)e.normalMap?(i=Kf(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType):i=e.bumpMap?jT(this.getTexture("bump").r,this.getFloat("bumpScale")):yi;else if(s===de.CLEARCOAT){let n=this.getFloat(s);i=e.clearcoatMap&&e.clearcoatMap.isTexture===!0?n.mul(this.getTexture(s).r):n}else if(s===de.CLEARCOAT_ROUGHNESS){let n=this.getFloat(s);i=e.clearcoatRoughnessMap&&e.clearcoatRoughnessMap.isTexture===!0?n.mul(this.getTexture(s).r):n}else if(s===de.CLEARCOAT_NORMAL)i=e.clearcoatNormalMap?Kf(this.getTexture(s),this.getCache(s+"Scale","vec2")):yi;else if(s===de.SHEEN){let n=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=e.sheenColorMap&&e.sheenColorMap.isTexture===!0?n.mul(this.getTexture("sheenColor").rgb):n}else if(s===de.SHEEN_ROUGHNESS){let n=this.getFloat(s);i=e.sheenRoughnessMap&&e.sheenRoughnessMap.isTexture===!0?n.mul(this.getTexture(s).a):n,i=i.clamp(.07,1)}else if(s===de.ANISOTROPY)if(e.anisotropyMap&&e.anisotropyMap.isTexture===!0){let n=this.getTexture(s);i=pp(Ho.x,Ho.y,Ho.y.negate(),Ho.x).mul(n.rg.mul(2).sub(Y(1)).normalize().mul(n.b))}else i=Ho;else if(s===de.IRIDESCENCE_THICKNESS){let n=pe("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){let a=pe("0","float",e.iridescenceThicknessRange);i=n.sub(a).mul(this.getTexture(s).g).add(a)}else i=n}else if(s===de.TRANSMISSION){let n=this.getFloat(s);i=e.transmissionMap?n.mul(this.getTexture(s).r):n}else if(s===de.THICKNESS){let n=this.getFloat(s);i=e.thicknessMap?n.mul(this.getTexture(s).g):n}else if(s===de.IOR)i=this.getFloat(s);else if(s===de.LIGHT_MAP)i=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===de.AO)i=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(s===de.LINE_DASH_OFFSET)i=e.dashOffset?this.getFloat(s):v(0);else{let n=this.getNodeType(t);i=this.getCache(s,n)}return i}};X.ALPHA_TEST="alphaTest",X.COLOR="color",X.OPACITY="opacity",X.SHININESS="shininess",X.SPECULAR="specular",X.SPECULAR_STRENGTH="specularStrength",X.SPECULAR_INTENSITY="specularIntensity",X.SPECULAR_COLOR="specularColor",X.REFLECTIVITY="reflectivity",X.ROUGHNESS="roughness",X.METALNESS="metalness",X.NORMAL="normal",X.CLEARCOAT="clearcoat",X.CLEARCOAT_ROUGHNESS="clearcoatRoughness",X.CLEARCOAT_NORMAL="clearcoatNormal",X.EMISSIVE="emissive",X.ROTATION="rotation",X.SHEEN="sheen",X.SHEEN_ROUGHNESS="sheenRoughness",X.ANISOTROPY="anisotropy",X.IRIDESCENCE="iridescence",X.IRIDESCENCE_IOR="iridescenceIOR",X.IRIDESCENCE_THICKNESS="iridescenceThickness",X.IOR="ior",X.TRANSMISSION="transmission",X.THICKNESS="thickness",X.ATTENUATION_DISTANCE="attenuationDistance",X.ATTENUATION_COLOR="attenuationColor",X.LINE_SCALE="scale",X.LINE_DASH_SIZE="dashSize",X.LINE_GAP_SIZE="gapSize",X.LINE_WIDTH="linewidth",X.LINE_DASH_OFFSET="dashOffset",X.POINT_SIZE="size",X.DISPERSION="dispersion",X.LIGHT_MAP="light",X.AO="ao";const WT=Q(X,X.ALPHA_TEST),qT=Q(X,X.COLOR),TV=Q(X,X.SHININESS),HT=Q(X,X.EMISSIVE),GT=Q(X,X.OPACITY),NV=Q(X,X.SPECULAR),SV=Q(X,X.SPECULAR_INTENSITY),_V=Q(X,X.SPECULAR_COLOR),AV=Q(X,X.SPECULAR_STRENGTH),zV=Q(X,X.REFLECTIVITY),CV=Q(X,X.ROUGHNESS),EV=Q(X,X.METALNESS),XT=Q(X,X.NORMAL),VV=Q(X,X.CLEARCOAT),RV=Q(X,X.CLEARCOAT_ROUGHNESS),LV=Q(X,X.CLEARCOAT_NORMAL),IV=Q(X,X.ROTATION),PV=Q(X,X.SHEEN),FV=Q(X,X.SHEEN_ROUGHNESS),OV=Q(X,X.ANISOTROPY),BV=Q(X,X.IRIDESCENCE),kV=Q(X,X.IRIDESCENCE_IOR),DV=Q(X,X.IRIDESCENCE_THICKNESS),UV=Q(X,X.TRANSMISSION),$V=Q(X,X.THICKNESS),jV=Q(X,X.IOR),WV=Q(X,X.ATTENUATION_DISTANCE),qV=Q(X,X.ATTENUATION_COLOR),HV=Q(X,X.LINE_SCALE),GV=Q(X,X.LINE_DASH_SIZE),XV=Q(X,X.LINE_GAP_SIZE),YV=Q(X,X.LINE_WIDTH),ZV=Q(X,X.LINE_DASH_OFFSET),JV=Q(X,X.POINT_SIZE),QV=Q(X,X.DISPERSION),YT=Q(X,X.LIGHT_MAP),ZT=Q(X,X.AO),Ho=ct(new jt).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),JT=C(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");var nr=class Ma extends at{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){let e=this.getNodeType(t),s=this.scope,i;if(s===Ma.VERTEX)i=t.getVertexIndex();else if(s===Ma.INSTANCE)i=t.getInstanceIndex();else if(s===Ma.DRAW)i=t.getDrawIndex();else if(s===Ma.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(s===Ma.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(s===Ma.SUBGROUP)i=t.getSubgroupIndex();else throw Error("THREE.IndexNode: Unknown scope: "+s);let n;return t.shaderStage==="vertex"||t.shaderStage==="compute"?n=i:n=fs(this).build(t,e),n}};nr.VERTEX="vertex",nr.INSTANCE="instance",nr.SUBGROUP="subgroup",nr.INVOCATION_LOCAL="invocationLocal",nr.INVOCATION_SUBGROUP="invocationSubgroup",nr.DRAW="draw";const QT=Q(nr,nr.VERTEX),jn=Q(nr,nr.INSTANCE),KV=Q(nr,nr.SUBGROUP),tR=Q(nr,nr.INVOCATION_SUBGROUP),eR=Q(nr,nr.INVOCATION_LOCAL),KT=Q(nr,nr.DRAW);var t2=class extends at{static get type(){return"InstanceNode"}constructor(r,t,e=null){super("void"),this.count=r,this.instanceMatrix=t,this.instanceColor=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=It.FRAME,this.buffer=null,this.bufferColor=null}setup(r){let{count:t,instanceMatrix:e,instanceColor:s}=this,{instanceMatrixNode:i,instanceColorNode:n}=this;if(i===null){if(t<=1e3)i=ch(e.array,"mat4",Math.max(t,1)).element(jn);else{let o=new oC(e.array,16,1);this.buffer=o;let l=e.usage===vu?Jf:Ld,h=[l(o,"vec4",16,0),l(o,"vec4",16,4),l(o,"vec4",16,8),l(o,"vec4",16,12)];i=Va(...h)}this.instanceMatrixNode=i}if(s&&n===null){let o=new nl(s.array,3),l=s.usage===vu?Jf:Ld;this.bufferColor=o,n=E(l(o,"vec3",3,0)),this.instanceColorNode=n}let a=i.mul(Se).xyz;if(Se.assign(a),r.hasGeometryAttribute("normal")){let o=RT(Pr,i);Pr.assign(o)}this.instanceColorNode!==null&&Wu("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==vu&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==vu&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const rR=H(t2).setParameterLength(2,3);var sR=class extends t2{static get type(){return"InstancedMeshNode"}constructor(r){let{count:t,instanceMatrix:e,instanceColor:s}=r;super(t,e,s),this.instancedMesh=r}};const e2=H(sR).setParameterLength(1);var iR=class extends at{static get type(){return"BatchNode"}constructor(r){super("void"),this.batchMesh=r,this.batchingIdNode=null}setup(r){this.batchingIdNode===null&&(r.getDrawIndex()===null?this.batchingIdNode=jn:this.batchingIdNode=KT);let t=C(([p])=>{let m=T($n(be(this.batchMesh._indirectTexture),0).x),f=T(p).mod(m),x=T(p).div(m);return be(this.batchMesh._indirectTexture,Ge(f,x)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),e=t(T(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=T($n(be(s),0).x),n=v(e).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),l=Va(be(s,Ge(a,o)),be(s,Ge(a.add(1),o)),be(s,Ge(a.add(2),o)),be(s,Ge(a.add(3),o))),h=this.batchMesh._colorsTexture;if(h!==null){let p=C(([f])=>{let x=T($n(be(h),0).x),b=f,w=b.mod(x),S=b.div(x);return be(h,Ge(w,S)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),m=p(e);Wu("vec3","vBatchColor").assign(m)}let u=Ir(l);Se.assign(l.mul(Se));let c=Pr.div(E(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(c).xyz;Pr.assign(d),r.hasGeometryAttribute("tangent")&&fh.mulAssign(u)}};const r2=H(iR).setParameterLength(1);var nR=class extends Xa{static get type(){return"StorageArrayElementNode"}constructor(r,t){super(r,t),this.isStorageArrayElementNode=!0}set storageBufferNode(r){this.node=r}get storageBufferNode(){return this.node}getMemberType(r,t){let e=this.storageBufferNode.structTypeNode;return e?e.getMemberType(r,t):"void"}setup(r){return r.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&r.setupPBO(this.node),super.setup(r)}generate(r,t){let e,s=r.context.assign;if(e=r.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||r.shaderStage!=="compute")?r.generatePBO(this):this.node.build(r):super.generate(r),s!==!0){let i=this.getNodeType(r);e=r.format(e,i,t)}return e}};const aR=H(nR).setParameterLength(2);var oR=class extends vy{static get type(){return"StorageBufferNode"}constructor(r,t=null,e=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&(e=r.count)):t===null&&(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)?(s=pC(r.itemSize),e=r.count):s=t,super(r,s,e),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=ii.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,r.isStorageBufferAttribute!==!0&&r.isStorageInstancedBufferAttribute!==!0&&(r.isInstancedBufferAttribute?r.isStorageInstancedBufferAttribute=!0:r.isStorageBufferAttribute=!0)}getHash(r){if(this.bufferCount===0){let t=r.globalCache.getData(this.value);return t===void 0&&(t={node:this},r.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(r){return aR(this,r)}setPBO(r){return this.isPBO=r,this}getPBO(){return this.isPBO}setAccess(r){return this.access=r,this}toReadOnly(){return this.setAccess(ii.READ_ONLY)}setAtomic(r){return this.isAtomic=r,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=hh(this.value),this._varying=fs(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(r){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(r);if(r.isAvailable("storageBuffer")||r.isAvailable("indirectStorageBuffer"))return super.getNodeType(r);let{attribute:t}=this.getAttributeData();return t.getNodeType(r)}getMemberType(r,t){return this.structTypeNode===null?"void":this.structTypeNode.getMemberType(r,t)}generate(r){if(this.structTypeNode!==null&&this.structTypeNode.build(r),r.isAvailable("storageBuffer")||r.isAvailable("indirectStorageBuffer"))return super.generate(r);let{attribute:t,varying:e}=this.getAttributeData(),s=e.build(r);return r.registerTransform(s,t),s}};const La=(r,t=null,e=0)=>W(new oR(r,t,e)),lR=(r,t,e)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),La(r,t,e).setPBO(!0)),Yx=new WeakMap;var s2=class extends at{static get type(){return"SkinningNode"}constructor(r){super("void"),this.skinnedMesh=r,this.updateType=It.OBJECT,this.skinIndexNode=Zn("skinIndex","uvec4"),this.skinWeightNode=Zn("skinWeight","vec4"),this.bindMatrixNode=pe("bindMatrix","mat4"),this.bindMatrixInverseNode=pe("bindMatrixInverse","mat4"),this.boneMatricesNode=Qf("skeleton.boneMatrices","mat4",r.skeleton.bones.length),this.positionNode=Se,this.toPositionNode=Se,this.previousBoneMatricesNode=null}getSkinnedPosition(r=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:e,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=r.element(e.x),o=r.element(e.y),l=r.element(e.z),h=r.element(e.w),u=i.mul(t),c=Ce(a.mul(s.x).mul(u),o.mul(s.y).mul(u),l.mul(s.z).mul(u),h.mul(s.w).mul(u));return n.mul(c).xyz}getSkinnedNormal(r=this.boneMatricesNode,t=Pr){let{skinIndexNode:e,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=r.element(e.x),o=r.element(e.y),l=r.element(e.z),h=r.element(e.w),u=Ce(s.x.mul(a),s.y.mul(o),s.z.mul(l),s.w.mul(h));return u=n.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(r){let t=r.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Qf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Id)}needsPreviousBoneMatrices(r){let t=r.renderer.getMRT();return t&&t.has("velocity")||Aw(r.object).useVelocity===!0}setup(r){this.needsPreviousBoneMatrices(r)&&Id.assign(this.getPreviousSkinnedPosition(r));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),r.hasGeometryAttribute("normal")){let e=this.getSkinnedNormal();Pr.assign(e),r.hasGeometryAttribute("tangent")&&fh.assign(e)}return t}generate(r,t){if(t!=="void")return super.generate(r,t)}update(r){let t=r.object&&r.object.skeleton?r.object.skeleton:this.skinnedMesh.skeleton;Yx.get(t)!==r.frameId&&(Yx.set(t,r.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const i2=r=>W(new s2(r)),uR=(r,t=null)=>{let e=new s2(r);return e.positionNode=La(new nl(r.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(jn).toVar(),e.skinIndexNode=La(new nl(new Uint32Array(r.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(jn).toVar(),e.skinWeightNode=La(new nl(r.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(jn).toVar(),e.bindMatrixNode=ct(r.bindMatrix,"mat4"),e.bindMatrixInverseNode=ct(r.bindMatrixInverse,"mat4"),e.boneMatricesNode=ch(r.skeleton.boneMatrices,"mat4",r.skeleton.bones.length),e.toPositionNode=t,W(e)};var hR=class extends at{static get type(){return"LoopNode"}constructor(r=[]){super(),this.params=r}getVarName(r){return String.fromCharCode(105+r)}getProperties(r){let t=r.getNodeProperties(this);if(t.stackNode!==void 0)return t;let e={};for(let n=0,a=this.params.length-1;n<a;n++){let o=this.params[n],l=o.isNode!==!0&&o.name||this.getVarName(n),h=o.isNode!==!0&&o.type||"int";e[l]=sn(l,h)}let s=r.addStack();t.returnsNode=this.params[this.params.length-1](e,r),t.stackNode=s;let i=this.params[0];return i.isNode!==!0&&typeof i.update=="function"&&(t.updateNode=C(this.params[0].update)(e)),r.removeStack(),t}getNodeType(r){let{returnsNode:t}=this.getProperties(r);return t?t.getNodeType(r):"void"}setup(r){this.getProperties(r)}generate(r){let t=this.getProperties(r),e=this.params,s=t.stackNode;for(let a=0,o=e.length-1;a<o;a++){let l=e[a],h=!1,u=null,c=null,d=null,p=null,m=null,f=null;l.isNode?l.getNodeType(r)==="bool"?(h=!0,p="bool",c=l.build(r,p)):(p="int",d=this.getVarName(a),u="0",c=l.build(r,p),m="<"):(p=l.type||"int",d=l.name||this.getVarName(a),u=l.start,c=l.end,m=l.condition,f=l.update,typeof u=="number"?u=r.generateConst(p,u):u&&u.isNode&&(u=u.build(r,p)),typeof c=="number"?c=r.generateConst(p,c):c&&c.isNode&&(c=c.build(r,p)),u!==void 0&&c===void 0?(u+=" - 1",c="0",m=">="):c!==void 0&&u===void 0&&(u="0",m="<"),m===void 0&&(m=Number(u)>Number(c)?">=":"<"));let x;if(h)x=`while ( ${c} )`;else{let b={start:u,end:c},w=b.start,S=b.end,_,V=()=>m.includes("<")?"+=":"-=";if(f!=null)switch(typeof f){case"function":_=r.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_=d+" "+V()+" "+r.generateConst(p,f);break;case"string":_=d+" "+f;break;default:f.isNode?_=d+" "+V()+" "+f.build(r):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),_="break /* invalid update */")}else f=p==="int"||p==="uint"?m.includes("<")?"++":"--":V()+" 1.",_=d+" "+f;let z=r.getVar(p,d)+" = "+w,A=d+" "+m+" "+S;x=`for ( ${z}; ${A}; ${_} )`}r.addFlowCode((a===0?`
|
|
58
|
+
`:"")+r.tab+x+` {
|
|
59
|
+
|
|
60
|
+
`).addFlowTab()}let i=s.build(r,"void"),n=t.returnsNode?t.returnsNode.build(r):"";r.removeFlowTab().addFlowCode(`
|
|
61
|
+
`+r.tab+i);for(let a=0,o=this.params.length-1;a<o;a++)r.addFlowCode((a===0?"":r.tab)+`}
|
|
62
|
+
|
|
63
|
+
`).removeFlowTab();return r.addFlowTab(),n}};const Pt=(...r)=>W(new hR(Ea(r,"int"))).toStack(),cR=()=>sn("continue").toStack(),n2=()=>sn("break").toStack(),dR=(...r)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Pt(...r)),Mm=new WeakMap,Dr=new wr,Zx=C(({bufferMap:r,influence:t,stride:e,width:s,depth:i,offset:n})=>{let a=T(QT).mul(e).add(n),o=a.div(s),l=a.sub(o.mul(s));return be(r,Ge(l,o)).depth(i).xyz.mul(t)});function pR(r){let t=r.morphAttributes.position!==void 0,e=r.morphAttributes.normal!==void 0,s=r.morphAttributes.color!==void 0,i=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,n=i===void 0?0:i.length,a=Mm.get(r);if(a===void 0||a.count!==n){let b=function(){f.dispose(),Mm.delete(r),r.removeEventListener("dispose",b)};a!==void 0&&a.texture.dispose();let o=r.morphAttributes.position||[],l=r.morphAttributes.normal||[],h=r.morphAttributes.color||[],u=0;t===!0&&(u=1),e===!0&&(u=2),s===!0&&(u=3);let c=r.attributes.position.count*u,d=1,p=4096;c>p&&(d=Math.ceil(c/p),c=p);let m=new Float32Array(c*d*4*n),f=new Sz(m,c,d,n);f.type=tw,f.needsUpdate=!0;let x=u*4;for(let w=0;w<n;w++){let S=o[w],_=l[w],V=h[w],z=c*d*4*w;for(let A=0;A<S.count;A++){let I=A*x;t===!0&&(Dr.fromBufferAttribute(S,A),m[z+I+0]=Dr.x,m[z+I+1]=Dr.y,m[z+I+2]=Dr.z,m[z+I+3]=0),e===!0&&(Dr.fromBufferAttribute(_,A),m[z+I+4]=Dr.x,m[z+I+5]=Dr.y,m[z+I+6]=Dr.z,m[z+I+7]=0),s===!0&&(Dr.fromBufferAttribute(V,A),m[z+I+8]=Dr.x,m[z+I+9]=Dr.y,m[z+I+10]=Dr.z,m[z+I+11]=V.itemSize===4?Dr.w:1)}}a={count:n,texture:f,stride:u,size:new jt(c,d)},Mm.set(r,a),r.addEventListener("dispose",b)}return a}var mR=class extends at{static get type(){return"MorphNode"}constructor(r){super("void"),this.mesh=r,this.morphBaseInfluence=ct(1),this.updateType=It.OBJECT}setup(r){let{geometry:t}=r,e=t.morphAttributes.position!==void 0,s=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=i===void 0?0:i.length,{texture:a,stride:o,size:l}=pR(t);e===!0&&Se.mulAssign(this.morphBaseInfluence),s===!0&&Pr.mulAssign(this.morphBaseInfluence);let h=T(l.width);Pt(n,({i:u})=>{let c=v(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?c.assign(be(this.mesh.morphTexture,Ge(T(u).add(1),T(jn))).r):c.assign(pe("morphTargetInfluences","float").element(u).toVar()),xt(c.notEqual(0),()=>{e===!0&&Se.addAssign(Zx({bufferMap:a,influence:c,stride:o,width:h,depth:u,offset:T(0)})),s===!0&&Pr.addAssign(Zx({bufferMap:a,influence:c,stride:o,width:h,depth:u,offset:T(1)}))})})}update(){let r=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?r.value=1:r.value=1-this.mesh.morphTargetInfluences.reduce((t,e)=>t+e,0)}};const a2=H(mR).setParameterLength(1);var o2=class extends at{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}},fR=class extends o2{static get type(){return"AONode"}constructor(r=null){super(),this.aoNode=r}setup(r){r.context.ambientOcclusion.mulAssign(this.aoNode)}},gR=class extends KM{static get type(){return"LightingContextNode"}constructor(r,t=null,e=null,s=null){super(r),this.lightingModel=t,this.backdropNode=e,this.backdropAlphaNode=s,this._value=null}getContext(){let{backdropNode:r,backdropAlphaNode:t}=this,e=E().toVar("directDiffuse"),s=E().toVar("directSpecular"),i=E().toVar("indirectDiffuse"),n=E().toVar("indirectSpecular"),a={directDiffuse:e,directSpecular:s,indirectDiffuse:i,indirectSpecular:n};return{radiance:E().toVar("radiance"),irradiance:E().toVar("irradiance"),iblIrradiance:E().toVar("iblIrradiance"),ambientOcclusion:v(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:r,backdropAlpha:t}}setup(r){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||r.context.lightingModel,super.setup(r)}};const l2=H(gR);var yR=class extends o2{static get type(){return"IrradianceNode"}constructor(r){super(),this.node=r}setup(r){r.context.irradiance.addAssign(this.node)}};let uc,hc;var ps=class En extends at{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this.isViewportNode=!0}getNodeType(){return this.scope===En.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=It.NONE;return(this.scope===En.SIZE||this.scope===En.VIEWPORT)&&(t=It.RENDER),this.updateType=t,t}update({renderer:t}){let e=t.getRenderTarget();this.scope===En.VIEWPORT?e===null?(t.getViewport(hc),hc.multiplyScalar(t.getPixelRatio())):hc.copy(e.viewport):e===null?t.getDrawingBufferSize(uc):(uc.width=e.width,uc.height=e.height)}setup(){let t=this.scope,e=null;return e=t===En.SIZE?ct(uc||(uc=new jt)):t===En.VIEWPORT?ct(hc||(hc=new wr)):Y(xh.div(Hu)),e}generate(t){if(this.scope===En.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let s=t.getNodeProperties(Hu).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${s}.y - ${e}.y )`}return e}return super.generate(t)}};ps.COORDINATE="coordinate",ps.VIEWPORT="viewport",ps.SIZE="size",ps.UV="uv";const na=Q(ps,ps.UV),Hu=Q(ps,ps.SIZE),xh=Q(ps,ps.COORDINATE),Cy=Q(ps,ps.VIEWPORT),u2=Cy.zw,h2=xh.sub(Cy.xy),xR=h2.div(u2),bR=C(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Hu),"vec2").once()(),vR=C(()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),na),"vec2").once()(),wR=C(()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),na.flipY()),"vec2").once()(),Kl=new jt;var Np=class extends nn{static get type(){return"ViewportTextureNode"}constructor(r=na,t=null,e=null){e===null&&(e=new yw,e.minFilter=op),super(e,r,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=It.FRAME}updateBefore(r){let t=r.renderer;t.getDrawingBufferSize(Kl);let e=this.value;(e.image.width!==Kl.width||e.image.height!==Kl.height)&&(e.image.width=Kl.width,e.image.height=Kl.height,e.needsUpdate=!0);let s=e.generateMipmaps;e.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(e),e.generateMipmaps=s}clone(){let r=new this.constructor(this.uvNode,this.levelNode,this.value);return r.generateMipmaps=this.generateMipmaps,r}};const MR=H(Np).setParameterLength(0,3),Ey=H(Np,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Tm=null;var TR=class extends Np{static get type(){return"ViewportDepthTextureNode"}constructor(r=na,t=null){Tm===null&&(Tm=new ah),super(r,t,Tm)}};const Vy=H(TR).setParameterLength(0,2);var Yi=class Mu extends at{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){let{scope:e}=this;return e===Mu.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:e}=this,s=this.valueNode,i=null;if(e===Mu.DEPTH_BASE)s!==null&&(i=d2().assign(s));else if(e===Mu.DEPTH)i=t.isPerspectiveCamera?c2(ar.z,Ln,In):ll(ar.z,Ln,In);else if(e===Mu.LINEAR_DEPTH)if(s!==null)if(t.isPerspectiveCamera){let n=Ry(s,Ln,In);i=ll(n,Ln,In)}else i=s;else i=ll(ar.z,Ln,In);return i}};Yi.DEPTH_BASE="depthBase",Yi.DEPTH="depth",Yi.LINEAR_DEPTH="linearDepth";const ll=(r,t,e)=>r.add(t).div(t.sub(e)),NR=(r,t,e)=>t.sub(e).mul(r).sub(t),c2=(r,t,e)=>t.add(r).mul(e).div(e.sub(t).mul(r)),Ry=(r,t,e)=>t.mul(e).div(e.sub(t).mul(r).sub(e)),Ly=(r,t,e)=>{t=t.max(1e-6).toVar();let s=li(r.negate().div(t)),i=li(e.div(t));return s.div(i)},SR=(r,t,e)=>{let s=r.mul(fp(e.div(t)));return v(Math.E).pow(s).mul(t).negate()},d2=H(Yi,Yi.DEPTH_BASE),Iy=Q(Yi,Yi.DEPTH),Pd=H(Yi,Yi.LINEAR_DEPTH).setParameterLength(0,1),_R=Pd(Vy());Iy.assign=r=>d2(r);var Wn=class fd extends at{static get type(){return"ClippingNode"}constructor(t=fd.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let e=t.clippingContext,{intersectionPlanes:s,unionPlanes:i}=e;return this.hardwareClipping=t.material.hardwareClipping,this.scope===fd.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,i):this.scope===fd.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(s,i)}setupAlphaToCoverage(t,e){return C(()=>{let s=v().toVar("distanceToPlane"),i=v().toVar("distanceToGradient"),n=v(1).toVar("clipOpacity"),a=e.length;if(this.hardwareClipping===!1&&a>0){let l=js(e);Pt(a,({i:h})=>{let u=l.element(h);s.assign(ar.dot(u.xyz).negate().add(u.w)),i.assign(s.fwidth().div(2)),n.mulAssign(rn(i.negate(),i,s))})}let o=t.length;if(o>0){let l=js(t),h=v(1).toVar("intersectionClipOpacity");Pt(o,({i:u})=>{let c=l.element(u);s.assign(ar.dot(c.xyz).negate().add(c.w)),i.assign(s.fwidth().div(2)),h.mulAssign(rn(i.negate(),i,s).oneMinus())}),n.mulAssign(h.oneMinus())}as.a.mulAssign(n),as.a.equal(0).discard()})()}setupDefault(t,e){return C(()=>{let s=e.length;if(this.hardwareClipping===!1&&s>0){let n=js(e);Pt(s,({i:a})=>{let o=n.element(a);ar.dot(o.xyz).greaterThan(o.w).discard()})}let i=t.length;if(i>0){let n=js(t),a=fi(!0).toVar("clipped");Pt(i,({i:o})=>{let l=n.element(o);a.assign(ar.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(t,e){let s=t.length;return e.enableHardwareClipping(s),C(()=>{let i=js(t),n=bp(e.getClipDistance());Pt(s,({i:a})=>{let o=i.element(a),l=ar.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}};Wn.ALPHA_TO_COVERAGE="alphaToCoverage",Wn.DEFAULT="default",Wn.HARDWARE="hardware";const AR=()=>W(new Wn),zR=()=>W(new Wn(Wn.ALPHA_TO_COVERAGE)),CR=()=>W(new Wn(Wn.HARDWARE)),ER=.05,Jx=C(([r])=>cn(gt(1e4,Xr(gt(17,r.x).add(gt(.1,r.y)))).mul(Ce(.1,Jt(Xr(gt(13,r.y).add(r.x))))))),Qx=C(([r])=>Jx(Y(Jx(r.xy),r.z))),VR=C(([r])=>{let t=ye(hi(ly(r.xyz)),hi(uy(r.xyz))),e=v(1).div(v(ER).mul(t)).toVar("pixScale"),s=Y(Cl(ui(li(e))),Cl(gp(li(e)))),i=Y(Qx(ui(s.x.mul(r.xyz))),Qx(ui(s.y.mul(r.xyz)))),n=cn(li(e)),a=Ce(gt(n.oneMinus(),i.x),gt(n,i.y)),o=ts(n,n.oneMinus()),l=E(a.mul(a).div(gt(2,o).mul(zt(1,o))),a.sub(gt(.5,o)).div(zt(1,o)),zt(1,zt(1,a).mul(zt(1,a)).div(gt(2,o).mul(zt(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return gi(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});var RR=class extends MT{static get type(){return"VertexColorNode"}constructor(r){super(null,"vec4"),this.isVertexColorNode=!0,this.index=r}getAttributeName(){let r=this.index;return"color"+(r>0?r:"")}generate(r){let t=this.getAttributeName(r),e=r.hasGeometryAttribute(t),s;return s=e===!0?super.generate(r):r.generateConst(this.nodeType,new wr(1,1,1,1)),s}serialize(r){super.serialize(r),r.index=this.index}deserialize(r){super.deserialize(r),this.index=r.index}};const p2=(r=0)=>W(new RR(r));var $a=class extends Lr{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(r){}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:r=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=r}})}customProgramCacheKey(){return this.type+Nw(this)}build(r){this.setup(r)}setupObserver(r){return new hC(r)}setup(r){r.context.setupNormal=()=>this.setupNormal(r),r.context.setupPositionView=()=>this.setupPositionView(r),r.context.setupModelViewProjection=()=>this.setupModelViewProjection(r);let t=r.renderer,e=t.getRenderTarget();r.addStack();let s=this.setupVertex(r),i=this.vertexNode||s;r.stack.outputNode=i,this.setupHardwareClipping(r),this.geometryNode!==null&&(r.stack.outputNode=r.stack.outputNode.bypass(this.geometryNode)),r.addFlow("vertex",r.removeStack()),r.addStack();let n,a=this.setupClipping(r);if((this.depthWrite===!0||this.depthTest===!0)&&(e===null?t.depth===!0&&this.setupDepth(r):e.depthBuffer===!0&&this.setupDepth(r)),this.fragmentNode===null){this.setupDiffuseColor(r),this.setupVariants(r);let o=this.setupLighting(r);a!==null&&r.stack.add(a);let l=ut(o,as.a).max(0);n=this.setupOutput(r,l),ol.assign(n);let h=this.outputNode!==null;if(h&&(n=this.outputNode),e!==null){let u=t.getMRT(),c=this.mrtNode;u===null?c!==null&&(n=c):(h&&ol.assign(n),n=u,c!==null&&(n=u.merge(c)))}}else{let o=this.fragmentNode;o.isOutputStructNode!==!0&&(o=ut(o)),n=this.setupOutput(r,o)}r.stack.outputNode=n,r.addFlow("fragment",r.removeStack()),r.observer=this.setupObserver(r)}setupClipping(r){if(r.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:e}=r.clippingContext,s=null;if(t.length>0||e.length>0){let i=r.renderer.samples;this.alphaToCoverage&&i>1?s=zR():r.stack.add(AR())}return s}setupHardwareClipping(r){if(this.hardwareClipping=!1,r.clippingContext===null)return;let t=r.clippingContext.unionPlanes.length;t>0&&t<=8&&r.isAvailable("clipDistance")&&(r.stack.add(CR()),this.hardwareClipping=!0)}setupDepth(r){let{renderer:t,camera:e}=r,s=this.depthNode;if(s===null){let i=t.getMRT();i&&i.has("depth")?s=i.get("depth"):t.logarithmicDepthBuffer===!0&&(s=e.isPerspectiveCamera?Ly(ar.z,Ln,In):ll(ar.z,Ln,In))}s!==null&&Iy.assign(s).toStack()}setupPositionView(){return ph.mul(Se).xyz}setupModelViewProjection(){return dh.mul(ar)}setupVertex(r){return r.addStack(),this.setupPosition(r),r.context.vertex=r.removeStack(),JT}setupPosition(r){let{object:t,geometry:e}=r;if((e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color)&&a2(t).toStack(),t.isSkinnedMesh===!0&&i2(t).toStack(),this.displacementMap){let s=Pn("displacementMap","texture"),i=Pn("displacementScale","float"),n=Pn("displacementBias","float");Se.addAssign(Pr.normalize().mul(s.x.mul(i).add(n)))}return t.isBatchedMesh&&r2(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&e2(t).toStack(),this.positionNode!==null&&Se.assign(mT(this.positionNode,"POSITION")),Se}setupDiffuseColor({object:r,geometry:t}){this.maskNode!==null&&fi(this.maskNode).not().discard();let e=this.colorNode?ut(this.colorNode):qT;this.vertexColors===!0&&t.hasAttribute("color")&&(e=e.mul(p2())),r.instanceColor&&(e=Wu("vec3","vInstanceColor").mul(e)),r.isBatchedMesh&&r._colorsTexture&&(e=Wu("vec3","vBatchColor").mul(e)),as.assign(e);let s=this.opacityNode?v(this.opacityNode):GT;as.a.assign(as.a.mul(s));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?WT:v(this.alphaTestNode),as.a.lessThanEqual(i).discard()),this.alphaHash===!0&&as.a.lessThan(VR(Se)).discard(),this.transparent===!1&&this.blending===Uf&&this.alphaToCoverage===!1?as.a.assign(1):i===null&&as.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?E(0):as.rgb}setupNormal(){return this.normalNode?E(this.normalNode):XT}setupEnvironment(){let r=null;return this.envNode?r=this.envNode:this.envMap&&(r=this.envMap.isCubeTexture?Pn("envMap","cubeTexture"):Pn("envMap","texture")),r}setupLightMap(r){let t=null;return r.material.lightMap&&(t=new yR(YT)),t}setupLights(r){let t=[],e=this.setupEnvironment(r);e&&e.isLightingNode&&t.push(e);let s=this.setupLightMap(r);if(s&&s.isLightingNode&&t.push(s),this.aoNode!==null||r.material.aoMap){let n=this.aoNode===null?ZT:this.aoNode;t.push(new fR(n))}let i=this.lightsNode||r.lightsNode;return t.length>0&&(i=r.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(r){let{material:t}=r,{backdropNode:e,backdropAlphaNode:s,emissiveNode:i}=this,n=this.lights===!0||this.lightsNode!==null,a=n?this.setupLights(r):null,o=this.setupOutgoingLight(r);if(a&&a.getScope().hasLights){let l=this.setupLightingModel(r)||null;o=l2(a,l,e,s)}else e!==null&&(o=E(s===null?e:fe(o,e,s)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Gf.assign(E(i||HT)),o=o.add(Gf)),o}setupFog(r,t){let e=r.fogNode;return e&&(ol.assign(t),t=ut(e)),t}setupOutput(r,t){return this.fog===!0&&(t=this.setupFog(r,t)),t}setDefaultValues(r){for(let e in r){let s=r[e];this[e]===void 0&&(this[e]=s,s&&s.clone&&(this[e]=s.clone()))}let t=Object.getOwnPropertyDescriptors(r.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(r){let t=r===void 0||typeof r=="string";t&&(r={textures:{},images:{},nodes:{}});let e=Lr.prototype.toJSON.call(this,r),s=Ed(this);e.inputNodes={};for(let{property:n,childNode:a}of s)e.inputNodes[n]=a.toJSON(r).uuid;function i(n){let a=[];for(let o in n){let l=n[o];delete l.metadata,a.push(l)}return a}if(t){let n=i(r.textures),a=i(r.images),o=i(r.nodes);n.length>0&&(e.textures=n),a.length>0&&(e.images=a),o.length>0&&(e.nodes=o)}return e}copy(r){return this.lightsNode=r.lightsNode,this.envNode=r.envNode,this.colorNode=r.colorNode,this.normalNode=r.normalNode,this.opacityNode=r.opacityNode,this.backdropNode=r.backdropNode,this.backdropAlphaNode=r.backdropAlphaNode,this.alphaTestNode=r.alphaTestNode,this.maskNode=r.maskNode,this.positionNode=r.positionNode,this.geometryNode=r.geometryNode,this.depthNode=r.depthNode,this.receivedShadowPositionNode=r.receivedShadowPositionNode,this.castShadowPositionNode=r.castShadowPositionNode,this.receivedShadowNode=r.receivedShadowNode,this.castShadowNode=r.castShadowNode,this.outputNode=r.outputNode,this.mrtNode=r.mrtNode,this.fragmentNode=r.fragmentNode,this.vertexNode=r.vertexNode,super.copy(r)}};new gw;new nC;let Nm=null;var LR=class extends Np{static get type(){return"ViewportSharedTextureNode"}constructor(r=na,t=null){Nm===null&&(Nm=new yw),super(r,t,Nm)}updateReference(){return this}};const IR=H(LR).setParameterLength(0,2),PR=r=>W(r).mul(.5).add(.5),FR=r=>W(r).mul(2).sub(1);new rC;var OR=class extends we{static get type(){return"EquirectUVNode"}constructor(r=My){super("vec2"),this.dirNode=r}setup(){let r=this.dirNode,t=r.z.atan(r.x).mul(1/(Math.PI*2)).add(.5),e=r.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,e)}};const Py=H(OR).setParameterLength(0,1);var BR=class extends Hz{constructor(r=1,t={}){super(r,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(r,t){let e=t.minFilter,s=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 Gg(5,5,5),n=Py(My),a=new $a;a.colorNode=Bt(t,n,0),a.side=Ha,a.blending=Ug;let o=new zl(i,a),l=new Zg;l.add(o),t.minFilter===op&&(t.minFilter=Da);let h=new dw(1,10,this),u=r.getMRT();return r.setMRT(null),h.update(r,l),r.setMRT(u),t.minFilter=e,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}};const Vu=new WeakMap;var kR=class extends we{static get type(){return"CubeMapNode"}constructor(r){super("vec3"),this.envNode=r,this._cubeTexture=null,this._cubeTextureNode=wp(null);let t=new Yg;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=It.RENDER}updateBefore(r){let{renderer:t,material:e}=r,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){let i=s.isTextureNode?s.value:e[s.property];if(i&&i.isTexture){let n=i.mapping;if(n===Jv||n===Qv){if(Vu.has(i)){let a=Vu.get(i);Kx(a,i.mapping),this._cubeTexture=a}else{let a=i.image;if(DR(a)){let o=new BR(a.height);o.fromEquirectangularTexture(t,i),Kx(o.texture,i.mapping),this._cubeTexture=o.texture,Vu.set(i,o.texture),i.addEventListener("dispose",m2)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(r){return this.updateBefore(r),this._cubeTextureNode}};function DR(r){return r==null?!1:r.height>0}function m2(r){let t=r.target;t.removeEventListener("dispose",m2);let e=Vu.get(t);e!==void 0&&(Vu.delete(t),e.dispose())}function Kx(r,t){t===Jv?r.mapping=Uu:t===Qv&&(r.mapping=Sd)}H(kR).setParameterLength(1);new Hg;const Gu=C(({f0:r,f90:t,dotVH:e})=>{let s=e.mul(-5.55473).sub(6.98316).mul(e).exp2();return r.mul(s.oneMinus()).add(t.mul(s))}),UR=C(r=>r.diffuseColor.mul(1/Math.PI)),$R=()=>v(.25),jR=C(({dotNH:r})=>Yf.mul(v(.5)).add(1).mul(v(1/Math.PI)).mul(r.pow(Yf)));C(({lightDirection:r})=>{let t=r.add(lr).normalize(),e=Kr.dot(t).clamp(),s=lr.dot(t).clamp(),i=Gu({f0:Jw,f90:1,dotVH:s}),n=$R(),a=jR({dotNH:e});return i.mul(n).mul(a)});new sC;new tC;const f2=C(r=>{if(r.geometry.hasAttribute("normal")===!1)return v(0);let t=yi.dFdx().abs().max(yi.dFdy().abs());return t.x.max(t.y).max(t.z)}),WR=C(r=>{let{roughness:t}=r,e=f2(),s=t.max(.0525);return s=s.add(e),s=s.min(1),s}),g2=C(({alpha:r,dotNL:t,dotNV:e})=>{let s=r.pow2(),i=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt()),n=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return Js(.5,i.add(n).max(NM))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),qR=C(({alphaT:r,alphaB:t,dotTV:e,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{let l=o.mul(E(r.mul(e),t.mul(s),a).length()),h=a.mul(E(r.mul(i),t.mul(n),o).length());return Js(.5,l.add(h)).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"}]}),y2=C(({alpha:r,dotNH:t})=>{let e=r.pow2(),s=t.pow2().mul(e.oneMinus()).oneMinus();return e.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),HR=v(1/Math.PI),GR=C(({alphaT:r,alphaB:t,dotNH:e,dotTH:s,dotBH:i})=>{let n=r.mul(t),a=E(t.mul(s),r.mul(i),n.mul(e)),o=a.dot(a),l=n.div(o);return HR.mul(n.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),XR=C(r=>{let{lightDirection:t,f0:e,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=r,l=r.normalView||Kr,h=i.pow2(),u=t.add(lr).normalize(),c=l.dot(t).clamp(),d=l.dot(lr).clamp(),p=l.dot(u).clamp(),m=lr.dot(u).clamp(),f=Gu({f0:e,f90:s,dotVH:m}),x,b;if(ju(a)&&(f=Yw.mix(f,n)),ju(o)){let w=md.dot(t),S=md.dot(lr),_=md.dot(u),V=al.dot(t),z=al.dot(lr),A=al.dot(u);x=qR({alphaT:Xf,alphaB:h,dotTV:S,dotBV:z,dotTL:w,dotBL:V,dotNV:d,dotNL:c}),b=GR({alphaT:Xf,alphaB:h,dotNH:p,dotTH:_,dotBH:A})}else x=g2({alpha:h,dotNL:c,dotNV:d}),b=y2({alpha:h,dotNH:p});return f.mul(x).mul(b)}),x2=C(({roughness:r,dotNV:t})=>{let e=ut(-1,-.0275,-.572,.022),s=ut(1,.0425,1.04,-.04),i=r.mul(e).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Y(-1.04,1.04).mul(n).add(i.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),YR=C(r=>{let{dotNV:t,specularColor:e,specularF90:s,roughness:i}=r,n=x2({dotNV:t,roughness:i});return e.mul(n.x).add(s.mul(n.y))}),ZR=C(({f:r,f90:t,dotVH:e})=>{let s=e.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return r.sub(E(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),JR=C(({roughness:r,dotNH:t})=>{let e=r.pow2(),s=v(1).div(e),i=t.pow2(),n=i.oneMinus().max(.0078125);return v(2).add(s).mul(n.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),QR=C(({dotNV:r,dotNL:t})=>v(1).div(v(4).mul(t.add(r).sub(t.mul(r))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]});C(({lightDirection:r})=>{let t=r.add(lr).normalize(),e=Kr.dot(r).clamp(),s=Kr.dot(lr).clamp(),i=Kr.dot(t).clamp(),n=JR({roughness:Xw,dotNH:i}),a=QR({dotNV:s,dotNL:e});return Gw.mul(n).mul(a)});C(({N:r,V:t,roughness:e})=>{let s=64,i=(s-1)/s,n=.5/s,a=r.dot(t).saturate(),o=Y(e,a.oneMinus().sqrt());return o.assign(o.mul(i).add(n)),o}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]});const KR=C(({f:r})=>{let t=r.length();return ye(t.mul(t).add(r.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),cc=C(({v1:r,v2:t})=>{let e=r.dot(t),s=e.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),a=i.div(n),o=e.greaterThan(0).select(a,ye(e.mul(e).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return r.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]});C(({N:r,V:t,P:e,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{let l=n.sub(i).toVar(),h=o.sub(i).toVar(),u=l.cross(h),c=E().toVar();return xt(u.dot(e.sub(i)).greaterThanEqual(0),()=>{let d=t.sub(r.mul(t.dot(r))).normalize(),p=r.cross(d).negate(),m=s.mul(Ir(d,p,r).transpose()).toVar(),f=m.mul(i.sub(e)).normalize().toVar(),x=m.mul(n.sub(e)).normalize().toVar(),b=m.mul(a.sub(e)).normalize().toVar(),w=m.mul(o.sub(e)).normalize().toVar(),S=E(0).toVar();S.addAssign(cc({v1:f,v2:x})),S.addAssign(cc({v1:x,v2:b})),S.addAssign(cc({v1:b,v2:w})),S.addAssign(cc({v1:w,v2:f})),c.assign(E(KR({f:S})))}),c}).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"}]});const Sp=1/6,b2=r=>gt(Sp,gt(r,gt(r,r.negate().add(3)).sub(3)).add(1)),tg=r=>gt(Sp,gt(r,gt(r,gt(3,r).sub(6))).add(4)),v2=r=>gt(Sp,gt(r,gt(r,gt(-3,r).add(3)).add(3)).add(1)),eg=r=>gt(Sp,Xs(r,3)),t1=r=>b2(r).add(tg(r)),e1=r=>v2(r).add(eg(r)),r1=r=>Ce(-1,tg(r).div(b2(r).add(tg(r)))),s1=r=>Ce(1,eg(r).div(v2(r).add(eg(r)))),i1=(r,t,e)=>{let s=r.uvNode,i=gt(s,t.zw).add(.5),n=ui(i),a=cn(i),o=t1(a.x),l=e1(a.x),h=r1(a.x),u=s1(a.x),c=r1(a.y),d=s1(a.y),p=Y(n.x.add(h),n.y.add(c)).sub(.5).mul(t.xy),m=Y(n.x.add(u),n.y.add(c)).sub(.5).mul(t.xy),f=Y(n.x.add(h),n.y.add(d)).sub(.5).mul(t.xy),x=Y(n.x.add(u),n.y.add(d)).sub(.5).mul(t.xy),b=t1(a.y).mul(Ce(o.mul(r.sample(p).level(e)),l.mul(r.sample(m).level(e)))),w=e1(a.y).mul(Ce(o.mul(r.sample(f).level(e)),l.mul(r.sample(x).level(e))));return b.add(w)},w2=C(([r,t=v(3)])=>{let e=Y(r.size(T(t))),s=Y(r.size(T(t.add(1)))),i=Js(1,e),n=Js(1,s),a=i1(r,ut(i,e),ui(t)),o=i1(r,ut(n,s),gp(t));return cn(t).mix(a,o)}),n1=C(([r,t,e,s,i])=>{let n=E(dy(t.negate(),en(r),Js(1,s))),a=E(hi(i[0].xyz),hi(i[1].xyz),hi(i[2].xyz));return en(n).mul(e.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),t4=C(([r,t])=>r.mul(gi(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),e4=Ey(),r4=Ey(),a1=C(([r,t,e],{material:s})=>{let i=s.side===Ha?e4:r4,n=i.sample(r),a=li(Hu.x).mul(t4(t,e));return w2(n,a)}),o1=C(([r,t,e])=>(xt(e.notEqual(0),()=>{let s=fp(t).negate().div(e);return ny(s.negate().mul(r))}),E(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]});C(([r,t,e,s,i,n,a,o,l,h,u,c,d,p,m])=>{let f,x;if(m){f=ut().toVar(),x=E().toVar();let V=u.sub(1).mul(m.mul(.025)),z=E(u.sub(V),u,u.add(V));Pt({start:0,end:3},({i:A})=>{let I=z.element(A),et=n1(r,t,c,I,o),nt=a.add(et),it=h.mul(l.mul(ut(nt,1))),vt=Y(it.xy.div(it.w)).toVar();vt.addAssign(1),vt.divAssign(2),vt.assign(Y(vt.x,vt.y.oneMinus()));let mt=a1(vt,e,I);f.element(A).assign(mt.element(A)),f.a.addAssign(mt.a),x.element(A).assign(s.element(A).mul(o1(hi(et),d,p).element(A)))}),f.a.divAssign(3)}else{let V=n1(r,t,c,u,o),z=a.add(V),A=h.mul(l.mul(ut(z,1))),I=Y(A.xy.div(A.w)).toVar();I.addAssign(1),I.divAssign(2),I.assign(Y(I.x,I.y.oneMinus())),f=a1(I,e,u),x=s.mul(o1(hi(V),d,p))}let b=x.rgb.mul(f.rgb),w=r.dot(t).clamp(),S=E(YR({dotNV:w,specularColor:i,specularF90:n,roughness:e})),_=x.r.add(x.g,x.b).div(3);return ut(S.oneMinus().mul(b),f.a.oneMinus().mul(_).oneMinus())});const s4=Ir(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),i4=r=>{let t=r.sqrt();return E(1).add(t).div(E(1).sub(t))},l1=(r,t)=>r.sub(t).div(r.add(t)).pow2(),n4=(r,t)=>{let e=r.mul(2*Math.PI*1e-9),s=E(54856e-17,44201e-17,52481e-17),i=E(1681e3,1795300,2208400),n=E(43278e5,93046e5,66121e5),a=v(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(e.mul(2239900).add(t.x).cos()).mul(e.pow2().mul(-45282e5).exp()),o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(e).add(t).cos()).mul(e.pow2().negate().mul(n).exp());return o=E(o.x.add(a),o.y,o.z).div(10685e-11),s4.mul(o)};C(({outsideIOR:r,eta2:t,cosTheta1:e,thinFilmThickness:s,baseF0:i})=>{let n=fe(r,t,rn(0,.03,s)),a=r.div(n).pow2().mul(e.pow2().oneMinus()),o=a.oneMinus();xt(o.lessThan(0),()=>E(1));let l=o.sqrt(),h=l1(n,r),u=Gu({f0:h,f90:1,dotVH:e}),c=u.oneMinus(),d=n.lessThan(r).select(Math.PI,0),p=v(Math.PI).sub(d),m=i4(i.clamp(0,.9999)),f=l1(m,n.toVec3()),x=Gu({f0:f,f90:1,dotVH:l}),b=E(m.x.lessThan(n).select(Math.PI,0),m.y.lessThan(n).select(Math.PI,0),m.z.lessThan(n).select(Math.PI,0)),w=n.mul(s,l,2),S=E(p).add(b),_=u.mul(x).clamp(1e-5,.9999),V=_.sqrt(),z=c.pow2().mul(x).div(E(1).sub(_)),A=u.add(z),I=A.toVar(),et=z.sub(c).toVar();return Pt({start:1,end:2,condition:"<=",name:"m"},({m:nt})=>{et.mulAssign(V);let it=n4(v(nt).mul(w),v(nt).mul(S)).mul(2);I.addAssign(et.mul(it))}),I.max(E(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"}]});C(({normal:r,viewDir:t,roughness:e})=>{let s=r.dot(t).saturate(),i=e.pow2(),n=Qe(e.lessThan(.25),v(-339.2).mul(i).add(v(161.4).mul(e)).sub(25.9),v(-8.48).mul(i).add(v(14.3).mul(e)).sub(9.95)),a=Qe(e.lessThan(.25),v(44).mul(i).sub(v(23.7).mul(e)).add(3.26),v(1.97).mul(i).sub(v(3.27).mul(e)).add(.72));return Qe(e.lessThan(.25),0,v(.1).mul(e).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()});E(.04);v(1);const u1=v(1),rg=v(-2),dc=v(.8),Sm=v(-1),pc=v(.4),_m=v(2),mc=v(.305),Am=v(3),h1=v(.21),a4=v(4),c1=v(4),o4=v(16),l4=C(([r])=>{let t=E(Jt(r)).toVar(),e=v(-1).toVar();return xt(t.x.greaterThan(t.z),()=>{xt(t.x.greaterThan(t.y),()=>{e.assign(Qe(r.x.greaterThan(0),0,3))}).Else(()=>{e.assign(Qe(r.y.greaterThan(0),1,4))})}).Else(()=>{xt(t.z.greaterThan(t.y),()=>{e.assign(Qe(r.z.greaterThan(0),2,5))}).Else(()=>{e.assign(Qe(r.y.greaterThan(0),1,4))})}),e}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),u4=C(([r,t])=>{let e=Y().toVar();return xt(t.equal(0),()=>{e.assign(Y(r.z,r.y).div(Jt(r.x)))}).ElseIf(t.equal(1),()=>{e.assign(Y(r.x.negate(),r.z.negate()).div(Jt(r.y)))}).ElseIf(t.equal(2),()=>{e.assign(Y(r.x.negate(),r.y).div(Jt(r.z)))}).ElseIf(t.equal(3),()=>{e.assign(Y(r.z.negate(),r.y).div(Jt(r.x)))}).ElseIf(t.equal(4),()=>{e.assign(Y(r.x.negate(),r.z).div(Jt(r.y)))}).Else(()=>{e.assign(Y(r.x,r.y).div(Jt(r.z)))}),gt(.5,e.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),h4=C(([r])=>{let t=v(0).toVar();return xt(r.greaterThanEqual(dc),()=>{t.assign(u1.sub(r).mul(Sm.sub(rg)).div(u1.sub(dc)).add(rg))}).ElseIf(r.greaterThanEqual(pc),()=>{t.assign(dc.sub(r).mul(_m.sub(Sm)).div(dc.sub(pc)).add(Sm))}).ElseIf(r.greaterThanEqual(mc),()=>{t.assign(pc.sub(r).mul(Am.sub(_m)).div(pc.sub(mc)).add(_m))}).ElseIf(r.greaterThanEqual(h1),()=>{t.assign(mc.sub(r).mul(a4.sub(Am)).div(mc.sub(h1)).add(Am))}).Else(()=>{t.assign(v(-2).mul(li(gt(1.16,r))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),M2=C(([r,t])=>{let e=r.toVar();e.assign(gt(2,e).sub(1));let s=E(e,1).toVar();return xt(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),T2=C(([r,t,e,s,i,n])=>{let a=v(e),o=E(t),l=gi(h4(a),rg,n),h=cn(l),u=ui(l),c=E(sg(r,o,u,s,i,n)).toVar();return xt(h.notEqual(0),()=>{let d=E(sg(r,o,u.add(1),s,i,n)).toVar();c.assign(fe(c,d,h))}),c}),sg=C(([r,t,e,s,i,n])=>{let a=v(e).toVar(),o=E(t),l=v(l4(o)).toVar(),h=v(ye(c1.sub(a),0)).toVar();a.assign(ye(a,c1));let u=v(Cl(a)).toVar(),c=Y(u4(o,l).mul(u.sub(2)).add(1)).toVar();return xt(l.greaterThan(2),()=>{c.y.addAssign(u),l.subAssign(3)}),c.x.addAssign(l.mul(u)),c.x.addAssign(h.mul(gt(3,o4))),c.y.addAssign(gt(4,Cl(n).sub(u))),c.x.mulAssign(s),c.y.mulAssign(i),r.sample(c).grad(Y(),Y())}),zm=C(({envMap:r,mipInt:t,outputDirection:e,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{let l=ki(s),h=e.mul(l).add(i.cross(e).mul(Xr(s))).add(i.mul(i.dot(e).mul(l.oneMinus())));return sg(r,h,t,n,a,o)}),N2=C(({n:r,latitudinal:t,poleAxis:e,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{let d=E(Qe(t,e,xp(e,s))).toVar();xt(d.equal(E(0)),()=>{d.assign(E(s.z,0,s.x.negate()))}),d.assign(en(d));let p=E().toVar();return p.addAssign(i.element(0).mul(zm({theta:0,axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Pt({start:T(1),end:r},({i:m})=>{xt(m.greaterThanEqual(n),()=>{n2()});let f=v(a.mul(v(m))).toVar();p.addAssign(i.element(m).mul(zm({theta:f.mul(-1),axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(m).mul(zm({theta:f,axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))}),ut(p,1)}),Qo=4,d1=[.125,.215,.35,.446,.526,.582],Sa=20,Cm=new bw(-1,1,1,-1,0,1),c4=new wa(90,1),p1=new Kt;let Em=null,Vm=0,Rm=0;const Ta=(1+Math.sqrt(5))/2,fo=1/Ta,m1=[new B(-Ta,fo,0),new B(Ta,fo,0),new B(-fo,0,Ta),new B(fo,0,Ta),new B(0,Ta,-fo),new B(0,Ta,fo),new B(-1,1,-1),new B(1,1,-1),new B(-1,1,1),new B(1,1,1)],d4=new B,S2=new WeakMap,p4=[3,1,5,0,4,2],Lm=M2(oe(),Zn("faceIndex")).normalize(),Fy=E(Lm.x,Lm.y,Lm.z);var m4=class{constructor(r){this._renderer=r,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(r,t=0,e=.1,s=100,i={}){let{size:n=256,position:a=d4,renderTarget:o=null}=i;if(this._setSize(n),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");let h=o||this._allocateTarget();return i.renderTarget=h,this.fromSceneAsync(r,t,e,s,i),h}Em=this._renderer.getRenderTarget(),Vm=this._renderer.getActiveCubeFace(),Rm=this._renderer.getActiveMipmapLevel();let l=o||this._allocateTarget();return l.depthBuffer=!0,this._init(l),this._sceneToCubeUV(r,e,s,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(r,t=0,e=.1,s=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(r,t,e,s,i)}fromEquirectangular(r,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(r);let e=t||this._allocateTarget();return this.fromEquirectangularAsync(r,e),e}return this._fromTexture(r,t)}async fromEquirectangularAsync(r,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(r,t)}fromCubemap(r,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(r);let e=t||this._allocateTarget();return this.fromCubemapAsync(r,t),e}return this._fromTexture(r,t)}async fromCubemapAsync(r,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(r,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g1(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=y1(),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(r){r.mapping===Uu||r.mapping===Sd?this._setSize(r.image.length===0?16:r.image[0].width||r.image[0].image.width):this._setSize(r.image.width/4)}_setSize(r){this._lodMax=Math.floor(Math.log2(r)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let r=0;r<this._lodPlanes.length;r++)this._lodPlanes[r].dispose()}_cleanup(r){this._renderer.setRenderTarget(Em,Vm,Rm),r.scissorTest=!1,fc(r,0,0,r.width,r.height)}_fromTexture(r,t){this._setSizeFromTexture(r),Em=this._renderer.getRenderTarget(),Vm=this._renderer.getActiveCubeFace(),Rm=this._renderer.getActiveMipmapLevel();let e=t||this._allocateTarget();return this._init(e),this._textureToCubeUV(r,e),this._applyPMREM(e),this._cleanup(e),e}_allocateTarget(){let r=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return f1(r,t)}_init(r){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==r.width||this._pingPongRenderTarget.height!==r.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=f1(r.width,r.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=f4(t)),this._blurMaterial=g4(t,r.width,r.height)}}async _compileMaterial(r){let t=new zl(this._lodPlanes[0],r);await this._renderer.compile(t,Cm)}_sceneToCubeUV(r,t,e,s,i){let n=c4;n.near=t,n.far=e;let a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],l=this._renderer,h=l.autoClear;l.getClearColor(p1),l.autoClear=!1;let u=this._backgroundBox;if(u===null){let p=new Hg({name:"PMREM.Background",side:Ha,depthWrite:!1,depthTest:!1});u=new zl(new Gg,p)}let c=!1,d=r.background;d?d.isColor&&(u.material.color.copy(d),r.background=null,c=!0):(u.material.color.copy(p1),c=!0),l.setRenderTarget(s),l.clear(),c&&l.render(u,n);for(let p=0;p<6;p++){let m=p%3;m===0?(n.up.set(0,a[p],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[p],i.y,i.z)):m===1?(n.up.set(0,0,a[p]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[p],i.z)):(n.up.set(0,a[p],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[p]));let f=this._cubeSize;fc(s,m*f,p>2?f:0,f,f),l.render(r,n)}l.autoClear=h,r.background=d}_textureToCubeUV(r,t){let e=this._renderer,s=r.mapping===Uu||r.mapping===Sd;s?this._cubemapMaterial===null&&(this._cubemapMaterial=g1(r)):this._equirectMaterial===null&&(this._equirectMaterial=y1(r));let i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=r;let n=this._lodMeshes[0];n.material=i;let a=this._cubeSize;fc(t,0,0,3*a,2*a),e.setRenderTarget(t),e.render(n,Cm)}_applyPMREM(r){let t=this._renderer,e=t.autoClear;t.autoClear=!1;let s=this._lodPlanes.length;for(let i=1;i<s;i++){let n=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=m1[(s-i-1)%m1.length];this._blur(r,i-1,i,n,a)}t.autoClear=e}_blur(r,t,e,s,i){let n=this._pingPongRenderTarget;this._halfBlur(r,n,t,e,s,"latitudinal",i),this._halfBlur(n,r,e,e,s,"longitudinal",i)}_halfBlur(r,t,e,s,i,n,a){let o=this._renderer,l=this._blurMaterial;n!=="latitudinal"&&n!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=this._lodMeshes[s];u.material=l;let c=S2.get(l),d=this._sizeLods[e]-1,p=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*Sa-1),m=i/p,f=isFinite(i)?1+Math.floor(h*m):Sa;f>Sa&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${Sa}`);let x=[],b=0;for(let z=0;z<Sa;++z){let A=z/m,I=Math.exp(-A*A/2);x.push(I),z===0?b+=I:z<f&&(b+=2*I)}for(let z=0;z<x.length;z++)x[z]=x[z]/b;r.texture.frame=(r.texture.frame||0)+1,c.envMap.value=r.texture,c.samples.value=f,c.weights.array=x,c.latitudinal.value=n==="latitudinal"?1:0,a&&(c.poleAxis.value=a);let{_lodMax:w}=this;c.dTheta.value=p,c.mipInt.value=w-e;let S=this._sizeLods[s],_=3*S*(s>w-Qo?s-w+Qo:0),V=4*(this._cubeSize-S);fc(t,_,V,3*S,2*S),o.setRenderTarget(t),o.render(u,Cm)}};function f4(r){let t=[],e=[],s=[],i=[],n=r,a=r-Qo+1+d1.length;for(let o=0;o<a;o++){let l=2**n;e.push(l);let h=1/l;o>r-Qo?h=d1[o-r+Qo-1]:o===0&&(h=0),s.push(h);let u=1/(l-2),c=-u,d=1+u,p=[c,c,d,c,d,d,c,c,d,d,c,d],m=6,f=6,x=3,b=2,w=1,S=new Float32Array(x*f*m),_=new Float32Array(b*f*m),V=new Float32Array(w*f*m);for(let A=0;A<m;A++){let I=A%3*2/3-1,et=A>2?0:-1,nt=[I,et,0,I+2/3,et,0,I+2/3,et+1,0,I,et,0,I+2/3,et+1,0,I,et+1,0],it=p4[A];S.set(nt,x*f*it),_.set(p,b*f*it);let vt=[it,it,it,it,it,it];V.set(vt,w*f*it)}let z=new up;z.setAttribute("position",new ms(S,x)),z.setAttribute("uv",new ms(_,b)),z.setAttribute("faceIndex",new ms(V,w)),t.push(z),i.push(new zl(z,null)),n>Qo&&n--}return{lodPlanes:t,sizeLods:e,sigmas:s,lodMeshes:i}}function f1(r,t){let e={magFilter:Da,minFilter:Da,generateMipmaps:!1,type:Bn,format:ew,colorSpace:Ad},s=new Ol(r,t,e);return s.texture.mapping=ZA,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function fc(r,t,e,s,i){r.viewport.set(t,e,s,i),r.scissor.set(t,e,s,i)}function Oy(r){let t=new $a;return t.depthTest=!1,t.depthWrite=!1,t.blending=Ug,t.name=`PMREM_${r}`,t}function g4(r,t,e){let s=js(Array(Sa).fill(0)),i=ct(new B(0,1,0)),n=ct(0),a=v(Sa),o=ct(0),l=ct(1),h=Bt(null),u=ct(0),c=v(1/t),d=v(1/e),p=v(r),m={n:a,latitudinal:o,weights:s,poleAxis:i,outputDirection:Fy,dTheta:n,samples:l,envMap:h,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},f=Oy("blur");return f.fragmentNode=N2({...m,latitudinal:o.equal(1)}),S2.set(f,m),f}function g1(r){let t=Oy("cubemap");return t.fragmentNode=wp(r,Fy),t}function y1(r){let t=Oy("equirect");return t.fragmentNode=Bt(r,Py(Fy),0),t}const x1=new WeakMap;function y4(r){let t=Math.log2(r)-2,e=1/r;return{texelWidth:1/(3*Math.max(2**t,7*16)),texelHeight:e,maxMip:t}}function x4(r,t,e){let s=b4(t),i=s.get(r);if((i===void 0?-1:i.pmremVersion)!==r.pmremVersion){let a=r.image;if(r.isCubeTexture)if(w4(a))i=e.fromCubemap(r,i);else return null;else if(M4(a))i=e.fromEquirectangular(r,i);else return null;i.pmremVersion=r.pmremVersion,s.set(r,i)}return i.texture}function b4(r){let t=x1.get(r);return t===void 0&&(t=new WeakMap,x1.set(r,t)),t}var v4=class extends we{static get type(){return"PMREMNode"}constructor(r,t=null,e=null){super("vec3"),this._value=r,this._pmrem=null,this.uvNode=t,this.levelNode=e,this._generator=null;let s=new oi;s.isRenderTargetTexture=!0,this._texture=Bt(s),this._width=ct(0),this._height=ct(0),this._maxMip=ct(0),this.updateBeforeType=It.RENDER}set value(r){this._value=r,this._pmrem=null}get value(){return this._value}updateFromTexture(r){let t=y4(r.image.height);this._texture.value=r,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(r){let t=this._pmrem,e=t?t.pmremVersion:-1,s=this._value;e!==s.pmremVersion&&(t=s.isPMREMTexture===!0?s:x4(s,r.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(r){this._generator===null&&(this._generator=new m4(r.renderer)),this.updateBefore(r);let t=this.uvNode;t===null&&r.context.getUV&&(t=r.context.getUV(this)),t=Sy.mul(E(t.x,t.y.negate(),t.z));let e=this.levelNode;return e===null&&r.context.getTextureLevel&&(e=r.context.getTextureLevel(this)),T2(this._texture,t,e,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function w4(r){if(r==null)return!1;let t=0,e=6;for(let s=0;s<e;s++)r[s]!==void 0&&t++;return t===e}function M4(r){return r==null?!1:r.height>0}const T4=H(v4).setParameterLength(1,3);new xw;new Kz;C(({normal:r,lightDirection:t,builder:e})=>{let s=r.dot(t),i=Y(s.mul(.5).add(.5),0);if(e.material.gradientMap){let n=Pn("gradientMap","texture").context({getUV:()=>i});return E(n.r)}else{let n=i.fwidth().mul(.5);return fe(E(.7),E(1),rn(v(.7).sub(n.x),v(.7).add(n.x),i.x))}});new eC;var N4=class extends we{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){let r=E(lr.z,0,lr.x.negate()).normalize(),t=lr.cross(r);return Y(r.dot(Kr),t.dot(Kr)).mul(.495).add(.5)}};const S4=Q(N4);new iC;var _4=class extends we{static get type(){return"RotateNode"}constructor(r,t){super(),this.positionNode=r,this.rotationNode=t}getNodeType(r){return this.positionNode.getNodeType(r)}setup(r){let{rotationNode:t,positionNode:e}=this;if(this.getNodeType(r)==="vec2"){let i=t.cos(),n=t.sin();return pp(i,n,n.negate(),i).mul(e)}else{let i=t,n=Va(ut(1,0,0,0),ut(0,ki(i.x),Xr(i.x).negate(),0),ut(0,Xr(i.x),ki(i.x),0),ut(0,0,0,1)),a=Va(ut(ki(i.y),0,Xr(i.y),0),ut(0,1,0,0),ut(Xr(i.y).negate(),0,ki(i.y),0),ut(0,0,0,1)),o=Va(ut(ki(i.z),Xr(i.z).negate(),0,0),ut(Xr(i.z),ki(i.z),0,0),ut(0,0,1,0),ut(0,0,0,1));return n.mul(a).mul(o).mul(ut(e,1)).xyz}}};const _2=H(_4).setParameterLength(2);new Xz;new Jz;new Qz;Dl("vec3");Dl("vec3");Dl("vec3");var A4=class{constructor(){this.weakMap=new WeakMap}get(r){let t=this.weakMap;for(let e=0;e<r.length-1;e++)if(t=t.get(r[e]),t===void 0)return;return t.get(r[r.length-1])}set(r,t){let e=this.weakMap;for(let s=0;s<r.length-1;s++){let i=r[s];e.has(i)===!1&&e.set(i,new WeakMap),e=e.get(i)}return e.set(r[r.length-1],t),this}delete(r){let t=this.weakMap;for(let e=0;e<r.length-1;e++)if(t=t.get(r[e]),t===void 0)return!1;return t.delete(r[r.length-1])}};new Zg;new Xg;new B;var z4=class extends Kt{constructor(r,t,e,s=1){super(r,t,e),this.a=s}set(r,t,e,s=1){return this.a=s,super.set(r,t,e)}copy(r){return r.a!==void 0&&(this.a=r.a),super.copy(r)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}},C4=class extends Ft{static get type(){return"ParameterNode"}constructor(r,t=null){super(r,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const E4=(r,t)=>W(new C4(r,t));var V4=class extends at{static get type(){return"StackNode"}constructor(r=null){super(),this.nodes=[],this.outputNode=null,this.parent=r,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(r){return this.outputNode?this.outputNode.getNodeType(r):"void"}getMemberType(r,t){return this.outputNode?this.outputNode.getMemberType(r,t):"void"}add(r){return this.nodes.push(r),this}If(r,t){let e=new Jo(t);return this._currentCond=Qe(r,e),this.add(this._currentCond)}ElseIf(r,t){let e=new Jo(t),s=Qe(r,e);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(r){return this._currentCond.elseNode=new Jo(r),this}Switch(r){return this._expressionNode=W(r),this}Case(...r){let t=[];if(r.length>=2)for(let a=0;a<r.length-1;a++)t.push(this._expressionNode.equal(W(r[a])));else throw Error("TSL: Invalid parameter length. Case() requires at least two parameters.");let e=r[r.length-1],s=new Jo(e),i=t[0];for(let a=1;a<t.length;a++)i=i.or(t[a]);let n=Qe(i,s);return this._currentCond===null?(this._currentCond=n,this.add(this._currentCond)):(this._currentCond.elseNode=n,this._currentCond=n,this)}Default(r){return this.Else(r),this}build(r,...t){let e=Fw();Hf(this);let s=r.buildStage;for(let i of this.nodes)if(s==="setup")i.build(r);else if(s==="analyze")i.build(r,this);else if(s==="generate"){let n=r.getDataFromNode(i,"any").stages,a=n&&n[r.shaderStage];if(i.isVarNode&&a&&a.length===1&&a[0]&&a[0].isStackNode)continue;i.build(r,"void")}return Hf(e),this.outputNode?this.outputNode.build(r,...t):super.build(r,...t)}else(...r){return console.warn("THREE.TSL: .else() has been renamed to .Else()."),this.Else(...r)}elseif(...r){return console.warn("THREE.TSL: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...r)}};const R4=H(V4).setParameterLength(0,1);function L4(r){return Object.entries(r).map(([t,e])=>typeof e=="string"?{name:t,type:e,atomic:!1}:{name:t,type:e.type,atomic:e.atomic||!1})}var I4=class extends at{static get type(){return"StructTypeNode"}constructor(r,t=null){super("struct"),this.membersLayout=L4(r),this.name=t,this.isStructLayoutNode=!0}getLength(){let r=8,t=Float32Array.BYTES_PER_ELEMENT,e=0;for(let s of this.membersLayout){let i=s.type,n=mC(i)*t,a=fC(i),o=e%r,l=o%a,h=o+l;e+=l,h!==0&&r-h<n&&(e+=r-h),e+=n}return Math.ceil(e/r)*r/t}getMemberType(r,t){let e=this.membersLayout.find(s=>s.name===t);return e?e.type:"void"}getNodeType(r){return r.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(r){r.addInclude(this)}generate(r){return this.getNodeType(r)}},P4=class extends at{static get type(){return"StructNode"}constructor(r,t){super("vec3"),this.structLayoutNode=r,this.values=t,this.isStructNode=!0}getNodeType(r){return this.structLayoutNode.getNodeType(r)}getMemberType(r,t){return this.structLayoutNode.getMemberType(r,t)}generate(r){let t=r.getVarFromNode(this),e=t.type,s=r.getPropertyName(t);return r.addLineFlowCode(`${s} = ${r.generateStruct(e,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const F4=(r,t=null)=>{let e=new I4(r,t),s=(...i)=>{let n=null;if(i.length>0)if(i[0].isNode){n={};let a=Object.keys(r);for(let o=0;o<i.length;o++)n[a[o]]=i[o]}else n=i[0];return W(new P4(e,n))};return s.layout=e,s.isStruct=!0,s};var A2=class extends at{static get type(){return"OutputStructNode"}constructor(...r){super(),this.members=r,this.isOutputStructNode=!0}getNodeType(r){let t=r.getNodeProperties(this);if(t.membersLayout===void 0){let e=this.members,s=[];for(let i=0;i<e.length;i++){let n="m"+i,a=e[i].getNodeType(r);s.push({name:n,type:a,index:i})}t.membersLayout=s,t.structType=r.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(r){let t=r.getOutputStructName(),e=this.members,s=t===""?"":t+".";for(let i=0;i<e.length;i++){let n=e[i].build(r);r.addLineFlowCode(`${s}m${i} = ${n}`,this)}return t}};const O4=H(A2);function z2(r,t){for(let e=0;e<r.length;e++)if(r[e].name===t)return e;return-1}var B4=class extends A2{static get type(){return"MRTNode"}constructor(r){super(),this.outputNodes=r,this.isMRTNode=!0}has(r){return this.outputNodes[r]!==void 0}get(r){return this.outputNodes[r]}merge(r){let t={...this.outputNodes,...r.outputNodes};return C2(t)}setup(r){let t=this.outputNodes,e=r.renderer.getRenderTarget(),s=[],i=e.textures;for(let n in t){let a=z2(i,n);s[a]=ut(t[n])}return this.members=s,super.setup(r)}};const C2=H(B4),k4=C(([r])=>{let t=r.toUint().mul(747796405).add(2891336453),e=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return e.shiftRight(22).bitXor(e).toFloat().mul(1/2**32)}),ig=(r,t)=>Xs(gt(4,r.mul(zt(1,r))),t),D4=(r,t)=>r.lessThan(.5)?ig(r.mul(2),t).div(2):zt(1,ig(gt(zt(1,r),2),t).div(2)),U4=(r,t,e)=>Xs(Js(Xs(r,t),Ce(Xs(r,t),Xs(zt(1,r),e))),1/t),$4=(r,t)=>Xr(Rd.mul(t.mul(r).sub(1))).div(Rd.mul(t.mul(r).sub(1))),Di=C(([r])=>r.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),j4=C(([r])=>E(Di(r.z.add(Di(r.y.mul(1)))),Di(r.z.add(Di(r.x.mul(1)))),Di(r.y.add(Di(r.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),W4=C(([r,t,e])=>{let s=E(r).toVar(),i=v(1.4).toVar(),n=v(0).toVar(),a=E(s).toVar();return Pt({start:v(0),end:v(3),type:"float",condition:"<="},()=>{let o=E(j4(a.mul(2))).toVar();s.addAssign(o.add(e.mul(v(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);let l=v(Di(s.z.add(Di(s.x.add(Di(s.y)))))).toVar();n.addAssign(l.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});var q4=class extends at{static get type(){return"FunctionOverloadingNode"}constructor(r=[],...t){super(),this.functionNodes=r,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(r){let t=this.parametersNodes,e=this._candidateFnCall;if(e===null){let s=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 l=o.inputs;if(t.length===l.length){let h=0;for(let u=0;u<t.length;u++){let c=t[u],d=l[u];c.getNodeType(r)===d.type?h++:h=0}h>i&&(s=n,i=h)}}this._candidateFnCall=e=s(...t)}return e}};const H4=H(q4),hr=r=>(...t)=>H4(r,...t),Ya=ct(0).setGroup(Tt).onRenderUpdate(r=>r.time),E2=ct(0).setGroup(Tt).onRenderUpdate(r=>r.deltaTime),G4=ct(0,"uint").setGroup(Tt).onRenderUpdate(r=>r.frameId),X4=(r=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Ya.mul(r)),Y4=(r=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Ya.mul(r)),Z4=(r=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),E2.mul(r)),J4=(r=Ya)=>r.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Q4=(r=Ya)=>r.fract().round(),K4=(r=Ya)=>r.add(.5).fract().mul(2).sub(1).abs(),tL=(r=Ya)=>r.fract(),eL=C(([r,t,e=Y(.5)])=>_2(r.sub(e),t).add(e)),rL=C(([r,t,e=Y(.5)])=>{let s=r.sub(e),i=s.dot(s),n=i.mul(i),a=n.mul(t);return r.add(s.mul(a))}),sL=C(({position:r=null,horizontal:t=!0,vertical:e=!1})=>{let s;r===null?s=ji:(s=ji.toVar(),s[3][0]=r.x,s[3][1]=r.y,s[3][2]=r.z);let i=Ts.mul(s);return ju(t)&&(i[0][0]=ji[0].length(),i[0][1]=0,i[0][2]=0),ju(e)&&(i[1][0]=0,i[1][1]=ji[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,dh.mul(i).mul(Se)}),iL=C(([r=null])=>{let t=Pd();return Pd(Vy(r)).sub(t).lessThan(0).select(na,r)});var nL=class extends at{static get type(){return"SpriteSheetUVNode"}constructor(r,t=oe(),e=v(0)){super("vec2"),this.countNode=r,this.uvNode=t,this.frameNode=e}setup(){let{frameNode:r,uvNode:t,countNode:e}=this,{width:s,height:i}=e,n=r.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),l=e.reciprocal(),h=Y(a,o);return t.add(h).mul(l)}};const aL=H(nL).setParameterLength(3);var oL=class extends at{static get type(){return"TriplanarTexturesNode"}constructor(r,t=null,e=null,s=v(1),i=Se,n=Pr){super("vec4"),this.textureXNode=r,this.textureYNode=t,this.textureZNode=e,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){let{textureXNode:r,textureYNode:t,textureZNode:e,scaleNode:s,positionNode:i,normalNode:n}=this,a=n.abs().normalize();a=a.div(a.dot(E(1)));let o=i.yz.mul(s),l=i.zx.mul(s),h=i.xy.mul(s),u=r.value,c=t===null?u:t.value,d=e===null?u:e.value,p=Bt(u,o).mul(a.x),m=Bt(c,l).mul(a.y),f=Bt(d,h).mul(a.z);return Ce(p,m,f)}};const V2=H(oL).setParameterLength(1,6),lL=(...r)=>V2(...r),go=new Vn,da=new B,yo=new B,Im=new B,tu=new Lt,gc=new B(0,0,-1),ri=new wr,eu=new B,yc=new B,ru=new wr,xc=new jt,Fd=new Ol,uL=na.flipX();Fd.depthTexture=new ah(1,1);let bc=!1;var hL=class R2 extends nn{static get type(){return"ReflectorNode"}constructor(t={}){super(t.defaultTexture||Fd.texture,uL),this._reflectorBaseNode=t.reflector||new cL(this,t),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=W(new R2({defaultTexture:Fd.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(t){return t.object.isQuadMesh||this._reflectorBaseNode.build(t),super.setup(t)}clone(){let t=new this.constructor(this.reflectorNode);return t._reflectorBaseNode=this._reflectorBaseNode,t}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},cL=class extends at{static get type(){return"ReflectorBaseNode"}constructor(r,t={}){super();let{target:e=new Xi,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=r,this.target=e,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?It.RENDER:It.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(r,t){let e=this.resolution;t.getDrawingBufferSize(xc),r.setSize(Math.round(xc.width*e),Math.round(xc.height*e))}setup(r){return this._updateResolution(Fd,r.renderer),super.setup(r)}dispose(){super.dispose();for(let r of this.renderTargets.values())r.dispose()}getVirtualCamera(r){let t=this.virtualCameras.get(r);return t===void 0&&(t=r.clone(),this.virtualCameras.set(r,t)),t}getRenderTarget(r){let t=this.renderTargets.get(r);return t===void 0&&(t=new Ol(0,0,{type:Bn}),this.generateMipmaps===!0&&(t.texture.minFilter=JA,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new ah),this.renderTargets.set(r,t)),t}updateBefore(r){if(this.bounces===!1&&bc)return!1;bc=!0;let{scene:t,camera:e,renderer:s,material:i}=r,{target:n}=this,a=this.getVirtualCamera(e),o=this.getRenderTarget(a);s.getDrawingBufferSize(xc),this._updateResolution(o,s),yo.setFromMatrixPosition(n.matrixWorld),Im.setFromMatrixPosition(e.matrixWorld),tu.extractRotation(n.matrixWorld),da.set(0,0,1),da.applyMatrix4(tu),eu.subVectors(yo,Im);let l=eu.dot(da)>0,h=!1;if(l===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){bc=!1;return}h=!0}eu.reflect(da).negate(),eu.add(yo),tu.extractRotation(e.matrixWorld),gc.set(0,0,-1),gc.applyMatrix4(tu),gc.add(Im),yc.subVectors(yo,gc),yc.reflect(da).negate(),yc.add(yo),a.coordinateSystem=e.coordinateSystem,a.position.copy(eu),a.up.set(0,1,0),a.up.applyMatrix4(tu),a.up.reflect(da),a.lookAt(yc),a.near=e.near,a.far=e.far,a.updateMatrixWorld(),a.projectionMatrix.copy(e.projectionMatrix),go.setFromNormalAndCoplanarPoint(da,yo),go.applyMatrix4(a.matrixWorldInverse),ri.set(go.normal.x,go.normal.y,go.normal.z,go.constant);let u=a.projectionMatrix;ru.x=(Math.sign(ri.x)+u.elements[8])/u.elements[0],ru.y=(Math.sign(ri.y)+u.elements[9])/u.elements[5],ru.z=-1,ru.w=(1+u.elements[10])/u.elements[14],ri.multiplyScalar(1/ri.dot(ru));let c=0;u.elements[2]=ri.x,u.elements[6]=ri.y,u.elements[10]=s.coordinateSystem===tn?ri.z-c:ri.z+1-c,u.elements[14]=ri.w,this.textureNode.value=o.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;let d=s.getRenderTarget(),p=s.getMRT(),m=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,h?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(p),s.setRenderTarget(d),s.autoClear=m,i.visible=!0,bc=!1,this.forceUpdate=!1}};const dL=r=>W(new hL(r)),Pm=new bw(-1,1,1,-1,0,1);var pL=class extends up{constructor(r=!1){super();let t=r===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new il([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new il(t,2))}};const mL=new pL;var L2=class extends zl{constructor(r=null){super(mL,r),this.camera=Pm,this.isQuadMesh=!0}async renderAsync(r){return r.renderAsync(this,Pm)}render(r){r.render(this,Pm)}};const fL=new jt;var gL=class extends nn{static get type(){return"RTTNode"}constructor(r,t=null,e=null,s={type:Bn}){let i=new Ol(t,e,s);super(i.texture,oe()),this.node=r,this.width=t,this.height=e,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new L2(new $a),this.updateBeforeType=It.RENDER}get autoSize(){return this.width===null}setup(r){return this._rttNode=this.node.context(r.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(r)}setSize(r,t){this.width=r,this.height=t;let e=r*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(e,s),this.textureNeedsUpdate=!0}setPixelRatio(r){this.pixelRatio=r,this.setSize(this.width,this.height)}updateBefore({renderer:r}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=r.getPixelRatio();let e=r.getSize(fL);this.setSize(e.width,e.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=r.getRenderTarget();r.setRenderTarget(this.renderTarget),this._quadMesh.render(r),r.setRenderTarget(t)}clone(){let r=new nn(this.value,this.uvNode,this.levelNode);return r.sampler=this.sampler,r.referenceNode=this,r}};const I2=(r,...t)=>W(new gL(W(r),...t)),yL=(r,...t)=>r.isTextureNode?r:r.isPassNode?r.getTextureNode():I2(r,...t),Go=C(([r,t,e],s)=>{let i;s.renderer.coordinateSystem===tn?(r=Y(r.x,r.y.oneMinus()).mul(2).sub(1),i=ut(E(r,t),1)):i=ut(E(r.x,r.y.oneMinus(),t).mul(2).sub(1),1);let n=ut(e.mul(i));return n.xyz.div(n.w)}),xL=C(([r,t])=>{let e=t.mul(ut(r,1)),s=e.xy.div(e.w).mul(.5).add(.5).toVar();return Y(s.x,s.y.oneMinus())}),bL=C(([r,t,e])=>{let s=$n(be(t)),i=Ge(r.mul(s)).toVar(),n=be(t,i).toVar(),a=be(t,i.sub(Ge(2,0))).toVar(),o=be(t,i.sub(Ge(1,0))).toVar(),l=be(t,i.add(Ge(1,0))).toVar(),h=be(t,i.add(Ge(2,0))).toVar(),u=be(t,i.add(Ge(0,2))).toVar(),c=be(t,i.add(Ge(0,1))).toVar(),d=be(t,i.sub(Ge(0,1))).toVar(),p=be(t,i.sub(Ge(0,2))).toVar(),m=Jt(zt(v(2).mul(o).sub(a),n)).toVar(),f=Jt(zt(v(2).mul(l).sub(h),n)).toVar(),x=Jt(zt(v(2).mul(c).sub(u),n)).toVar(),b=Jt(zt(v(2).mul(d).sub(p),n)).toVar(),w=Go(r,n,e).toVar(),S=m.lessThan(f).select(w.sub(Go(r.sub(Y(v(1).div(s.x),0)),o,e)),w.negate().add(Go(r.add(Y(v(1).div(s.x),0)),l,e))),_=x.lessThan(b).select(w.sub(Go(r.add(Y(0,v(1).div(s.y))),c,e)),w.negate().add(Go(r.sub(Y(0,v(1).div(s.y))),d,e)));return en(xp(S,_))});var vL=class extends nl{constructor(r,t,e=Float32Array){let s=ArrayBuffer.isView(r)?r:new e(r*t);super(s,t),this.isStorageInstancedBufferAttribute=!0}},wL=class extends ms{constructor(r,t,e=Float32Array){let s=ArrayBuffer.isView(r)?r:new e(r*t);super(s,t),this.isStorageBufferAttribute=!0}};const ML=(r,t="float")=>{let e,s;t.isStruct===!0?(e=t.layout.getLength(),s=Vd("float")):(e=Sw(t),s=Vd(t));let i=new wL(r,e,s);return La(i,t,r)},TL=(r,t="float")=>{let e,s;t.isStruct===!0?(e=t.layout.getLength(),s=Vd("float")):(e=Sw(t),s=Vd(t));let i=new vL(r,e,s);return La(i,t,r)};var NL=class extends at{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}};const SL=Q(NL),su=new mi,Fm=new Lt;var Zi=class Tu extends at{static get type(){return"SceneNode"}constructor(t=Tu.BACKGROUND_BLURRINESS,e=null){super(),this.scope=t,this.scene=e}setup(t){let e=this.scope,s=this.scene===null?t.scene:this.scene,i;return e===Tu.BACKGROUND_BLURRINESS?i=pe("backgroundBlurriness","float",s):e===Tu.BACKGROUND_INTENSITY?i=pe("backgroundIntensity","float",s):e===Tu.BACKGROUND_ROTATION?i=ct("mat4").label("backgroundRotation").setGroup(Tt).onRenderUpdate(()=>{let n=s.background;return n!==null&&n.isTexture&&n.mapping!==jg?(su.copy(s.backgroundRotation),su.x*=-1,su.y*=-1,su.z*=-1,Fm.makeRotationFromEuler(su)):Fm.identity(),Fm}):console.error("THREE.SceneNode: Unknown scope:",e),i}};Zi.BACKGROUND_BLURRINESS="backgroundBlurriness",Zi.BACKGROUND_INTENSITY="backgroundIntensity",Zi.BACKGROUND_ROTATION="backgroundRotation";const _L=Q(Zi,Zi.BACKGROUND_BLURRINESS),AL=Q(Zi,Zi.BACKGROUND_INTENSITY),zL=Q(Zi,Zi.BACKGROUND_ROTATION);var CL=class extends nn{static get type(){return"StorageTextureNode"}constructor(r,t,e=null){super(r,t),this.storeNode=e,this.isStorageTextureNode=!0,this.access=ii.WRITE_ONLY}getInputType(){return"storageTexture"}setup(r){super.setup(r);let t=r.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(r){return this.access=r,this}generate(r,t){let e;return e=this.storeNode===null?super.generate(r,t):this.generateStore(r),e}toReadWrite(){return this.setAccess(ii.READ_WRITE)}toReadOnly(){return this.setAccess(ii.READ_ONLY)}toWriteOnly(){return this.setAccess(ii.WRITE_ONLY)}generateStore(r){let t=r.getNodeProperties(this),{uvNode:e,storeNode:s,depthNode:i}=t,n=super.generate(r,"property"),a=e.build(r,"uvec2"),o=s.build(r,"vec4"),l=i?i.build(r,"int"):null,h=r.generateTextureStore(r,n,a,l,o);r.addLineFlowCode(h,this)}clone(){let r=super.clone();return r.storeNode=this.storeNode,r}};const P2=H(CL).setParameterLength(1,3),EL=(r,t,e)=>{let s=P2(r,t,e);return e!==null&&s.toStack(),s},VL=C(({texture:r,uv:t})=>{let e=1e-4,s=E().toVar();return xt(t.x.lessThan(e),()=>{s.assign(E(1,0,0))}).ElseIf(t.y.lessThan(e),()=>{s.assign(E(0,1,0))}).ElseIf(t.z.lessThan(e),()=>{s.assign(E(0,0,1))}).ElseIf(t.x.greaterThan(1-e),()=>{s.assign(E(-1,0,0))}).ElseIf(t.y.greaterThan(1-e),()=>{s.assign(E(0,-1,0))}).ElseIf(t.z.greaterThan(1-e),()=>{s.assign(E(0,0,-1))}).Else(()=>{let i=.01,n=r.sample(t.add(E(-.01,0,0))).r.sub(r.sample(t.add(E(i,0,0))).r),a=r.sample(t.add(E(0,-.01,0))).r.sub(r.sample(t.add(E(0,i,0))).r),o=r.sample(t.add(E(0,0,-.01))).r.sub(r.sample(t.add(E(0,0,i))).r);s.assign(E(n,a,o))}),s.normalize()});var RL=class extends nn{static get type(){return"Texture3DNode"}constructor(r,t=null,e=null){super(r,t,e),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return E(.5,.5,.5)}setUpdateMatrix(){}setupUV(r,t){let e=this.value;return r.isFlipY()&&(e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(T($n(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(r,t){return t.build(r,"vec3")}normal(r){return VL({texture:this,uv:r})}};const LL=H(RL).setParameterLength(1,3);var IL=class extends Mp{static get type(){return"UserDataNode"}constructor(r,t,e=null){super(r,t,e),this.userData=e}updateReference(r){return this.reference=this.userData===null?r.object.userData:this.userData,this.reference}};const PL=(r,t,e)=>W(new IL(r,t,e)),b1=new WeakMap;var FL=class extends we{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=It.OBJECT,this.updateAfterType=It.OBJECT,this.previousModelWorldMatrix=ct(new Lt),this.previousProjectionMatrix=ct(new Lt).setGroup(Tt),this.previousCameraViewMatrix=ct(new Lt)}setProjectionMatrix(r){this.projectionMatrix=r}update({frameId:r,camera:t,object:e}){let s=v1(e);this.previousModelWorldMatrix.value.copy(s);let i=F2(t);i.frameId!==r&&(i.frameId=r,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new Lt,i.previousCameraViewMatrix=new Lt,i.currentProjectionMatrix=new Lt,i.currentCameraViewMatrix=new Lt,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:r}){v1(r).copy(r.matrixWorld)}setup(){let r=this.projectionMatrix===null?dh:ct(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),e=r.mul(ph).mul(Se),s=this.previousProjectionMatrix.mul(t).mul(Id),i=e.xy.div(e.w),n=s.xy.div(s.w);return zt(i,n)}};function F2(r){let t=b1.get(r);return t===void 0&&(t={},b1.set(r,t)),t}function v1(r,t=0){let e=F2(r),s=e[t];return s===void 0&&(e[t]=s=new Lt,e[t].copy(r.matrixWorld)),s}const OL=Q(FL),O2=C(([r,t])=>ts(1,r.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),B2=C(([r,t])=>ts(r.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),k2=C(([r,t])=>r.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),D2=C(([r,t])=>fe(r.mul(2).mul(t),r.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),yp(.5,r))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),BL=C(([r,t])=>{let e=t.a.add(r.a.mul(t.a.oneMinus()));return ut(t.rgb.mul(t.a).add(r.rgb.mul(r.a).mul(t.a.oneMinus())).div(e),e)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kL=C(([r])=>ut(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"}),DL=C(([r])=>(xt(r.a.equal(0),()=>ut(0)),ut(r.rgb.div(r.a),r.a)),{color:"vec4",return:"vec4"}),UL=(...r)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),O2(r)),$L=(...r)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),B2(r)),jL=(...r)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),k2(r)),WL=(...r)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),D2(r)),qL=C(([r])=>By(r.rgb)),HL=C(([r,t=v(1)])=>t.mix(By(r.rgb),r.rgb)),GL=C(([r,t=v(1)])=>{let e=Ce(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),i=s.sub(e).mul(t).mul(-3);return fe(r.rgb,s,i)}),XL=C(([r,t=v(1)])=>{let e=E(.57735,.57735,.57735),s=t.cos();return E(r.rgb.mul(s).add(e.cross(r.rgb).mul(t.sin()).add(e.mul(ia(e,r.rgb).mul(s.oneMinus())))))}),By=(r,t=E(Me.getLuminanceCoefficients(new B)))=>ia(r,t),YL=C(([r,t=E(1),e=E(0),s=E(1),i=v(1),n=E(Me.getLuminanceCoefficients(new B,Ad))])=>{let a=r.rgb.dot(E(n)),o=ye(r.rgb.mul(t).add(e),0).toVar(),l=o.pow(s).toVar();return xt(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),xt(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),xt(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(i))),ut(o.rgb,r.a)});var ZL=class extends we{static get type(){return"PosterizeNode"}constructor(r,t){super(),this.sourceNode=r,this.stepsNode=t}setup(){let{sourceNode:r,stepsNode:t}=this;return r.mul(t).floor().div(t)}};const JL=H(ZL).setParameterLength(2),vc=new jt;var U2=class extends nn{static get type(){return"PassTextureNode"}constructor(r,t){super(t),this.passNode=r,this.setUpdateMatrix(!1)}setup(r){return r.object.isQuadMesh&&this.passNode.build(r),super.setup(r)}clone(){return new this.constructor(this.passNode,this.value)}},w1=class extends U2{static get type(){return"PassMultipleTextureNode"}constructor(r,t,e=!1){super(r,null),this.textureName=t,this.previousTexture=e}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(r){return this.updateTexture(),super.setup(r)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},Jn=class $2 extends we{static get type(){return"PassNode"}constructor(t,e,s,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=s,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;let n=new ah;n.isRenderTargetTexture=!0,n.name="depth";let a=new Ol(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Bn,...i});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=ct(0),this._cameraFar=ct(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=It.FRAME,this.global=!0}setResolution(t){return this._resolution=t,this}getResolution(){return this._resolution}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let e=this._textures[t];return e===void 0&&(e=this.renderTarget.texture.clone(),e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)),e}getPreviousTexture(t){let e=this._previousTextures[t];return e===void 0&&(e=this.getTexture(t).clone(),this._previousTextures[t]=e),e}toggleTexture(t){let e=this._previousTextures[t];if(e!==void 0){let s=this._textures[t],i=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=s,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return e===void 0&&(e=W(new w1(this,t)),e.updateTexture(),this._textureNodes[t]=e),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return e===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),e=W(new w1(this,t,!0)),e.updateTexture(),this._previousTextureNodes[t]=e),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(e===void 0){let s=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=Ry(this.getTextureNode(t),s,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(e===void 0){let s=this._cameraNear,i=this._cameraFar,n=this.getViewZNode(t);this._linearDepthNodes[t]=e=ll(n,s,i)}return e}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===$2.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){let{renderer:e}=t,{scene:s}=this,i,n,a=e.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,i=e.xr.getCamera(),e.xr.updateCamera(i),vc.set(a.width,a.height)):(i=this.camera,n=e.getPixelRatio(),e.getSize(vc)),this._pixelRatio=n,this.setSize(vc.width,vc.height);let o=e.getRenderTarget(),l=e.getMRT(),h=i.layers.mask;for(let u in this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(u);e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.render(s,i),e.setRenderTarget(o),e.setMRT(l),i.layers.mask=h}setSize(t,e){this._width=t,this._height=e;let s=this._width*this._pixelRatio*this._resolution,i=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(s,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};Jn.COLOR="color",Jn.DEPTH="depth";const QL=(r,t,e)=>W(new Jn(Jn.COLOR,r,t,e)),KL=(r,t)=>W(new U2(r,t)),tI=(r,t,e)=>W(new Jn(Jn.DEPTH,r,t,e));var eI=class extends Jn{static get type(){return"ToonOutlinePassNode"}constructor(r,t,e,s,i){super(Jn.COLOR,r,t),this.colorNode=e,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(r){let{renderer:t}=r,e=t.getRenderObjectFunction();t.setRenderObjectFunction((s,i,n,a,o,l,h,u)=>{if((o.isMeshToonMaterial||o.isMeshToonNodeMaterial)&&o.wireframe===!1){let c=this._getOutlineMaterial(o);t.renderObject(s,i,n,a,c,l,h,u)}t.renderObject(s,i,n,a,o,l,h,u)}),super.updateBefore(r),t.setRenderObjectFunction(e)}_createMaterial(){let r=new $a;r.isMeshToonOutlineMaterial=!0,r.name="Toon_Outline",r.side=Ha;let t=Pr.negate(),e=dh.mul(ph),s=v(1),i=e.mul(ut(Se,1)),n=e.mul(ut(Se.add(t),1)),a=en(i.sub(n));return r.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),r.colorNode=ut(this.colorNode,this.alphaNode),r}_getOutlineMaterial(r){let t=this._materialCache.get(r);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(r,t)),t}};const rI=(r,t,e=new Kt(0,0,0),s=.003,i=1)=>W(new eI(r,t,W(e),W(s),W(i))),sI=C(([r,t])=>r.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),iI=C(([r,t])=>(r=r.mul(t),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nI=C(([r,t])=>{r=r.mul(t),r=r.sub(.004).max(0);let e=r.mul(r.mul(6.2).add(.5)),s=r.mul(r.mul(6.2).add(1.7)).add(.06);return e.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),aI=C(([r])=>{let t=r.mul(r.add(.0245786)).sub(90537e-9),e=r.mul(r.add(.432951).mul(.983729)).add(.238081);return t.div(e)}),oI=C(([r,t])=>{let e=Ir(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=Ir(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(t).div(.6),r=e.mul(r),r=aI(r),r=s.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),lI=Ir(E(1.6605,-.1246,-.0182),E(-.5876,1.1329,-.1006),E(-.0728,-.0083,1.1187)),uI=Ir(E(.6274,.0691,.0164),E(.3293,.9195,.088),E(.0433,.0113,.8956)),hI=C(([r])=>{let t=E(r).toVar(),e=E(t.mul(t)).toVar(),s=E(e.mul(e)).toVar();return v(15.5).mul(s.mul(e)).sub(gt(40.14,s.mul(t))).add(gt(31.96,s).sub(gt(6.868,e.mul(t))).add(gt(.4298,e).add(gt(.1191,t).sub(.00232))))}),cI=C(([r,t])=>{let e=E(r).toVar(),s=Ir(E(.856627153315983,.137318972929847,.11189821299995),E(.0951212405381588,.761241990602591,.0767994186031903),E(.0482516061458583,.101439036467562,.811302368396859)),i=Ir(E(1.1271005818144368,-.1413297634984383,-.14132976349843826),E(-.11060664309660323,1.157823702216272,-.11060664309660294),E(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=v(-12.47393),a=v(4.026069);return e.mulAssign(t),e.assign(uI.mul(e)),e.assign(s.mul(e)),e.assign(ye(e,1e-10)),e.assign(li(e)),e.assign(e.sub(n).div(a.sub(n))),e.assign(gi(e,0,1)),e.assign(hI(e)),e.assign(i.mul(e)),e.assign(Xs(ye(E(0),e),E(2.2))),e.assign(lI.mul(e)),e.assign(gi(e,0,1)),e}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),dI=C(([r,t])=>{let e=v(.76),s=v(.15);r=r.mul(t);let i=ts(r.r,ts(r.g,r.b)),n=Qe(i.lessThan(.08),i.sub(gt(6.25,i.mul(i))),.04);r.subAssign(n);let a=ye(r.r,ye(r.g,r.b));xt(a.lessThan(e),()=>r);let o=zt(1,e),l=zt(1,o.mul(o).div(a.add(o.sub(e))));r.mulAssign(l.div(a));let h=zt(1,Js(1,s.mul(a.sub(l)).add(1)));return fe(r,E(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});var qe=class extends at{static get type(){return"CodeNode"}constructor(r="",t=[],e=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=r,this.includes=t,this.language=e}setIncludes(r){return this.includes=r,this}getIncludes(){return this.includes}generate(r){let t=this.getIncludes(r);for(let s of t)s.build(r);let e=r.getCodeFromNode(this,this.getNodeType(r));return e.code=this.code,e.code}serialize(r){super.serialize(r),r.code=this.code,r.language=this.language}deserialize(r){super.deserialize(r),this.code=r.code,this.language=r.language}};const _p=H(qe).setParameterLength(1,3),pI=(r,t)=>_p(r,t,"js"),mI=(r,t)=>_p(r,t,"wgsl"),fI=(r,t)=>_p(r,t,"glsl");var gI=class extends qe{static get type(){return"FunctionNode"}constructor(r="",t=[],e=""){super(r,t,e)}getNodeType(r){return this.getNodeFunction(r).type}getInputs(r){return this.getNodeFunction(r).inputs}getNodeFunction(r){let t=r.getDataFromNode(this),e=t.nodeFunction;return e===void 0&&(e=r.parser.parseFunction(this.code),t.nodeFunction=e),e}generate(r,t){super.generate(r);let e=this.getNodeFunction(r),s=e.name,i=e.type,n=r.getCodeFromNode(this,i);s!==""&&(n.name=s);let a=r.getPropertyName(n),o=this.getNodeFunction(r).getCode(a);return n.code=o+`
|
|
64
|
+
`,t==="property"?a:r.format(`${a}()`,i,t)}};const j2=(r,t=[],e="")=>{for(let n=0;n<t.length;n++){let a=t[n];typeof a=="function"&&(t[n]=a.functionNode)}let s=W(new gI(r,t,e)),i=(...n)=>s.call(...n);return i.functionNode=s,i},yI=(r,t)=>j2(r,t,"glsl"),xI=(r,t)=>j2(r,t,"wgsl");var bI=class extends at{static get type(){return"ScriptableValueNode"}constructor(r=null){super(),this._value=r,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Ga,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(r){this._value!==r&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=r,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){let r=this.value;if(r&&this._cache===null&&this.inputType==="URL"&&r.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([r.value]));else if(r&&r.value!==null&&r.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof r.value=="string"||this.inputType==="Number"&&typeof r.value=="number"||this.inputType==="Vector2"&&r.value.isVector2||this.inputType==="Vector3"&&r.value.isVector3||this.inputType==="Vector4"&&r.value.isVector4||this.inputType==="Color"&&r.value.isColor||this.inputType==="Matrix3"&&r.value.isMatrix3||this.inputType==="Matrix4"&&r.value.isMatrix4))return r.value;return this._cache||r}getNodeType(r){return this.value&&this.value.isNode?this.value.getNodeType(r):"float"}setup(){return this.value&&this.value.isNode?this.value:v()}serialize(r){super.serialize(r),this.value===null?r.value=null:this.inputType==="ArrayBuffer"?r.value=zw(this.value):r.value=this.value?this.value.toJSON(r.meta).uuid:null,r.inputType=this.inputType,r.outputType=this.outputType}deserialize(r){super.deserialize(r);let t=null;r.value!==null&&(t=r.inputType==="ArrayBuffer"?Cw(r.value):r.inputType==="Texture"?r.meta.textures[r.value]:r.meta.nodes[r.value]||null),this.value=t,this.inputType=r.inputType,this.outputType=r.outputType}};const gd=H(bI).setParameterLength(1);var W2=class extends Map{get(r,t=null,...e){if(this.has(r))return super.get(r);if(t!==null){let s=t(...e);return this.set(r,s),s}}},vI=class{constructor(r){this.scriptableNode=r}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(r){return this.scriptableNode.getInputLayout(r)}get(r){let t=this.parameters[r];return t?t.getValue():null}};const yd=new W2;var wI=class extends at{static get type(){return"ScriptableNode"}constructor(r=null,t={}){super(),this.codeNode=r,this.parameters=t,this._local=new W2,this._output=gd(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(r,t){return this._local.set(r,t)}getLocal(r){return this._local.get(r)}onRefresh(){this._refresh()}getInputLayout(r){for(let t of this.getLayout())if(t.inputType&&(t.id===r||t.name===r))return t}getOutputLayout(r){for(let t of this.getLayout())if(t.outputType&&(t.id===r||t.name===r))return t}setOutput(r,t){let e=this._outputs;return e[r]===void 0?e[r]=gd(t):e[r].value=t,this}getOutput(r){return this._outputs[r]}getParameter(r){return this.parameters[r]}setParameter(r,t){let e=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(r),e[r]=t,e[r].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(r),e[r]=t,e[r].events.addEventListener("refresh",this.onRefresh)):e[r]===void 0?(e[r]=gd(t),e[r].events.addEventListener("refresh",this.onRefresh)):e[r].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(r){let t=this.parameters[r];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(let r of Object.keys(this.parameters))this.deleteParameter(r);return this.needsUpdate=!0,this}call(r,...t){let e=this.getObject(),s=e[r];if(typeof s=="function")return s(...t)}async callAsync(r,...t){let e=this.getObject(),s=e[r];if(typeof s=="function")return s.constructor.name==="AsyncFunction"?await s(...t):s(...t)}getNodeType(r){return this.getDefaultOutputNode().getNodeType(r)}refresh(r=null){r===null?this._refresh():this.getOutput(r).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let r=()=>this.refresh(),t=(l,h)=>this.setOutput(l,h),e=new vI(this),s=yd.get("THREE"),i=yd.get("TSL"),n=this.getMethod(),a=[e,this._local,yd,r,t,s,i];this._object=n(...a);let o=this._object.layout;if(o&&(o.cache===!1&&this._local.clear(),this._output.outputType=o.outputType||null,Array.isArray(o.elements)))for(let l of o.elements){let h=l.id||l.name;l.inputType&&(this.getParameter(h)===void 0&&this.setParameter(h,null),this.getParameter(h).inputType=l.inputType),l.outputType&&(this.getOutput(h)===void 0&&this.setOutput(h,null),this.getOutput(h).outputType=l.outputType)}return this._object}deserialize(r){for(let t in super.deserialize(r),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 r=this.getDefaultOutput().value;return r&&r.isNode?r:v()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let r=["parameters","local","global","refresh","setOutput","THREE","TSL"],t=["layout","init","main","dispose"],e=t.join(", "),s="var "+e+`; var output = {};
|
|
65
|
+
`,i=`
|
|
66
|
+
return { ...output, `+e+" };",n=s+this.codeNode.code+i;return this._method=Function(...r,n),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(r){let t=[cC(this.source),this.getDefaultOutputNode().getCacheKey(r)];for(let e in this.parameters)t.push(this.parameters[e].getCacheKey(r));return Mw(t)}set needsUpdate(r){r===!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 MI=H(wI).setParameterLength(1,2);function q2(r){let t,e=r.context.getViewZ;return e!==void 0&&(t=e(this)),(t||ar.z).negate()}const H2=C(([r,t],e)=>{let s=q2(e);return rn(r,t,s)}),G2=C(([r],t)=>{let e=q2(t);return r.mul(r,e,e).negate().exp().oneMinus()}),ky=C(([r,t])=>ut(t.toFloat().mix(ol.rgb,r.toVec3()),ol.a));function TI(r,t,e){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),ky(r,H2(t,e))}function NI(r,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),ky(r,G2(t))}let xo=null,bo=null;var SI=class extends at{static get type(){return"RangeNode"}constructor(r=v(),t=v()){super(),this.minNode=r,this.maxNode=t}getVectorLength(r){let t=r.getTypeLength(kn(this.minNode.value)),e=r.getTypeLength(kn(this.maxNode.value));return t>e?t:e}getNodeType(r){return r.object.count>1?r.getTypeFromLength(this.getVectorLength(r)):"float"}setup(r){let t=r.object,e=null;if(t.count>1){let s=this.minNode.value,i=this.maxNode.value,n=r.getTypeLength(kn(s)),a=r.getTypeLength(kn(i));xo||(xo=new wr),bo||(bo=new wr),xo.setScalar(0),bo.setScalar(0),n===1?xo.setScalar(s):s.isColor?xo.set(s.r,s.g,s.b,1):xo.set(s.x,s.y,s.z||0,s.w||0),a===1?bo.setScalar(i):i.isColor?bo.set(i.r,i.g,i.b,1):bo.set(i.x,i.y,i.z||0,i.w||0);let o=4,l=o*t.count,h=new Float32Array(l);for(let c=0;c<l;c++){let d=c%o,p=xo.getComponent(d),m=bo.getComponent(d);h[c]=rw.lerp(p,m,Math.random())}let u=this.getNodeType(r);if(t.count<=4096)e=ch(h,"vec4",t.count).element(jn).convert(u);else{let c=new nl(h,4);r.geometry.setAttribute("__range"+this.id,c),e=Ld(c).convert(u)}}else e=v(0);return e}};const _I=H(SI).setParameterLength(2);var AI=class extends at{static get type(){return"ComputeBuiltinNode"}constructor(r,t){super(t),this._builtinName=r}getHash(r){return this.getBuiltinName(r)}getNodeType(){return this.nodeType}setBuiltinName(r){return this._builtinName=r,this}getBuiltinName(){return this._builtinName}hasBuiltin(r){return r.hasBuiltin(this._builtinName)}generate(r,t){let e=this.getBuiltinName(r),s=this.getNodeType(r);return r.shaderStage==="compute"?r.format(e,s,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${e} can not be accessed in the ${r.shaderStage} stage`),r.generateConst(s))}serialize(r){super.serialize(r),r.global=this.global,r._builtinName=this._builtinName}deserialize(r){super.deserialize(r),this.global=r.global,this._builtinName=r._builtinName}};const bh=(r,t)=>W(new AI(r,t)),zI=bh("numWorkgroups","uvec3"),CI=bh("workgroupId","uvec3"),EI=bh("globalId","uvec3"),VI=bh("localId","uvec3"),RI=bh("subgroupSize","uint");var LI=class extends at{constructor(r){super(),this.scope=r}generate(r){let{scope:t}=this,{renderer:e}=r;e.backend.isWebGLBackend===!0?r.addFlowCode(` // ${t}Barrier
|
|
67
|
+
`):r.addLineFlowCode(`${t}Barrier()`,this)}};const Dy=H(LI),II=()=>Dy("workgroup").toStack(),PI=()=>Dy("storage").toStack(),FI=()=>Dy("texture").toStack();var OI=class extends Xa{constructor(r,t){super(r,t),this.isWorkgroupInfoElementNode=!0}generate(r,t){let e,s=r.context.assign;if(e=super.generate(r),s!==!0){let i=this.getNodeType(r);e=r.format(e,i,t)}return e}},BI=class extends at{constructor(r,t,e=0){super(t),this.bufferType=t,this.bufferCount=e,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=r}label(r){return this.name=r,this}setScope(r){return this.scope=r,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(r){return W(new OI(this,r))}generate(r){return r.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const kI=(r,t)=>W(new BI("Workgroup",r,t));var Xe=class extends at{static get type(){return"AtomicFunctionNode"}constructor(r,t,e){super("uint"),this.method=r,this.pointerNode=t,this.valueNode=e,this.parents=!0}getInputType(r){return this.pointerNode.getNodeType(r)}getNodeType(r){return this.getInputType(r)}generate(r){let t=r.getNodeProperties(this),e=t.parents,s=this.method,i=this.getNodeType(r),n=this.getInputType(r),a=this.pointerNode,o=this.valueNode,l=[];l.push(`&${a.build(r,n)}`),o!==null&&l.push(o.build(r,n));let h=`${r.getMethod(s,i)}( ${l.join(", ")} )`;if(e.length===1&&e[0].isStackNode===!0)r.addLineFlowCode(h,this);else return t.constNode===void 0&&(t.constNode=sn(h,i).toConst()),t.constNode.build(r)}};Xe.ATOMIC_LOAD="atomicLoad",Xe.ATOMIC_STORE="atomicStore",Xe.ATOMIC_ADD="atomicAdd",Xe.ATOMIC_SUB="atomicSub",Xe.ATOMIC_MAX="atomicMax",Xe.ATOMIC_MIN="atomicMin",Xe.ATOMIC_AND="atomicAnd",Xe.ATOMIC_OR="atomicOr",Xe.ATOMIC_XOR="atomicXor";const DI=H(Xe),Si=(r,t,e)=>DI(r,t,e).toStack(),UI=r=>Si(Xe.ATOMIC_LOAD,r,null),$I=(r,t)=>Si(Xe.ATOMIC_STORE,r,t),jI=(r,t)=>Si(Xe.ATOMIC_ADD,r,t),WI=(r,t)=>Si(Xe.ATOMIC_SUB,r,t),qI=(r,t)=>Si(Xe.ATOMIC_MAX,r,t),HI=(r,t)=>Si(Xe.ATOMIC_MIN,r,t),GI=(r,t)=>Si(Xe.ATOMIC_AND,r,t),XI=(r,t)=>Si(Xe.ATOMIC_OR,r,t),YI=(r,t)=>Si(Xe.ATOMIC_XOR,r,t);let Om;function Ap(r){Om||(Om=new WeakMap);let t=Om.get(r);return t===void 0&&Om.set(r,t={}),t}function Uy(r){let t=Ap(r);return t.shadowMatrix||(t.shadowMatrix=ct("mat4").setGroup(Tt).onRenderUpdate(e=>((r.castShadow!==!0||e.renderer.shadowMap.enabled===!1)&&r.shadow.updateMatrices(r),r.shadow.matrix)))}function ZI(r,t=Ra){let e=Uy(r).mul(t);return e.xyz.div(e.w)}function X2(r){let t=Ap(r);return t.position||(t.position=ct(new B).setGroup(Tt).onRenderUpdate((e,s)=>s.value.setFromMatrixPosition(r.matrixWorld)))}function Y2(r){let t=Ap(r);return t.targetPosition||(t.targetPosition=ct(new B).setGroup(Tt).onRenderUpdate((e,s)=>s.value.setFromMatrixPosition(r.target.matrixWorld)))}function JI(r){let t=Ap(r);return t.viewPosition||(t.viewPosition=ct(new B).setGroup(Tt).onRenderUpdate(({camera:e},s)=>{s.value=s.value||new B,s.value.setFromMatrixPosition(r.matrixWorld),s.value.applyMatrix4(e.matrixWorldInverse)}))}const QI=r=>Ts.transformDirection(X2(r).sub(Y2(r))),KI=r=>r.sort((t,e)=>t.id-e.id),tP=(r,t)=>{for(let e of t)if(e.isAnalyticLightNode&&e.light.id===r)return e;return null},Bm=new WeakMap,iu=[];var Z2=class extends at{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=E().toVar(),this.totalSpecularNode=E().toVar(),this.outgoingLightNode=E().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let r=this._lights;for(let e=0;e<r.length;e++){let s=r[e];if(iu.push(s.id),iu.push(s.castShadow?1:0),s.isSpotLight===!0){let i=s.map===null?-1:s.map.id,n=s.colorNode?s.colorNode.getCacheKey():-1;iu.push(i,n)}}let t=Mw(iu);return iu.length=0,t}getHash(r){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(r);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(r){let t=r.getNodeProperties(this);for(let e of t.nodes)e.build(r);t.outputNode.build(r)}setupLightsNode(r){let t=[],e=this._lightNodes,s=KI(this._lights),i=r.renderer.library;for(let n of s)if(n.isNode)t.push(W(n));else{let a=null;if(e!==null&&(a=tP(n.id,e)),a===null){let o=i.getLightNodeClass(n.constructor);if(o===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${n.constructor.name}`);continue}let l=null;Bm.has(n)?l=Bm.get(n):(l=W(new o(n)),Bm.set(n,l)),t.push(l)}}this._lightNodes=t}setupDirectLight(r,t,e){let{lightingModel:s,reflectedLight:i}=r.context;s.direct({...e,lightNode:t,reflectedLight:i},r)}setupDirectRectAreaLight(r,t,e){let{lightingModel:s,reflectedLight:i}=r.context;s.directRectArea({...e,lightNode:t,reflectedLight:i},r)}setupLights(r,t){for(let e of t)e.build(r)}getLightNodes(r){return this._lightNodes===null&&this.setupLightsNode(r),this._lightNodes}setup(r){let t=r.lightsNode;r.lightsNode=this;let e=this.outgoingLightNode,s=r.context,i=s.lightingModel,n=r.getNodeProperties(this);if(i){let{totalDiffuseNode:a,totalSpecularNode:o}=this;s.outgoingLight=e;let l=r.addStack();n.nodes=l.nodes,i.start(r);let{backdrop:h,backdropAlpha:u}=s,{directDiffuse:c,directSpecular:d,indirectDiffuse:p,indirectSpecular:m}=s.reflectedLight,f=c.add(p);h!==null&&(f=E(u===null?h:u.mix(f,h)),s.material.transparent=!0),a.assign(f),o.assign(d.add(m)),e.assign(a.add(o)),i.finish(r),e=e.bypass(r.removeStack())}else n.nodes=[];return r.lightsNode=t,e}setLights(r){return this._lights=r,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const eP=(r=[])=>W(new Z2).setLights(r);var rP=class extends at{static get type(){return"ShadowBaseNode"}constructor(r){super(),this.light=r,this.updateBeforeType=It.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:r,material:t}){$y.assign(t.receivedShadowPositionNode||r.shadowPositionWorld||Ra)}};const $y=Dl("vec3","shadowPositionWorld");function sP(r,t={}){return t.toneMapping=r.toneMapping,t.toneMappingExposure=r.toneMappingExposure,t.outputColorSpace=r.outputColorSpace,t.renderTarget=r.getRenderTarget(),t.activeCubeFace=r.getActiveCubeFace(),t.activeMipmapLevel=r.getActiveMipmapLevel(),t.renderObjectFunction=r.getRenderObjectFunction(),t.pixelRatio=r.getPixelRatio(),t.mrt=r.getMRT(),t.clearColor=r.getClearColor(t.clearColor||new Kt),t.clearAlpha=r.getClearAlpha(),t.autoClear=r.autoClear,t.scissorTest=r.getScissorTest(),t}function iP(r,t){return t=sP(r,t),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,t}function nP(r,t){r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),r.setRenderObjectFunction(t.renderObjectFunction),r.setPixelRatio(t.pixelRatio),r.setMRT(t.mrt),r.setClearColor(t.clearColor,t.clearAlpha),r.autoClear=t.autoClear,r.setScissorTest(t.scissorTest)}function aP(r,t={}){return t.background=r.background,t.backgroundNode=r.backgroundNode,t.overrideMaterial=r.overrideMaterial,t}function oP(r,t){return t=aP(r,t),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,t}function lP(r,t){r.background=t.background,r.backgroundNode=t.backgroundNode,r.overrideMaterial=t.overrideMaterial}function uP(r,t,e){return e=iP(r,e),e=oP(t,e),e}function hP(r,t,e){nP(r,e),lP(t,e)}const M1=new WeakMap,J2=C(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{let s=Bt(r,t.xy).label("t_basic");return r.isArrayTexture&&(s=s.depth(e)),s.compare(t.z)}),Q2=C(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:s})=>{let i=(x,b)=>{let w=Bt(r,x);return r.isArrayTexture&&(w=w.depth(s)),w.compare(b)},n=pe("mapSize","vec2",e).setGroup(Tt),a=pe("radius","float",e).setGroup(Tt),o=Y(1).div(n),l=o.x.negate().mul(a),h=o.y.negate().mul(a),u=o.x.mul(a),c=o.y.mul(a),d=l.div(2),p=h.div(2),m=u.div(2),f=c.div(2);return Ce(i(t.xy.add(Y(l,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(u,h)),t.z),i(t.xy.add(Y(d,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(l,0)),t.z),i(t.xy.add(Y(d,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(d,f)),t.z),i(t.xy.add(Y(0,f)),t.z),i(t.xy.add(Y(m,f)),t.z),i(t.xy.add(Y(l,c)),t.z),i(t.xy.add(Y(0,c)),t.z),i(t.xy.add(Y(u,c)),t.z)).mul(1/17)}),K2=C(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:s})=>{let i=(c,d)=>{let p=Bt(r,c);return r.isArrayTexture&&(p=p.depth(s)),p.compare(d)},n=pe("mapSize","vec2",e).setGroup(Tt),a=Y(1).div(n),o=a.x,l=a.y,h=t.xy,u=cn(h.mul(n).add(.5));return h.subAssign(u.mul(a)),Ce(i(h,t.z),i(h.add(Y(o,0)),t.z),i(h.add(Y(0,l)),t.z),i(h.add(a),t.z),fe(i(h.add(Y(o.negate(),0)),t.z),i(h.add(Y(o.mul(2),0)),t.z),u.x),fe(i(h.add(Y(o.negate(),l)),t.z),i(h.add(Y(o.mul(2),l)),t.z),u.x),fe(i(h.add(Y(0,l.negate())),t.z),i(h.add(Y(0,l.mul(2))),t.z),u.y),fe(i(h.add(Y(o,l.negate())),t.z),i(h.add(Y(o,l.mul(2))),t.z),u.y),fe(fe(i(h.add(Y(o.negate(),l.negate())),t.z),i(h.add(Y(o.mul(2),l.negate())),t.z),u.x),fe(i(h.add(Y(o.negate(),l.mul(2))),t.z),i(h.add(Y(o.mul(2),l.mul(2))),t.z),u.x),u.y)).mul(1/9)}),tN=C(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{let s=v(1).toVar(),i=Bt(r).sample(t.xy);r.isArrayTexture&&(i=i.depth(e)),i=i.rg;let n=yp(t.z,i.x);return xt(n.notEqual(v(1)),()=>{let a=t.z.sub(i.x),o=ye(0,i.y.mul(i.y)),l=o.div(o.add(a.mul(a)));l=gi(zt(l,.3).div(.6499999999999999)),s.assign(gi(ye(n,l)))}),s}),cP=C(([r,t,e])=>{let s=Ra.sub(r).length();return s=s.sub(t).div(e.sub(t)),s=s.saturate(),s}),dP=r=>{let t=r.shadow.camera,e=pe("near","float",t).setGroup(Tt),s=pe("far","float",t).setGroup(Tt),i=ST(r);return cP(i,e,s)},eN=r=>{let t=M1.get(r);if(t===void 0){let e=r.isPointLight?dP(r):null;t=new $a,t.colorNode=ut(0,0,0,1),t.depthNode=e,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,M1.set(r,t)}return t},T1=new A4,vo=[],rN=(r,t,e,s)=>{vo[0]=r,vo[1]=t;let i=T1.get(vo);return(i===void 0||i.shadowType!==e||i.useVelocity!==s)&&(i=(n,a,o,l,h,u,...c)=>{(n.castShadow===!0||n.receiveShadow&&e===cd)&&(s&&(Aw(n).useVelocity=!0),n.onBeforeShadow(r,n,o,t.camera,l,a.overrideMaterial,u),r.renderObject(n,a,o,l,h,u,...c),n.onAfterShadow(r,n,o,t.camera,l,a.overrideMaterial,u))},i.shadowType=e,i.useVelocity=s,T1.set(vo,i)),vo[0]=null,vo[1]=null,i},pP=C(({samples:r,radius:t,size:e,shadowPass:s,depthLayer:i})=>{let n=v(0).toVar("meanVertical"),a=v(0).toVar("squareMeanVertical"),o=r.lessThanEqual(v(1)).select(v(0),v(2).div(r.sub(1))),l=r.lessThanEqual(v(1)).select(v(0),v(-1));Pt({start:T(0),end:T(r),type:"int",condition:"<"},({i:u})=>{let c=l.add(v(u).mul(o)),d=s.sample(Ce(xh.xy,Y(0,c).mul(t)).div(e));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(r),a.divAssign(r);let h=Ni(a.sub(n.mul(n)));return Y(n,h)}),mP=C(({samples:r,radius:t,size:e,shadowPass:s,depthLayer:i})=>{let n=v(0).toVar("meanHorizontal"),a=v(0).toVar("squareMeanHorizontal"),o=r.lessThanEqual(v(1)).select(v(0),v(2).div(r.sub(1))),l=r.lessThanEqual(v(1)).select(v(0),v(-1));Pt({start:T(0),end:T(r),type:"int",condition:"<"},({i:u})=>{let c=l.add(v(u).mul(o)),d=s.sample(Ce(xh.xy,Y(c,0).mul(t)).div(e));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Ce(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(r),a.divAssign(r);let h=Ni(a.sub(n.mul(n)));return Y(n,h)}),fP=[J2,Q2,K2,tN];let km;const wc=new L2;var sN=class extends rP{static get type(){return"ShadowNode"}constructor(r,t=null){super(r),this.shadow=t||r.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(r,{filterFn:t,depthTexture:e,shadowCoord:s,shadow:i,depthLayer:n}){let a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),o=t({depthTexture:e,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,v(1))}setupShadowCoord(r,t){let{shadow:e}=this,{renderer:s}=r,i=pe("bias","float",e).setGroup(Tt),n=t,a;if(e.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)n=n.xyz.div(n.w),a=n.z,s.coordinateSystem===tn&&(a=a.mul(2).sub(1));else{let o=n.w;n=n.xy.div(o);let l=pe("near","float",e.camera).setGroup(Tt),h=pe("far","float",e.camera).setGroup(Tt);a=Ly(o.negate(),l,h)}return n=E(n.x,n.y.oneMinus(),a.add(i)),n}getShadowFilterFn(r){return fP[r]}setupRenderTarget(r,t){let e=new ah(r.mapSize.width,r.mapSize.height);e.name="ShadowDepthTexture",e.compareFunction=rz;let s=t.createRenderTarget(r.mapSize.width,r.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=r.mapType,s.depthTexture=e,{shadowMap:s,depthTexture:e}}setupShadow(r){let{renderer:t}=r,{light:e,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,r);if(s.camera.updateProjectionMatrix(),i===cd&&s.isPointLightShadow!==!0){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=r.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:qh,type:Bn,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=r.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:qh,type:Bn,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=r.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:qh,type:Bn,depthBuffer:!1}),this.vsmShadowMapHorizontal=r.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:qh,type:Bn,depthBuffer:!1}));let x=Bt(n);n.isArrayTexture&&(x=x.depth(this.depthLayer));let b=Bt(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(b=b.depth(this.depthLayer));let w=pe("blurSamples","float",s).setGroup(Tt),S=pe("radius","float",s).setGroup(Tt),_=pe("mapSize","vec2",s).setGroup(Tt),V=this.vsmMaterialVertical||(this.vsmMaterialVertical=new $a);V.fragmentNode=pP({samples:w,radius:S,size:_,shadowPass:x,depthLayer:this.depthLayer}).context(r.getSharedContext()),V.name="VSMVertical",V=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new $a),V.fragmentNode=mP({samples:w,radius:S,size:_,shadowPass:b,depthLayer:this.depthLayer}).context(r.getSharedContext()),V.name="VSMHorizontal"}let o=pe("intensity","float",s).setGroup(Tt),l=pe("normalBias","float",s).setGroup(Tt),h=Uy(e).mul($y.add(VT.mul(l))),u=this.setupShadowCoord(r,h),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(c===null)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let d=i===cd&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(r,{filterFn:c,shadowTexture:a.texture,depthTexture:d,shadowCoord:u,shadow:s,depthLayer:this.depthLayer}),m=Bt(a.texture,u);n.isArrayTexture&&(m=m.depth(this.depthLayer));let f=fe(1,p.rgb.mix(m,1),o.mul(m.a)).toVar();return this.shadowMap=a,this.shadow.map=a,f}setup(r){if(r.renderer.shadowMap.enabled!==!1)return C(()=>{let t=this._node;return this.setupShadowPosition(r),t===null&&(this._node=t=this.setupShadow(r)),r.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),r.material.receivedShadowNode&&(t=r.material.receivedShadowNode(t)),t})()}renderShadow(r){let{shadow:t,shadowMap:e,light:s}=this,{renderer:i,scene:n}=r;t.updateMatrices(s),e.setSize(t.mapSize.width,t.mapSize.height,e.depth),i.render(n,t.camera)}updateShadow(r){let{shadowMap:t,light:e,shadow:s}=this,{renderer:i,scene:n,camera:a}=r,o=i.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;let h=s.camera.layers.mask;s.camera.layers.mask&4294967294||(s.camera.layers.mask=a.layers.mask);let u=i.getRenderObjectFunction(),c=i.getMRT(),d=c?c.has("velocity"):!1;km=uP(i,n,km),n.overrideMaterial=eN(e),i.setRenderObjectFunction(rN(i,s,o,d)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(r),i.setRenderObjectFunction(u),o===cd&&s.isPointLightShadow!==!0&&this.vsmPass(i),s.camera.layers.mask=h,hP(i,n,km)}vsmPass(r){let{shadow:t}=this,e=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,e),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,e),r.setRenderTarget(this.vsmShadowMapVertical),wc.material=this.vsmMaterialVertical,wc.render(r),r.setRenderTarget(this.vsmShadowMapHorizontal),wc.material=this.vsmMaterialHorizontal,wc.render(r)}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(r){let{shadow:t}=this,e=t.needsUpdate||t.autoUpdate;e&&(this._cameraFrameId[r.camera]===r.frameId&&(e=!1),this._cameraFrameId[r.camera]=r.frameId),e&&(this.updateShadow(r),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const gP=(r,t)=>W(new sN(r,t)),yP=new Kt,Os=C(([r,t])=>{let e=r.toVar(),s=Jt(e),i=Js(1,ye(s.x,ye(s.y,s.z)));s.mulAssign(i),e.mulAssign(i.mul(t.mul(2).oneMinus()));let n=Y(e.xy).toVar(),a=t.mul(1.5),o=a.oneMinus();return xt(s.z.greaterThanEqual(o),()=>{xt(e.z.greaterThan(0),()=>{n.x.assign(zt(4,e.x))})}).ElseIf(s.x.greaterThanEqual(o),()=>{let l=qu(e.x);n.x.assign(e.z.mul(l).add(l.mul(2)))}).ElseIf(s.y.greaterThanEqual(o),()=>{let l=qu(e.y);n.x.assign(e.x.add(l.mul(2)).add(2)),n.y.assign(e.z.mul(l).sub(2))}),Y(.125,.25).mul(n).add(Y(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),iN=C(({depthTexture:r,bd3D:t,dp:e,texelSize:s})=>Bt(r,Os(t,s.y)).compare(e)),nN=C(({depthTexture:r,bd3D:t,dp:e,texelSize:s,shadow:i})=>{let n=pe("radius","float",i).setGroup(Tt),a=Y(-1,1).mul(n).mul(s.y);return Bt(r,Os(t.add(a.xyy),s.y)).compare(e).add(Bt(r,Os(t.add(a.yyy),s.y)).compare(e)).add(Bt(r,Os(t.add(a.xyx),s.y)).compare(e)).add(Bt(r,Os(t.add(a.yyx),s.y)).compare(e)).add(Bt(r,Os(t,s.y)).compare(e)).add(Bt(r,Os(t.add(a.xxy),s.y)).compare(e)).add(Bt(r,Os(t.add(a.yxy),s.y)).compare(e)).add(Bt(r,Os(t.add(a.xxx),s.y)).compare(e)).add(Bt(r,Os(t.add(a.yxx),s.y)).compare(e)).mul(1/9)}),xP=C(({filterFn:r,depthTexture:t,shadowCoord:e,shadow:s})=>{let i=e.xyz.toVar(),n=i.length(),a=ct("float").setGroup(Tt).onRenderUpdate(()=>s.camera.near),o=ct("float").setGroup(Tt).onRenderUpdate(()=>s.camera.far),l=pe("bias","float",s).setGroup(Tt),h=ct(s.mapSize).setGroup(Tt),u=v(1).toVar();return xt(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),()=>{let c=n.sub(a).div(o.sub(a)).toVar();c.addAssign(l);let d=i.normalize(),p=Y(1).div(h.mul(Y(4,2)));u.assign(r({depthTexture:t,bd3D:d,dp:c,texelSize:p,shadow:s}))}),u}),N1=new wr,wo=new jt,nu=new jt;var bP=class extends sN{static get type(){return"PointShadowNode"}constructor(r,t=null){super(r,t)}getShadowFilterFn(r){return r===YA?iN:nN}setupShadowCoord(r,t){return t}setupShadowFilter(r,{filterFn:t,shadowTexture:e,depthTexture:s,shadowCoord:i,shadow:n}){return xP({filterFn:t,shadowTexture:e,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(r){let{shadow:t,shadowMap:e,light:s}=this,{renderer:i,scene:n}=r,a=t.getFrameExtents();nu.copy(t.mapSize),nu.multiply(a),e.setSize(nu.width,nu.height),wo.copy(t.mapSize);let o=i.autoClear,l=i.getClearColor(yP),h=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let c=0;c<u;c++){let d=t.getViewport(c),p=wo.x*d.x,m=nu.y-wo.y-wo.y*d.y;N1.set(p,m,wo.x*d.z,wo.y*d.w),e.viewport.copy(N1),t.updateMatrices(s,c),i.render(n,t.camera)}i.autoClear=o,i.setClearColor(l,h)}};const vP=(r,t)=>W(new bP(r,t)),aN=C(({lightDistance:r,cutoffDistance:t,decayExponent:e})=>{let s=r.pow(e).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(r.div(t).pow4().oneMinus().clamp().pow2()),s)}),wP=({color:r,lightVector:t,cutoffDistance:e,decayExponent:s})=>{let i=t.normalize(),n=t.length(),a=aN({lightDistance:n,cutoffDistance:e,decayExponent:s}),o=r.mul(a);return{lightDirection:i,lightColor:o}},MP=C(([r=oe()])=>{let t=r.mul(2),e=t.x.floor(),s=t.y.floor();return e.add(s).mod(2).sign()}),TP=C(([r=oe()],{renderer:t,material:e})=>{let s=cy(r.mul(2).sub(1)),i;if(e.alphaToCoverage&&t.samples>1){let n=v(s.fwidth()).toVar();i=rn(n.oneMinus(),n.add(1),s).oneMinus()}else i=Qe(s.greaterThan(1),0,1);return i}),Ru=C(([r,t,e])=>{let s=v(e).toVar(),i=v(t).toVar(),n=fi(r).toVar();return Qe(n,i,s)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Od=C(([r,t])=>{let e=fi(t).toVar(),s=v(r).toVar();return Qe(e,s.negate(),s)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ae=C(([r])=>{let t=v(r).toVar();return T(ui(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ne=C(([r,t])=>{let e=v(r).toVar();return t.assign(Ae(e)),e.sub(v(t))}),NP=C(([r,t,e,s,i,n])=>{let a=v(n).toVar(),o=v(i).toVar(),l=v(s).toVar(),h=v(e).toVar(),u=v(t).toVar(),c=v(r).toVar(),d=v(zt(1,o)).toVar();return zt(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),SP=C(([r,t,e,s,i,n])=>{let a=v(n).toVar(),o=v(i).toVar(),l=E(s).toVar(),h=E(e).toVar(),u=E(t).toVar(),c=E(r).toVar(),d=v(zt(1,o)).toVar();return zt(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),oN=hr([NP,SP]),_P=C(([r,t,e,s,i,n,a,o,l,h,u])=>{let c=v(u).toVar(),d=v(h).toVar(),p=v(l).toVar(),m=v(o).toVar(),f=v(a).toVar(),x=v(n).toVar(),b=v(i).toVar(),w=v(s).toVar(),S=v(e).toVar(),_=v(t).toVar(),V=v(r).toVar(),z=v(zt(1,p)).toVar(),A=v(zt(1,d)).toVar();return v(zt(1,c)).toVar().mul(A.mul(V.mul(z).add(_.mul(p))).add(d.mul(S.mul(z).add(w.mul(p))))).add(c.mul(A.mul(b.mul(z).add(x.mul(p))).add(d.mul(f.mul(z).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"}]}),AP=C(([r,t,e,s,i,n,a,o,l,h,u])=>{let c=v(u).toVar(),d=v(h).toVar(),p=v(l).toVar(),m=E(o).toVar(),f=E(a).toVar(),x=E(n).toVar(),b=E(i).toVar(),w=E(s).toVar(),S=E(e).toVar(),_=E(t).toVar(),V=E(r).toVar(),z=v(zt(1,p)).toVar(),A=v(zt(1,d)).toVar();return v(zt(1,c)).toVar().mul(A.mul(V.mul(z).add(_.mul(p))).add(d.mul(S.mul(z).add(w.mul(p))))).add(c.mul(A.mul(b.mul(z).add(x.mul(p))).add(d.mul(f.mul(z).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"}]}),lN=hr([_P,AP]),zP=C(([r,t,e])=>{let s=v(e).toVar(),i=v(t).toVar(),n=rt(r).toVar(),a=rt(n.bitAnd(rt(7))).toVar(),o=v(Ru(a.lessThan(rt(4)),i,s)).toVar(),l=v(gt(2,Ru(a.lessThan(rt(4)),s,i))).toVar();return Od(o,fi(a.bitAnd(rt(1)))).add(Od(l,fi(a.bitAnd(rt(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),CP=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=v(t).toVar(),o=rt(r).toVar(),l=rt(o.bitAnd(rt(15))).toVar(),h=v(Ru(l.lessThan(rt(8)),a,n)).toVar(),u=v(Ru(l.lessThan(rt(4)),n,Ru(l.equal(rt(12)).or(l.equal(rt(14))),a,i))).toVar();return Od(h,fi(l.bitAnd(rt(1)))).add(Od(u,fi(l.bitAnd(rt(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"}]}),sr=hr([zP,CP]),EP=C(([r,t,e])=>{let s=v(e).toVar(),i=v(t).toVar(),n=kl(r).toVar();return E(sr(n.x,i,s),sr(n.y,i,s),sr(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),VP=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=v(t).toVar(),o=kl(r).toVar();return E(sr(o.x,a,n,i),sr(o.y,a,n,i),sr(o.z,a,n,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"}]}),ls=hr([EP,VP]),RP=C(([r])=>{let t=v(r).toVar();return gt(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),LP=C(([r])=>{let t=v(r).toVar();return gt(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),IP=C(([r])=>{let t=E(r).toVar();return gt(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),uN=hr([RP,IP]),PP=C(([r])=>{let t=E(r).toVar();return gt(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),hN=hr([LP,PP]),Hr=C(([r,t])=>{let e=T(t).toVar(),s=rt(r).toVar();return s.shiftLeft(e).bitOr(s.shiftRight(T(32).sub(e)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),cN=C(([r,t,e])=>{r.subAssign(e),r.bitXorAssign(Hr(e,T(4))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(Hr(r,T(6))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(Hr(t,T(8))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(Hr(e,T(16))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(Hr(r,T(19))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(Hr(t,T(4))),t.addAssign(r)}),vh=C(([r,t,e])=>{let s=rt(e).toVar(),i=rt(t).toVar(),n=rt(r).toVar();return s.bitXorAssign(i),s.subAssign(Hr(i,T(14))),n.bitXorAssign(s),n.subAssign(Hr(s,T(11))),i.bitXorAssign(n),i.subAssign(Hr(n,T(25))),s.bitXorAssign(i),s.subAssign(Hr(i,T(16))),n.bitXorAssign(s),n.subAssign(Hr(s,T(4))),i.bitXorAssign(n),i.subAssign(Hr(n,T(14))),s.bitXorAssign(i),s.subAssign(Hr(i,T(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),br=C(([r])=>{let t=rt(r).toVar();return v(t).div(v(rt(T(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ci=C(([r])=>{let t=v(r).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"}]}),FP=C(([r])=>{let t=T(r).toVar(),e=rt(rt(1)).toVar(),s=rt(rt(T(3735928559)).add(e.shiftLeft(rt(2))).add(rt(13))).toVar();return vh(s.add(rt(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),OP=C(([r,t])=>{let e=T(t).toVar(),s=T(r).toVar(),i=rt(rt(2)).toVar(),n=rt().toVar(),a=rt().toVar(),o=rt().toVar();return n.assign(a.assign(o.assign(rt(T(3735928559)).add(i.shiftLeft(rt(2))).add(rt(13))))),n.addAssign(rt(s)),a.addAssign(rt(e)),vh(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),BP=C(([r,t,e])=>{let s=T(e).toVar(),i=T(t).toVar(),n=T(r).toVar(),a=rt(rt(3)).toVar(),o=rt().toVar(),l=rt().toVar(),h=rt().toVar();return o.assign(l.assign(h.assign(rt(T(3735928559)).add(a.shiftLeft(rt(2))).add(rt(13))))),o.addAssign(rt(n)),l.addAssign(rt(i)),h.addAssign(rt(s)),vh(o,l,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),kP=C(([r,t,e,s])=>{let i=T(s).toVar(),n=T(e).toVar(),a=T(t).toVar(),o=T(r).toVar(),l=rt(rt(4)).toVar(),h=rt().toVar(),u=rt().toVar(),c=rt().toVar();return h.assign(u.assign(c.assign(rt(T(3735928559)).add(l.shiftLeft(rt(2))).add(rt(13))))),h.addAssign(rt(o)),u.addAssign(rt(a)),c.addAssign(rt(n)),cN(h,u,c),h.addAssign(rt(i)),vh(h,u,c)}).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"}]}),DP=C(([r,t,e,s,i])=>{let n=T(i).toVar(),a=T(s).toVar(),o=T(e).toVar(),l=T(t).toVar(),h=T(r).toVar(),u=rt(rt(5)).toVar(),c=rt().toVar(),d=rt().toVar(),p=rt().toVar();return c.assign(d.assign(p.assign(rt(T(3735928559)).add(u.shiftLeft(rt(2))).add(rt(13))))),c.addAssign(rt(h)),d.addAssign(rt(l)),p.addAssign(rt(o)),cN(c,d,p),c.addAssign(rt(a)),d.addAssign(rt(n)),vh(c,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Dt=hr([FP,OP,BP,kP,DP]),UP=C(([r,t])=>{let e=T(t).toVar(),s=T(r).toVar(),i=rt(Dt(s,e)).toVar(),n=kl().toVar();return n.x.assign(i.bitAnd(T(255))),n.y.assign(i.shiftRight(T(8)).bitAnd(T(255))),n.z.assign(i.shiftRight(T(16)).bitAnd(T(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),$P=C(([r,t,e])=>{let s=T(e).toVar(),i=T(t).toVar(),n=T(r).toVar(),a=rt(Dt(n,i,s)).toVar(),o=kl().toVar();return o.x.assign(a.bitAnd(T(255))),o.y.assign(a.shiftRight(T(8)).bitAnd(T(255))),o.z.assign(a.shiftRight(T(16)).bitAnd(T(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),us=hr([UP,$P]),jP=C(([r])=>{let t=Y(r).toVar(),e=T().toVar(),s=T().toVar(),i=v(ne(t.x,e)).toVar(),n=v(ne(t.y,s)).toVar(),a=v(ci(i)).toVar(),o=v(ci(n)).toVar(),l=v(oN(sr(Dt(e,s),i,n),sr(Dt(e.add(T(1)),s),i.sub(1),n),sr(Dt(e,s.add(T(1))),i,n.sub(1)),sr(Dt(e.add(T(1)),s.add(T(1))),i.sub(1),n.sub(1)),a,o)).toVar();return uN(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),WP=C(([r])=>{let t=E(r).toVar(),e=T().toVar(),s=T().toVar(),i=T().toVar(),n=v(ne(t.x,e)).toVar(),a=v(ne(t.y,s)).toVar(),o=v(ne(t.z,i)).toVar(),l=v(ci(n)).toVar(),h=v(ci(a)).toVar(),u=v(ci(o)).toVar(),c=v(lN(sr(Dt(e,s,i),n,a,o),sr(Dt(e.add(T(1)),s,i),n.sub(1),a,o),sr(Dt(e,s.add(T(1)),i),n,a.sub(1),o),sr(Dt(e.add(T(1)),s.add(T(1)),i),n.sub(1),a.sub(1),o),sr(Dt(e,s,i.add(T(1))),n,a,o.sub(1)),sr(Dt(e.add(T(1)),s,i.add(T(1))),n.sub(1),a,o.sub(1)),sr(Dt(e,s.add(T(1)),i.add(T(1))),n,a.sub(1),o.sub(1)),sr(Dt(e.add(T(1)),s.add(T(1)),i.add(T(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return hN(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),jy=hr([jP,WP]),qP=C(([r])=>{let t=Y(r).toVar(),e=T().toVar(),s=T().toVar(),i=v(ne(t.x,e)).toVar(),n=v(ne(t.y,s)).toVar(),a=v(ci(i)).toVar(),o=v(ci(n)).toVar(),l=E(oN(ls(us(e,s),i,n),ls(us(e.add(T(1)),s),i.sub(1),n),ls(us(e,s.add(T(1))),i,n.sub(1)),ls(us(e.add(T(1)),s.add(T(1))),i.sub(1),n.sub(1)),a,o)).toVar();return uN(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),HP=C(([r])=>{let t=E(r).toVar(),e=T().toVar(),s=T().toVar(),i=T().toVar(),n=v(ne(t.x,e)).toVar(),a=v(ne(t.y,s)).toVar(),o=v(ne(t.z,i)).toVar(),l=v(ci(n)).toVar(),h=v(ci(a)).toVar(),u=v(ci(o)).toVar(),c=E(lN(ls(us(e,s,i),n,a,o),ls(us(e.add(T(1)),s,i),n.sub(1),a,o),ls(us(e,s.add(T(1)),i),n,a.sub(1),o),ls(us(e.add(T(1)),s.add(T(1)),i),n.sub(1),a.sub(1),o),ls(us(e,s,i.add(T(1))),n,a,o.sub(1)),ls(us(e.add(T(1)),s,i.add(T(1))),n.sub(1),a,o.sub(1)),ls(us(e,s.add(T(1)),i.add(T(1))),n,a.sub(1),o.sub(1)),ls(us(e.add(T(1)),s.add(T(1)),i.add(T(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return hN(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wy=hr([qP,HP]),GP=C(([r])=>{let t=v(r).toVar(),e=T(Ae(t)).toVar();return br(Dt(e))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),XP=C(([r])=>{let t=Y(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar();return br(Dt(e,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),YP=C(([r])=>{let t=E(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar(),i=T(Ae(t.z)).toVar();return br(Dt(e,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ZP=C(([r])=>{let t=ut(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar(),i=T(Ae(t.z)).toVar(),n=T(Ae(t.w)).toVar();return br(Dt(e,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),JP=hr([GP,XP,YP,ZP]),QP=C(([r])=>{let t=v(r).toVar(),e=T(Ae(t)).toVar();return E(br(Dt(e,T(0))),br(Dt(e,T(1))),br(Dt(e,T(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),KP=C(([r])=>{let t=Y(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar();return E(br(Dt(e,s,T(0))),br(Dt(e,s,T(1))),br(Dt(e,s,T(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),t6=C(([r])=>{let t=E(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar(),i=T(Ae(t.z)).toVar();return E(br(Dt(e,s,i,T(0))),br(Dt(e,s,i,T(1))),br(Dt(e,s,i,T(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),e6=C(([r])=>{let t=ut(r).toVar(),e=T(Ae(t.x)).toVar(),s=T(Ae(t.y)).toVar(),i=T(Ae(t.z)).toVar(),n=T(Ae(t.w)).toVar();return E(br(Dt(e,s,i,n,T(0))),br(Dt(e,s,i,n,T(1))),br(Dt(e,s,i,n,T(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),dN=hr([QP,KP,t6,e6]),Bd=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=T(t).toVar(),o=E(r).toVar(),l=v(0).toVar(),h=v(1).toVar();return Pt(a,()=>{l.addAssign(h.mul(jy(o))),h.mulAssign(i),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),pN=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=T(t).toVar(),o=E(r).toVar(),l=E(0).toVar(),h=v(1).toVar();return Pt(a,()=>{l.addAssign(h.mul(Wy(o))),h.mulAssign(i),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),r6=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=T(t).toVar(),o=E(r).toVar();return Y(Bd(o,a,n,i),Bd(o.add(E(T(19),T(193),T(17))),a,n,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"}]}),s6=C(([r,t,e,s])=>{let i=v(s).toVar(),n=v(e).toVar(),a=T(t).toVar(),o=E(r).toVar(),l=E(pN(o,a,n,i)).toVar(),h=v(Bd(o.add(E(T(19),T(193),T(17))),a,n,i)).toVar();return ut(l,h)}).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"}]}),i6=C(([r,t,e,s,i,n,a])=>{let o=T(a).toVar(),l=v(n).toVar(),h=T(i).toVar(),u=T(s).toVar(),c=T(e).toVar(),d=T(t).toVar(),p=Y(r).toVar(),m=E(dN(Y(d.add(u),c.add(h)))).toVar(),f=Y(m.x,m.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);let x=Y(Y(v(d),v(c)).add(f)).toVar(),b=Y(x.sub(p)).toVar();return xt(o.equal(T(2)),()=>Jt(b.x).add(Jt(b.y))),xt(o.equal(T(3)),()=>ye(Jt(b.x),Jt(b.y))),ia(b,b)}).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"}]}),n6=C(([r,t,e,s,i,n,a,o,l])=>{let h=T(l).toVar(),u=v(o).toVar(),c=T(a).toVar(),d=T(n).toVar(),p=T(i).toVar(),m=T(s).toVar(),f=T(e).toVar(),x=T(t).toVar(),b=E(r).toVar(),w=E(dN(E(x.add(p),f.add(d),m.add(c)))).toVar();w.subAssign(.5),w.mulAssign(u),w.addAssign(.5);let S=E(E(v(x),v(f),v(m)).add(w)).toVar(),_=E(S.sub(b)).toVar();return xt(h.equal(T(2)),()=>Jt(_.x).add(Jt(_.y)).add(Jt(_.z))),xt(h.equal(T(3)),()=>ye(Jt(_.x),Jt(_.y),Jt(_.z))),ia(_,_)}).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"}]}),Ul=hr([i6,n6]),a6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=Y(r).toVar(),a=T().toVar(),o=T().toVar(),l=Y(ne(n.x,a),ne(n.y,o)).toVar(),h=v(1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:u})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:c})=>{let d=v(Ul(l,u,c,a,o,i,s)).toVar();h.assign(ts(h,d))})}),xt(s.equal(T(0)),()=>{h.assign(Ni(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),o6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=Y(r).toVar(),a=T().toVar(),o=T().toVar(),l=Y(ne(n.x,a),ne(n.y,o)).toVar(),h=Y(1e6,1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:u})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:c})=>{let d=v(Ul(l,u,c,a,o,i,s)).toVar();xt(d.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.y.assign(d)})})}),xt(s.equal(T(0)),()=>{h.assign(Ni(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),l6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=Y(r).toVar(),a=T().toVar(),o=T().toVar(),l=Y(ne(n.x,a),ne(n.y,o)).toVar(),h=E(1e6,1e6,1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:u})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:c})=>{let d=v(Ul(l,u,c,a,o,i,s)).toVar();xt(d.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(d)}).ElseIf(d.lessThan(h.z),()=>{h.z.assign(d)})})}),xt(s.equal(T(0)),()=>{h.assign(Ni(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),u6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=E(r).toVar(),a=T().toVar(),o=T().toVar(),l=T().toVar(),h=E(ne(n.x,a),ne(n.y,o),ne(n.z,l)).toVar(),u=v(1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:c})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:d})=>{Pt({start:-1,end:T(1),name:"z",condition:"<="},({z:p})=>{let m=v(Ul(h,c,d,p,a,o,l,i,s)).toVar();u.assign(ts(u,m))})})}),xt(s.equal(T(0)),()=>{u.assign(Ni(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),h6=hr([a6,u6]),c6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=E(r).toVar(),a=T().toVar(),o=T().toVar(),l=T().toVar(),h=E(ne(n.x,a),ne(n.y,o),ne(n.z,l)).toVar(),u=Y(1e6,1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:c})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:d})=>{Pt({start:-1,end:T(1),name:"z",condition:"<="},({z:p})=>{let m=v(Ul(h,c,d,p,a,o,l,i,s)).toVar();xt(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),xt(s.equal(T(0)),()=>{u.assign(Ni(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),d6=hr([o6,c6]),p6=C(([r,t,e])=>{let s=T(e).toVar(),i=v(t).toVar(),n=E(r).toVar(),a=T().toVar(),o=T().toVar(),l=T().toVar(),h=E(ne(n.x,a),ne(n.y,o),ne(n.z,l)).toVar(),u=E(1e6,1e6,1e6).toVar();return Pt({start:-1,end:T(1),name:"x",condition:"<="},({x:c})=>{Pt({start:-1,end:T(1),name:"y",condition:"<="},({y:d})=>{Pt({start:-1,end:T(1),name:"z",condition:"<="},({z:p})=>{let m=v(Ul(h,c,d,p,a,o,l,i,s)).toVar();xt(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),xt(s.equal(T(0)),()=>{u.assign(Ni(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),m6=hr([l6,p6]),f6=C(([r])=>{let t=r.y,e=r.z,s=E().toVar();return xt(t.lessThan(1e-4),()=>{s.assign(E(e,e,e))}).Else(()=>{let i=r.x;i=i.sub(ui(i)).mul(6).toVar();let n=T(hy(i)),a=i.sub(v(n)),o=e.mul(t.oneMinus()),l=e.mul(t.mul(a).oneMinus()),h=e.mul(t.mul(a.oneMinus()).oneMinus());xt(n.equal(T(0)),()=>{s.assign(E(e,h,o))}).ElseIf(n.equal(T(1)),()=>{s.assign(E(l,e,o))}).ElseIf(n.equal(T(2)),()=>{s.assign(E(o,e,h))}).ElseIf(n.equal(T(3)),()=>{s.assign(E(o,l,e))}).ElseIf(n.equal(T(4)),()=>{s.assign(E(h,o,e))}).Else(()=>{s.assign(E(e,o,l))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),g6=C(([r])=>{let t=E(r).toVar(),e=v(t.x).toVar(),s=v(t.y).toVar(),i=v(t.z).toVar(),n=v(ts(e,ts(s,i))).toVar(),a=v(ye(e,ye(s,i))).toVar(),o=v(a.sub(n)).toVar(),l=v().toVar(),h=v().toVar(),u=v().toVar();return u.assign(a),xt(a.greaterThan(0),()=>{h.assign(o.div(a))}).Else(()=>{h.assign(0)}),xt(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{xt(e.greaterThanEqual(a),()=>{l.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{l.assign(Ce(2,i.sub(e).div(o)))}).Else(()=>{l.assign(Ce(4,e.sub(s).div(o)))}),l.mulAssign(1/6),xt(l.lessThan(0),()=>{l.addAssign(1)})}),E(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),y6=C(([r])=>{let t=E(r).toVar(),e=ry(iy(t,E(.04045))).toVar(),s=E(t.div(12.92)).toVar(),i=E(Xs(ye(t.add(E(.055)),E(0)).div(1.055),E(2.4))).toVar();return fe(s,i,e)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),mN=(r,t)=>{r=v(r),t=v(t);let e=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return rn(r.sub(e),r.add(e),t)},fN=(r,t,e,s)=>fe(r,t,e[s].clamp()),x6=(r,t,e=oe())=>fN(r,t,e,"x"),b6=(r,t,e=oe())=>fN(r,t,e,"y"),gN=(r,t,e,s,i)=>fe(r,t,mN(e,s[i])),v6=(r,t,e,s=oe())=>gN(r,t,e,s,"x"),w6=(r,t,e,s=oe())=>gN(r,t,e,s,"y"),M6=(r=1,t=0,e=oe())=>e.mul(r).add(t),T6=(r,t=1)=>(r=v(r),r.abs().pow(t).mul(r.sign())),N6=(r,t=1,e=.5)=>v(r).sub(e).mul(t).add(e),S6=(r=oe(),t=1,e=0)=>jy(r.convert("vec2|vec3")).mul(t).add(e),_6=(r=oe(),t=1,e=0)=>Wy(r.convert("vec2|vec3")).mul(t).add(e),A6=(r=oe(),t=1,e=0)=>(r=r.convert("vec2|vec3"),ut(Wy(r),jy(r.add(Y(19,73)))).mul(t).add(e)),z6=(r=oe(),t=1)=>h6(r.convert("vec2|vec3"),t,T(1)),C6=(r=oe(),t=1)=>d6(r.convert("vec2|vec3"),t,T(1)),E6=(r=oe(),t=1)=>m6(r.convert("vec2|vec3"),t,T(1)),V6=(r=oe())=>JP(r.convert("vec2|vec3")),R6=(r=oe(),t=3,e=2,s=.5,i=1)=>Bd(r,T(t),e,s).mul(i),L6=(r=oe(),t=3,e=2,s=.5,i=1)=>r6(r,T(t),e,s).mul(i),I6=(r=oe(),t=3,e=2,s=.5,i=1)=>pN(r,T(t),e,s).mul(i),P6=(r=oe(),t=3,e=2,s=.5,i=1)=>s6(r,T(t),e,s).mul(i),F6=C(([r,t,e])=>{let s=en(r).toVar(),i=zt(v(.5).mul(t.sub(e)),Ra).div(s).toVar(),n=zt(v(-.5).mul(t.sub(e)),Ra).div(s).toVar(),a=E().toVar();a.x=s.x.greaterThan(v(0)).select(i.x,n.x),a.y=s.y.greaterThan(v(0)).select(i.y,n.y),a.z=s.z.greaterThan(v(0)).select(i.z,n.z);let o=ts(a.x,a.y,a.z).toVar();return Ra.add(s.mul(o)).toVar().sub(e)}),O6=C(([r,t])=>{let e=r.x,s=r.y,i=r.z,n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(2*.511664).mul(s)),n=n.add(t.element(2).mul(2*.511664).mul(i)),n=n.add(t.element(3).mul(2*.511664).mul(e)),n=n.add(t.element(4).mul(2*.429043).mul(e).mul(s)),n=n.add(t.element(5).mul(2*.429043).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(2*.429043).mul(e).mul(i)),n=n.add(t.element(8).mul(.429043).mul(gt(e,e).sub(gt(s,s)))),n});var g=Object.freeze({__proto__:null,BRDF_GGX:XR,BRDF_Lambert:UR,BasicPointShadowFilter:iN,BasicShadowFilter:J2,Break:n2,Const:rT,Continue:cR,DFGApprox:x2,D_GGX:y2,Discard:bT,EPSILON:NM,F_Schlick:Gu,Fn:C,INFINITY:uE,If:xt,Loop:Pt,NodeAccess:ii,NodeShaderStage:wu,NodeType:gC,NodeUpdateType:It,PCFShadowFilter:Q2,PCFSoftShadowFilter:K2,PI:Rd,PI2:hE,PointShadowFilter:nN,Return:zE,Schlick_to_F0:ZR,ScriptableNodeResources:yd,ShaderNode:Jo,Stack:dp,Switch:BC,TBNViewMatrix:zy,VSMShadowFilter:tN,V_GGX_SmithCorrelated:g2,Var:eT,abs:Jt,acesFilmicToneMapping:oI,acos:VM,add:Ce,addMethodChaining:D,addNodeElement:VE,agxToneMapping:cI,all:SM,alphaT:Xf,and:lM,anisotropy:Zw,anisotropyB:al,anisotropyT:md,any:_M,append:$C,array:eM,arrayBuffer:DC,asin:EM,assign:rM,atan:oy,atan2:JM,atomicAdd:jI,atomicAnd:GI,atomicFunc:Si,atomicLoad:UI,atomicMax:qI,atomicMin:HI,atomicOr:XI,atomicStore:$I,atomicSub:WI,atomicXor:YI,attenuationColor:sE,attenuationDistance:rE,attribute:Zn,attributeArray:ML,backgroundBlurriness:_L,backgroundIntensity:AL,backgroundRotation:zL,batch:r2,billboarding:sL,bitAnd:dM,bitNot:pM,bitOr:mM,bitXor:fM,bitangentGeometry:dV,bitangentLocal:pV,bitangentView:DT,bitangentWorld:mV,bitcast:cE,blendBurn:O2,blendColor:BL,blendDodge:B2,blendOverlay:D2,blendScreen:k2,blur:N2,bool:fi,buffer:ch,bufferAttribute:hh,bumpMap:jT,burn:UL,bvec2:kw,bvec3:ry,bvec4:jw,bypass:fT,cache:pT,call:sM,cameraFar:In,cameraIndex:vp,cameraNear:Ln,cameraNormalMatrix:jE,cameraPosition:WE,cameraProjectionMatrix:dh,cameraProjectionMatrixInverse:UE,cameraViewMatrix:Ts,cameraWorldMatrix:$E,cbrt:HM,cdl:YL,ceil:gp,checker:MP,cineonToneMapping:nI,clamp:gi,clearcoat:qC,clearcoatRoughness:HC,code:_p,color:Ow,colorSpaceToWorking:xy,colorToDirection:FR,compute:dT,computeSkinning:uR,cond:QM,context:my,convert:qw,convertColorSpace:xE,convertToTexture:yL,cos:ki,cross:xp,cubeTexture:wp,cubeTextureBase:_y,cubeToUV:Os,dFdx:ly,dFdy:uy,dashSize:ZC,debug:wT,decrement:wM,decrementBefore:bM,defaultBuildStages:yC,defaultShaderStages:Ew,defined:ju,degrees:zM,deltaTime:E2,densityFog:NI,densityFogFactor:G2,depth:Iy,depthPass:tI,difference:UM,diffuseColor:as,directPointLight:wP,directionToColor:PR,dispersion:iE,distance:DM,div:Js,dodge:$L,dot:ia,drawIndex:KT,dynamicBufferAttribute:cT,element:Ww,emissive:Gf,equal:sy,equals:BM,equirectUV:Py,exp:ny,exp2:Cl,expression:sn,faceDirection:mh,faceForward:py,faceforward:dE,float:v,floor:ui,fog:ky,fract:cn,frameGroup:nE,frameId:G4,frontFacing:zT,fwidth:FM,gain:D4,gapSize:JC,getConstNodeType:Pw,getCurrentStack:Fw,getDirection:M2,getDistanceAttenuation:aN,getGeometryRoughness:f2,getNormalFromDepth:bL,getParallaxCorrectNormal:F6,getRoughness:WR,getScreenPosition:xL,getShIrradianceAt:O6,getShadowMaterial:eN,getShadowRenderObjectFunction:rN,getTextureIndex:z2,getViewPosition:Go,globalId:EI,glsl:fI,glslFn:yI,grayscale:qL,greaterThan:iy,greaterThanEqual:oM,hash:k4,highpModelNormalViewMatrix:sV,highpModelViewMatrix:rV,hue:XL,increment:vM,incrementBefore:xM,instance:rR,instanceIndex:jn,instancedArray:TL,instancedBufferAttribute:Ld,instancedDynamicBufferAttribute:Jf,instancedMesh:e2,int:T,inverseSqrt:ay,inversesqrt:pE,invocationLocalIndex:eR,invocationSubgroupIndex:tR,ior:KC,iridescence:Yw,iridescenceIOR:GC,iridescenceThickness:XC,ivec2:Ge,ivec3:Dw,ivec4:Uw,js:pI,label:tT,length:hi,lengthSq:cy,lessThan:nM,lessThanEqual:aM,lightPosition:X2,lightProjectionUV:ZI,lightShadowMatrix:Uy,lightTargetDirection:QI,lightTargetPosition:Y2,lightViewPosition:JI,lightingContext:l2,lights:eP,linearDepth:Pd,linearToneMapping:sI,localId:VI,log:fp,log2:li,logarithmicDepthToViewZ:SR,loop:dR,luminance:By,mat2:pp,mat3:Ir,mat4:Va,matcapUV:S4,materialAO:ZT,materialAlphaTest:WT,materialAnisotropy:OV,materialAnisotropyVector:Ho,materialAttenuationColor:qV,materialAttenuationDistance:WV,materialClearcoat:VV,materialClearcoatNormal:LV,materialClearcoatRoughness:RV,materialColor:qT,materialDispersion:QV,materialEmissive:HT,materialEnvIntensity:aV,materialEnvRotation:Sy,materialIOR:jV,materialIridescence:BV,materialIridescenceIOR:kV,materialIridescenceThickness:DV,materialLightMap:YT,materialLineDashOffset:ZV,materialLineDashSize:GV,materialLineGapSize:XV,materialLineScale:HV,materialLineWidth:YV,materialMetalness:EV,materialNormal:XT,materialOpacity:GT,materialPointSize:JV,materialReference:Pn,materialReflectivity:zV,materialRefractionRatio:LT,materialRotation:IV,materialRoughness:CV,materialSheen:PV,materialSheenRoughness:FV,materialShininess:TV,materialSpecular:NV,materialSpecularColor:_V,materialSpecularIntensity:SV,materialSpecularStrength:AV,materialThickness:$V,materialTransmission:UV,max:ye,maxMipLevel:TT,mediumpModelViewMatrix:AT,metalness:WC,min:ts,mix:fe,mixElement:YM,mod:uh,modInt:TM,modelDirection:ZE,modelNormalMatrix:_T,modelPosition:JE,modelRadius:tV,modelScale:QE,modelViewMatrix:ph,modelViewPosition:KE,modelViewProjection:JT,modelWorldMatrix:ji,modelWorldMatrixInverse:eV,morphReference:a2,mrt:C2,mul:gt,mx_aastep:mN,mx_cell_noise_float:V6,mx_contrast:N6,mx_fractal_noise_float:R6,mx_fractal_noise_vec2:L6,mx_fractal_noise_vec3:I6,mx_fractal_noise_vec4:P6,mx_hsvtorgb:f6,mx_noise_float:S6,mx_noise_vec3:_6,mx_noise_vec4:A6,mx_ramplr:x6,mx_ramptb:b6,mx_rgbtohsv:g6,mx_safepower:T6,mx_splitlr:v6,mx_splittb:w6,mx_srgb_texture_to_lin_rec709:y6,mx_transform_uv:M6,mx_worley_noise_float:z6,mx_worley_noise_vec2:C6,mx_worley_noise_vec3:E6,namespace:mT,negate:RM,neutralToneMapping:dI,nodeArray:Ea,nodeImmutable:Q,nodeObject:W,nodeObjects:oh,nodeProxy:H,normalFlat:CT,normalGeometry:Ty,normalLocal:Pr,normalMap:Kf,normalView:yi,normalWorld:ET,normalize:en,not:hM,notEqual:iM,numWorkgroups:zI,objectDirection:qE,objectGroup:tM,objectPosition:ST,objectRadius:YE,objectScale:GE,objectViewPosition:XE,objectWorldMatrix:HE,oneMinus:LM,or:uM,orthographicDepthToViewZ:NR,oscSawtooth:tL,oscSine:J4,oscSquare:Q4,oscTriangle:K4,output:ol,outputStruct:O4,overlay:WL,overloadingFn:hr,parabola:ig,parallaxDirection:$T,parallaxUV:gV,parameter:E4,pass:QL,passTexture:KL,pcurve:U4,perspectiveDepthToViewZ:Ry,pmremTexture:T4,pointShadow:vP,pointUV:SL,pointWidth:QC,positionGeometry:wy,positionLocal:Se,positionPrevious:Id,positionView:ar,positionViewDirection:lr,positionWorld:Ra,positionWorldDirection:My,posterize:JL,pow:Xs,pow2:$M,pow3:jM,pow4:WM,premult:kL,property:Dl,radians:AM,rand:XM,range:_I,rangeFog:TI,rangeFogFactor:H2,reciprocal:PM,reference:pe,referenceBuffer:Qf,reflect:kM,reflectVector:FT,reflectView:IT,reflector:dL,refract:dy,refractVector:OT,refractView:PT,reinhardToneMapping:iI,remainder:MM,remap:yT,remapClamp:xT,renderGroup:Tt,renderOutput:vT,rendererReference:lT,rotate:_2,rotateUV:eL,roughness:Hw,round:IM,rtt:I2,sRGBTransferEOTF:nT,sRGBTransferOETF:aT,sampler:FE,samplerComparison:OE,saturate:GM,saturation:HL,screen:jL,screenCoordinate:xh,screenSize:Hu,screenUV:na,scriptable:MI,scriptableValue:gd,select:Qe,setCurrentStack:Hf,shaderStages:xC,shadow:gP,shadowPositionWorld:$y,shapeCircle:TP,sharedUniformGroup:mp,sheen:Gw,sheenRoughness:Xw,shiftLeft:gM,shiftRight:yM,shininess:Yf,sign:qu,sin:Xr,sinc:$4,skinning:i2,smoothstep:rn,smoothstepElement:ZM,specularColor:Jw,specularF90:YC,spherizeUV:rL,split:UC,spritesheetUV:aL,sqrt:Ni,stack:R4,step:yp,storage:La,storageBarrier:PI,storageObject:lR,storageTexture:P2,string:kC,struct:F4,sub:zt,subgroupIndex:KV,subgroupSize:RI,tan:CM,tangentGeometry:Tp,tangentLocal:fh,tangentView:gh,tangentWorld:kT,temp:sT,texture:Bt,texture3D:LL,textureBarrier:FI,textureBicubic:w2,textureCubeUV:T2,textureLoad:be,textureSize:$n,textureStore:EL,thickness:eE,time:Ya,timerDelta:Z4,timerGlobal:Y4,timerLocal:X4,toneMapping:uT,toneMappingExposure:hT,toonOutlinePass:rI,transformDirection:qM,transformNormal:RT,transformNormalToView:Ny,transformedBentNormalView:yV,transformedBitangentView:UT,transformedBitangentWorld:fV,transformedClearcoatNormalView:nV,transformedNormalView:Kr,transformedNormalWorld:VT,transformedTangentView:Ay,transformedTangentWorld:cV,transmission:tE,transpose:OM,triNoise3D:W4,triplanarTexture:lL,triplanarTextures:V2,trunc:hy,tslFn:jC,uint:rt,uniform:ct,uniformArray:js,uniformCubeTexture:lV,uniformGroup:Kw,uniformTexture:PE,uniforms:kE,unpremult:DL,userData:PL,uv:oe,uvec2:Bw,uvec3:kl,uvec4:$w,varying:fs,varyingProperty:Wu,vec2:Y,vec3:E,vec4:ut,vectorComponents:Bl,velocity:OL,vertexColor:p2,vertexIndex:QT,vertexStage:iT,vibrance:GL,viewZToLogarithmicDepth:Ly,viewZToOrthographicDepth:ll,viewZToPerspectiveDepth:c2,viewport:Cy,viewportBottomLeft:wR,viewportCoordinate:h2,viewportDepthTexture:Vy,viewportLinearDepth:_R,viewportMipTexture:Ey,viewportResolution:bR,viewportSafeUV:iL,viewportSharedTexture:IR,viewportSize:u2,viewportTexture:MR,viewportTopLeft:vR,viewportUV:xR,wgsl:mI,wgslFn:xI,workgroupArray:kI,workgroupBarrier:II,workgroupId:CI,workingToColorSpace:oT,xor:cM});new z4;new Lt;new Lt;C(([r,t])=>{let e=r.abs().sub(t);return hi(ye(e,0)).add(ts(ye(e.x,e.y),0))});new Vn;new Z2;new B;new B;new Zg;new jt;new wr;new fw;new Lt;new wr;new jt;const Mo=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};ii.READ_ONLY+"",ii.WRITE_ONLY+"",ii.READ_WRITE+"";Mo&&Mo.VERTEX,Mo&&Mo.FRAGMENT,Mo&&Mo.COMPUTE;const pa={tsl_xor:new qe("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new qe("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new qe("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new qe("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new qe("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new qe("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new qe("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new qe("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 qe("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 qe("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new qe("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 qe("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new qe(`
|
|
68
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
69
|
+
|
|
70
|
+
let res = vec2f( iRes );
|
|
71
|
+
|
|
72
|
+
let uvScaled = coord * res;
|
|
73
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
74
|
+
|
|
75
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
76
|
+
|
|
77
|
+
let uv = uvWrapping - 0.5;
|
|
78
|
+
let iuv = floor( uv );
|
|
79
|
+
let f = fract( uv );
|
|
80
|
+
|
|
81
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
82
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
83
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
84
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
85
|
+
|
|
86
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
`)};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(pa.pow_float=new qe("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),pa.pow_vec2=new qe("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 ) ); }",[pa.pow_float]),pa.pow_vec3=new qe("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 ) ); }",[pa.pow_float]),pa.pow_vec4=new qe("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 ) ); }",[pa.pow_float]));var rs={};XA(rs,{BRDF_GGX:()=>B6,BRDF_Lambert:()=>k6,BasicShadowFilter:()=>D6,Break:()=>U6,Const:()=>YO,Continue:()=>$6,DFGApprox:()=>j6,D_GGX:()=>W6,Discard:()=>q6,EPSILON:()=>H6,F_Schlick:()=>G6,Fn:()=>X6,INFINITY:()=>Y6,If:()=>Z6,Loop:()=>Q6,NodeAccess:()=>rF,NodeShaderStage:()=>K6,NodeType:()=>tF,NodeUpdateType:()=>eF,PCFShadowFilter:()=>sF,PCFSoftShadowFilter:()=>iF,PI:()=>nF,PI2:()=>aF,Return:()=>oF,Schlick_to_F0:()=>lF,ScriptableNodeResources:()=>uF,ShaderNode:()=>hF,Switch:()=>J6,TBNViewMatrix:()=>cF,VSMShadowFilter:()=>dF,V_GGX_SmithCorrelated:()=>pF,Var:()=>f$,abs:()=>mF,acesFilmicToneMapping:()=>fF,acos:()=>gF,add:()=>yF,addNodeElement:()=>xF,agxToneMapping:()=>bF,all:()=>vF,alphaT:()=>wF,and:()=>MF,anisotropy:()=>TF,anisotropyB:()=>NF,anisotropyT:()=>SF,any:()=>_F,append:()=>AF,array:()=>zF,arrayBuffer:()=>CF,asin:()=>EF,assign:()=>VF,atan:()=>RF,atan2:()=>LF,atomicAdd:()=>IF,atomicAnd:()=>PF,atomicFunc:()=>FF,atomicLoad:()=>jF,atomicMax:()=>OF,atomicMin:()=>BF,atomicOr:()=>kF,atomicStore:()=>DF,atomicSub:()=>UF,atomicXor:()=>$F,attenuationColor:()=>WF,attenuationDistance:()=>qF,attribute:()=>HF,attributeArray:()=>GF,backgroundBlurriness:()=>XF,backgroundIntensity:()=>YF,backgroundRotation:()=>ZF,batch:()=>JF,billboarding:()=>QF,bitAnd:()=>KF,bitNot:()=>tO,bitOr:()=>eO,bitXor:()=>rO,bitangentGeometry:()=>sO,bitangentLocal:()=>iO,bitangentView:()=>nO,bitangentWorld:()=>aO,bitcast:()=>oO,blendBurn:()=>lO,blendColor:()=>uO,blendDodge:()=>hO,blendOverlay:()=>cO,blendScreen:()=>dO,blur:()=>pO,bool:()=>mO,buffer:()=>fO,bufferAttribute:()=>gO,bumpMap:()=>yO,burn:()=>xO,bvec2:()=>bO,bvec3:()=>vO,bvec4:()=>wO,bypass:()=>MO,cache:()=>TO,call:()=>NO,cameraFar:()=>SO,cameraIndex:()=>_O,cameraNear:()=>AO,cameraNormalMatrix:()=>zO,cameraPosition:()=>CO,cameraProjectionMatrix:()=>EO,cameraProjectionMatrixInverse:()=>VO,cameraViewMatrix:()=>RO,cameraWorldMatrix:()=>LO,cbrt:()=>IO,cdl:()=>PO,ceil:()=>FO,checker:()=>OO,cineonToneMapping:()=>BO,clamp:()=>kO,clearcoat:()=>DO,clearcoatRoughness:()=>UO,code:()=>$O,color:()=>jO,colorSpaceToWorking:()=>WO,colorToDirection:()=>qO,compute:()=>HO,computeSkinning:()=>GO,cond:()=>XO,context:()=>ZO,convert:()=>JO,convertColorSpace:()=>QO,convertToTexture:()=>KO,cos:()=>t9,cross:()=>e9,cubeTexture:()=>r9,dFdx:()=>s9,dFdy:()=>i9,dashSize:()=>n9,debug:()=>a9,decrement:()=>o9,decrementBefore:()=>l9,defaultBuildStages:()=>u9,defaultShaderStages:()=>h9,defined:()=>c9,degrees:()=>d9,deltaTime:()=>p9,densityFog:()=>m9,densityFogFactor:()=>f9,depth:()=>g9,depthPass:()=>y9,difference:()=>x9,diffuseColor:()=>b9,directPointLight:()=>v9,directionToColor:()=>w9,dispersion:()=>M9,distance:()=>T9,div:()=>N9,dodge:()=>S9,dot:()=>_9,drawIndex:()=>A9,dynamicBufferAttribute:()=>z9,element:()=>C9,emissive:()=>E9,equal:()=>V9,equals:()=>R9,equirectUV:()=>L9,exp:()=>I9,exp2:()=>P9,expression:()=>F9,faceDirection:()=>O9,faceForward:()=>B9,faceforward:()=>k9,float:()=>D9,floor:()=>U9,fog:()=>$9,fract:()=>j9,frameGroup:()=>W9,frameId:()=>q9,frontFacing:()=>H9,fwidth:()=>G9,gain:()=>X9,gapSize:()=>Y9,getConstNodeType:()=>Z9,getCurrentStack:()=>J9,getDirection:()=>Q9,getDistanceAttenuation:()=>K9,getGeometryRoughness:()=>tB,getNormalFromDepth:()=>eB,getParallaxCorrectNormal:()=>rB,getRoughness:()=>sB,getScreenPosition:()=>iB,getShIrradianceAt:()=>nB,getShadowMaterial:()=>lB,getShadowRenderObjectFunction:()=>uB,getTextureIndex:()=>aB,getViewPosition:()=>oB,globalId:()=>ek,glsl:()=>hB,glslFn:()=>cB,grayscale:()=>dB,greaterThan:()=>pB,greaterThanEqual:()=>mB,hash:()=>fB,highpModelNormalViewMatrix:()=>gB,highpModelViewMatrix:()=>yB,hue:()=>xB,increment:()=>bB,incrementBefore:()=>vB,instance:()=>wB,instanceIndex:()=>MB,instancedArray:()=>TB,instancedBufferAttribute:()=>NB,instancedDynamicBufferAttribute:()=>SB,instancedMesh:()=>_B,int:()=>AB,inverseSqrt:()=>zB,inversesqrt:()=>CB,invocationLocalIndex:()=>EB,invocationSubgroupIndex:()=>VB,ior:()=>RB,iridescence:()=>LB,iridescenceIOR:()=>IB,iridescenceThickness:()=>PB,ivec2:()=>FB,ivec3:()=>OB,ivec4:()=>BB,js:()=>kB,label:()=>DB,length:()=>UB,lengthSq:()=>$B,lessThan:()=>jB,lessThanEqual:()=>WB,lightPosition:()=>qB,lightProjectionUV:()=>tD,lightShadowMatrix:()=>HB,lightTargetDirection:()=>GB,lightTargetPosition:()=>XB,lightViewPosition:()=>YB,lightingContext:()=>ZB,lights:()=>JB,linearDepth:()=>QB,linearToneMapping:()=>KB,localId:()=>tk,log:()=>rk,log2:()=>sk,logarithmicDepthToViewZ:()=>ik,loop:()=>nk,luminance:()=>ak,mat2:()=>lk,mat3:()=>uk,mat4:()=>hk,matcapUV:()=>ck,materialAO:()=>dk,materialAlphaTest:()=>pk,materialAnisotropy:()=>mk,materialAnisotropyVector:()=>fk,materialAttenuationColor:()=>gk,materialAttenuationDistance:()=>yk,materialClearcoat:()=>xk,materialClearcoatNormal:()=>bk,materialClearcoatRoughness:()=>vk,materialColor:()=>wk,materialDispersion:()=>Mk,materialEmissive:()=>Tk,materialIOR:()=>Nk,materialIridescence:()=>Sk,materialIridescenceIOR:()=>_k,materialIridescenceThickness:()=>Ak,materialLightMap:()=>zk,materialLineDashOffset:()=>Ck,materialLineDashSize:()=>Ek,materialLineGapSize:()=>Vk,materialLineScale:()=>Rk,materialLineWidth:()=>Lk,materialMetalness:()=>Ik,materialNormal:()=>Pk,materialOpacity:()=>Fk,materialPointSize:()=>Ok,materialReference:()=>Bk,materialReflectivity:()=>kk,materialRefractionRatio:()=>Dk,materialRotation:()=>Uk,materialRoughness:()=>$k,materialSheen:()=>jk,materialSheenRoughness:()=>Wk,materialShininess:()=>qk,materialSpecular:()=>Hk,materialSpecularColor:()=>Gk,materialSpecularIntensity:()=>Xk,materialSpecularStrength:()=>Yk,materialThickness:()=>Zk,materialTransmission:()=>Jk,max:()=>Qk,maxMipLevel:()=>Kk,mediumpModelViewMatrix:()=>ok,metalness:()=>t7,min:()=>e7,mix:()=>r7,mixElement:()=>s7,mod:()=>i7,modInt:()=>n7,modelDirection:()=>a7,modelNormalMatrix:()=>o7,modelPosition:()=>l7,modelRadius:()=>u7,modelScale:()=>h7,modelViewMatrix:()=>c7,modelViewPosition:()=>d7,modelViewProjection:()=>p7,modelWorldMatrix:()=>m7,modelWorldMatrixInverse:()=>f7,morphReference:()=>g7,mrt:()=>y7,mul:()=>x7,mx_aastep:()=>b7,mx_cell_noise_float:()=>v7,mx_contrast:()=>w7,mx_fractal_noise_float:()=>M7,mx_fractal_noise_vec2:()=>T7,mx_fractal_noise_vec3:()=>N7,mx_fractal_noise_vec4:()=>S7,mx_hsvtorgb:()=>_7,mx_noise_float:()=>A7,mx_noise_vec3:()=>z7,mx_noise_vec4:()=>C7,mx_ramplr:()=>E7,mx_ramptb:()=>V7,mx_rgbtohsv:()=>R7,mx_safepower:()=>L7,mx_splitlr:()=>I7,mx_splittb:()=>P7,mx_srgb_texture_to_lin_rec709:()=>F7,mx_transform_uv:()=>O7,mx_worley_noise_float:()=>B7,mx_worley_noise_vec2:()=>k7,mx_worley_noise_vec3:()=>D7,namespace:()=>U7,negate:()=>$7,neutralToneMapping:()=>j7,nodeArray:()=>W7,nodeImmutable:()=>q7,nodeObject:()=>H7,nodeObjects:()=>G7,nodeProxy:()=>X7,normalFlat:()=>Y7,normalGeometry:()=>Z7,normalLocal:()=>J7,normalMap:()=>Q7,normalView:()=>K7,normalWorld:()=>t8,normalize:()=>e8,not:()=>r8,notEqual:()=>s8,numWorkgroups:()=>i8,objectDirection:()=>n8,objectGroup:()=>a8,objectPosition:()=>o8,objectRadius:()=>l8,objectScale:()=>u8,objectViewPosition:()=>h8,objectWorldMatrix:()=>c8,oneMinus:()=>d8,or:()=>p8,orthographicDepthToViewZ:()=>m8,oscSawtooth:()=>f8,oscSine:()=>g8,oscSquare:()=>y8,oscTriangle:()=>x8,output:()=>b8,outputStruct:()=>v8,overlay:()=>w8,overloadingFn:()=>M8,parabola:()=>T8,parallaxDirection:()=>N8,parallaxUV:()=>S8,parameter:()=>_8,pass:()=>A8,passTexture:()=>z8,pcurve:()=>C8,perspectiveDepthToViewZ:()=>E8,pmremTexture:()=>V8,pointShadow:()=>BD,pointUV:()=>R8,pointWidth:()=>L8,positionGeometry:()=>I8,positionLocal:()=>P8,positionPrevious:()=>F8,positionView:()=>O8,positionViewDirection:()=>B8,positionWorld:()=>k8,positionWorldDirection:()=>D8,posterize:()=>U8,pow:()=>$8,pow2:()=>j8,pow3:()=>W8,pow4:()=>q8,premult:()=>H8,property:()=>G8,radians:()=>X8,rand:()=>Y8,range:()=>Z8,rangeFog:()=>J8,rangeFogFactor:()=>Q8,reciprocal:()=>K8,reference:()=>eD,referenceBuffer:()=>rD,reflect:()=>sD,reflectVector:()=>iD,reflectView:()=>nD,reflector:()=>aD,refract:()=>oD,refractVector:()=>lD,refractView:()=>uD,reinhardToneMapping:()=>hD,remainder:()=>cD,remap:()=>dD,remapClamp:()=>pD,renderGroup:()=>mD,renderOutput:()=>fD,rendererReference:()=>gD,rotate:()=>yD,rotateUV:()=>xD,roughness:()=>bD,round:()=>vD,rtt:()=>wD,sRGBTransferEOTF:()=>MD,sRGBTransferOETF:()=>TD,sampler:()=>ND,samplerComparison:()=>SD,saturate:()=>_D,saturation:()=>AD,screen:()=>zD,screenCoordinate:()=>CD,screenSize:()=>ED,screenUV:()=>VD,scriptable:()=>RD,scriptableValue:()=>LD,select:()=>ID,setCurrentStack:()=>PD,shaderStages:()=>FD,shadow:()=>OD,shadowPositionWorld:()=>kD,shapeCircle:()=>UD,sharedUniformGroup:()=>DD,sheen:()=>$D,sheenRoughness:()=>jD,shiftLeft:()=>WD,shiftRight:()=>qD,shininess:()=>HD,sign:()=>GD,sin:()=>XD,sinc:()=>YD,skinning:()=>ZD,smoothstep:()=>JD,smoothstepElement:()=>QD,specularColor:()=>KD,specularF90:()=>tU,spherizeUV:()=>eU,split:()=>rU,spritesheetUV:()=>sU,sqrt:()=>iU,stack:()=>nU,step:()=>aU,storage:()=>oU,storageBarrier:()=>lU,storageObject:()=>uU,storageTexture:()=>hU,string:()=>cU,struct:()=>dU,sub:()=>pU,subgroupIndex:()=>mU,subgroupSize:()=>fU,tan:()=>gU,tangentGeometry:()=>yU,tangentLocal:()=>xU,tangentView:()=>bU,tangentWorld:()=>vU,temp:()=>wU,texture:()=>MU,texture3D:()=>TU,textureBarrier:()=>NU,textureBicubic:()=>SU,textureCubeUV:()=>_U,textureLoad:()=>AU,textureSize:()=>zU,textureStore:()=>CU,thickness:()=>EU,time:()=>VU,timerDelta:()=>RU,timerGlobal:()=>LU,timerLocal:()=>IU,toneMapping:()=>PU,toneMappingExposure:()=>FU,toonOutlinePass:()=>OU,transformDirection:()=>BU,transformNormal:()=>kU,transformNormalToView:()=>DU,transformedBentNormalView:()=>UU,transformedBitangentView:()=>$U,transformedBitangentWorld:()=>jU,transformedClearcoatNormalView:()=>WU,transformedNormalView:()=>qU,transformedNormalWorld:()=>HU,transformedTangentView:()=>GU,transformedTangentWorld:()=>XU,transmission:()=>YU,transpose:()=>ZU,triNoise3D:()=>JU,triplanarTexture:()=>QU,triplanarTextures:()=>KU,trunc:()=>t$,tslFn:()=>e$,uint:()=>r$,uniform:()=>s$,uniformArray:()=>n$,uniformCubeTexture:()=>i$,uniformGroup:()=>a$,uniformTexture:()=>o$,uniforms:()=>l$,unpremult:()=>u$,userData:()=>h$,uv:()=>c$,uvec2:()=>d$,uvec3:()=>p$,uvec4:()=>m$,varying:()=>g$,varyingProperty:()=>y$,vec2:()=>x$,vec3:()=>b$,vec4:()=>v$,vectorComponents:()=>w$,velocity:()=>M$,vertexColor:()=>T$,vertexIndex:()=>N$,vibrance:()=>S$,viewZToLogarithmicDepth:()=>_$,viewZToOrthographicDepth:()=>A$,viewZToPerspectiveDepth:()=>z$,viewport:()=>C$,viewportBottomLeft:()=>E$,viewportCoordinate:()=>V$,viewportDepthTexture:()=>R$,viewportLinearDepth:()=>L$,viewportMipTexture:()=>I$,viewportResolution:()=>P$,viewportSafeUV:()=>F$,viewportSharedTexture:()=>O$,viewportSize:()=>B$,viewportTexture:()=>k$,viewportTopLeft:()=>D$,viewportUV:()=>U$,wgsl:()=>$$,wgslFn:()=>j$,workgroupArray:()=>W$,workgroupBarrier:()=>q$,workgroupId:()=>H$,workingToColorSpace:()=>G$,xor:()=>X$});const B6=g.BRDF_GGX,k6=g.BRDF_Lambert,D6=g.BasicShadowFilter,U6=g.Break,$6=g.Continue,j6=g.DFGApprox,W6=g.D_GGX,q6=g.Discard,H6=g.EPSILON,G6=g.F_Schlick,X6=g.Fn,Y6=g.INFINITY,Z6=g.If,J6=g.Switch,Q6=g.Loop,K6=g.NodeShaderStage,tF=g.NodeType,eF=g.NodeUpdateType,rF=g.NodeAccess,sF=g.PCFShadowFilter,iF=g.PCFSoftShadowFilter,nF=g.PI,aF=g.PI2,oF=g.Return,lF=g.Schlick_to_F0,uF=g.ScriptableNodeResources,hF=g.ShaderNode,cF=g.TBNViewMatrix,dF=g.VSMShadowFilter,pF=g.V_GGX_SmithCorrelated,mF=g.abs,fF=g.acesFilmicToneMapping,gF=g.acos,yF=g.add,xF=g.addNodeElement,bF=g.agxToneMapping,vF=g.all,wF=g.alphaT,MF=g.and,TF=g.anisotropy,NF=g.anisotropyB,SF=g.anisotropyT,_F=g.any,AF=g.append,zF=g.array,CF=g.arrayBuffer,EF=g.asin,VF=g.assign,RF=g.atan,LF=g.atan2,IF=g.atomicAdd,PF=g.atomicAnd,FF=g.atomicFunc,OF=g.atomicMax,BF=g.atomicMin,kF=g.atomicOr,DF=g.atomicStore,UF=g.atomicSub,$F=g.atomicXor,jF=g.atomicLoad,WF=g.attenuationColor,qF=g.attenuationDistance,HF=g.attribute,GF=g.attributeArray,XF=g.backgroundBlurriness,YF=g.backgroundIntensity,ZF=g.backgroundRotation,JF=g.batch,QF=g.billboarding,KF=g.bitAnd,tO=g.bitNot,eO=g.bitOr,rO=g.bitXor,sO=g.bitangentGeometry,iO=g.bitangentLocal,nO=g.bitangentView,aO=g.bitangentWorld,oO=g.bitcast,lO=g.blendBurn,uO=g.blendColor,hO=g.blendDodge,cO=g.blendOverlay,dO=g.blendScreen,pO=g.blur,mO=g.bool,fO=g.buffer,gO=g.bufferAttribute,yO=g.bumpMap,xO=g.burn,bO=g.bvec2,vO=g.bvec3,wO=g.bvec4,MO=g.bypass,TO=g.cache,NO=g.call,SO=g.cameraFar,_O=g.cameraIndex,AO=g.cameraNear,zO=g.cameraNormalMatrix,CO=g.cameraPosition,EO=g.cameraProjectionMatrix,VO=g.cameraProjectionMatrixInverse,RO=g.cameraViewMatrix,LO=g.cameraWorldMatrix,IO=g.cbrt,PO=g.cdl,FO=g.ceil,OO=g.checker,BO=g.cineonToneMapping,kO=g.clamp,DO=g.clearcoat,UO=g.clearcoatRoughness,$O=g.code,jO=g.color,WO=g.colorSpaceToWorking,qO=g.colorToDirection,HO=g.compute,GO=g.computeSkinning,XO=g.cond,YO=g.Const,ZO=g.context,JO=g.convert,QO=g.convertColorSpace,KO=g.convertToTexture,t9=g.cos,e9=g.cross,r9=g.cubeTexture,s9=g.dFdx,i9=g.dFdy,n9=g.dashSize,a9=g.debug,o9=g.decrement,l9=g.decrementBefore,u9=g.defaultBuildStages,h9=g.defaultShaderStages,c9=g.defined,d9=g.degrees,p9=g.deltaTime,m9=g.densityFog,f9=g.densityFogFactor,g9=g.depth,y9=g.depthPass,x9=g.difference,b9=g.diffuseColor,v9=g.directPointLight,w9=g.directionToColor,M9=g.dispersion,T9=g.distance,N9=g.div,S9=g.dodge,_9=g.dot,A9=g.drawIndex,z9=g.dynamicBufferAttribute,C9=g.element,E9=g.emissive,V9=g.equal,R9=g.equals,L9=g.equirectUV,I9=g.exp,P9=g.exp2,F9=g.expression,O9=g.faceDirection,B9=g.faceForward,k9=g.faceforward,D9=g.float,U9=g.floor,$9=g.fog,j9=g.fract,W9=g.frameGroup,q9=g.frameId,H9=g.frontFacing,G9=g.fwidth,X9=g.gain,Y9=g.gapSize,Z9=g.getConstNodeType,J9=g.getCurrentStack,Q9=g.getDirection,K9=g.getDistanceAttenuation,tB=g.getGeometryRoughness,eB=g.getNormalFromDepth,rB=g.getParallaxCorrectNormal,sB=g.getRoughness,iB=g.getScreenPosition,nB=g.getShIrradianceAt,aB=g.getTextureIndex,oB=g.getViewPosition,lB=g.getShadowMaterial,uB=g.getShadowRenderObjectFunction,hB=g.glsl,cB=g.glslFn,dB=g.grayscale,pB=g.greaterThan,mB=g.greaterThanEqual,fB=g.hash,gB=g.highpModelNormalViewMatrix,yB=g.highpModelViewMatrix,xB=g.hue,bB=g.increment,vB=g.incrementBefore,wB=g.instance,MB=g.instanceIndex,TB=g.instancedArray,NB=g.instancedBufferAttribute,SB=g.instancedDynamicBufferAttribute,_B=g.instancedMesh,AB=g.int,zB=g.inverseSqrt,CB=g.inversesqrt,EB=g.invocationLocalIndex,VB=g.invocationSubgroupIndex,RB=g.ior,LB=g.iridescence,IB=g.iridescenceIOR,PB=g.iridescenceThickness,FB=g.ivec2,OB=g.ivec3,BB=g.ivec4,kB=g.js,DB=g.label,UB=g.length,$B=g.lengthSq,jB=g.lessThan,WB=g.lessThanEqual,qB=g.lightPosition,HB=g.lightShadowMatrix,GB=g.lightTargetDirection,XB=g.lightTargetPosition,YB=g.lightViewPosition,ZB=g.lightingContext,JB=g.lights,QB=g.linearDepth,KB=g.linearToneMapping,tk=g.localId,ek=g.globalId,rk=g.log,sk=g.log2,ik=g.logarithmicDepthToViewZ,nk=g.loop,ak=g.luminance,ok=g.mediumpModelViewMatrix,lk=g.mat2,uk=g.mat3,hk=g.mat4,ck=g.matcapUV,dk=g.materialAO,pk=g.materialAlphaTest,mk=g.materialAnisotropy,fk=g.materialAnisotropyVector,gk=g.materialAttenuationColor,yk=g.materialAttenuationDistance,xk=g.materialClearcoat,bk=g.materialClearcoatNormal,vk=g.materialClearcoatRoughness,wk=g.materialColor,Mk=g.materialDispersion,Tk=g.materialEmissive,Nk=g.materialIOR,Sk=g.materialIridescence,_k=g.materialIridescenceIOR,Ak=g.materialIridescenceThickness,zk=g.materialLightMap,Ck=g.materialLineDashOffset,Ek=g.materialLineDashSize,Vk=g.materialLineGapSize,Rk=g.materialLineScale,Lk=g.materialLineWidth,Ik=g.materialMetalness,Pk=g.materialNormal,Fk=g.materialOpacity,Ok=g.materialPointSize,Bk=g.materialReference,kk=g.materialReflectivity,Dk=g.materialRefractionRatio,Uk=g.materialRotation,$k=g.materialRoughness,jk=g.materialSheen,Wk=g.materialSheenRoughness,qk=g.materialShininess,Hk=g.materialSpecular,Gk=g.materialSpecularColor,Xk=g.materialSpecularIntensity,Yk=g.materialSpecularStrength,Zk=g.materialThickness,Jk=g.materialTransmission,Qk=g.max,Kk=g.maxMipLevel,t7=g.metalness,e7=g.min,r7=g.mix,s7=g.mixElement,i7=g.mod,n7=g.modInt,a7=g.modelDirection,o7=g.modelNormalMatrix,l7=g.modelPosition,u7=g.modelRadius,h7=g.modelScale,c7=g.modelViewMatrix,d7=g.modelViewPosition,p7=g.modelViewProjection,m7=g.modelWorldMatrix,f7=g.modelWorldMatrixInverse,g7=g.morphReference,y7=g.mrt,x7=g.mul,b7=g.mx_aastep,v7=g.mx_cell_noise_float,w7=g.mx_contrast,M7=g.mx_fractal_noise_float,T7=g.mx_fractal_noise_vec2,N7=g.mx_fractal_noise_vec3,S7=g.mx_fractal_noise_vec4,_7=g.mx_hsvtorgb,A7=g.mx_noise_float,z7=g.mx_noise_vec3,C7=g.mx_noise_vec4,E7=g.mx_ramplr,V7=g.mx_ramptb,R7=g.mx_rgbtohsv,L7=g.mx_safepower,I7=g.mx_splitlr,P7=g.mx_splittb,F7=g.mx_srgb_texture_to_lin_rec709,O7=g.mx_transform_uv,B7=g.mx_worley_noise_float,k7=g.mx_worley_noise_vec2,D7=g.mx_worley_noise_vec3,U7=g.namespace,$7=g.negate,j7=g.neutralToneMapping,W7=g.nodeArray,q7=g.nodeImmutable,H7=g.nodeObject,G7=g.nodeObjects,X7=g.nodeProxy,Y7=g.normalFlat,Z7=g.normalGeometry,J7=g.normalLocal,Q7=g.normalMap,K7=g.normalView,t8=g.normalWorld,e8=g.normalize,r8=g.not,s8=g.notEqual,i8=g.numWorkgroups,n8=g.objectDirection,a8=g.objectGroup,o8=g.objectPosition,l8=g.objectRadius,u8=g.objectScale,h8=g.objectViewPosition,c8=g.objectWorldMatrix,d8=g.oneMinus,p8=g.or,m8=g.orthographicDepthToViewZ,f8=g.oscSawtooth,g8=g.oscSine,y8=g.oscSquare,x8=g.oscTriangle,b8=g.output,v8=g.outputStruct,w8=g.overlay,M8=g.overloadingFn,T8=g.parabola,N8=g.parallaxDirection,S8=g.parallaxUV,_8=g.parameter,A8=g.pass,z8=g.passTexture,C8=g.pcurve,E8=g.perspectiveDepthToViewZ,V8=g.pmremTexture,R8=g.pointUV,L8=g.pointWidth,I8=g.positionGeometry,P8=g.positionLocal,F8=g.positionPrevious,O8=g.positionView,B8=g.positionViewDirection,k8=g.positionWorld,D8=g.positionWorldDirection,U8=g.posterize,$8=g.pow,j8=g.pow2,W8=g.pow3,q8=g.pow4,H8=g.premult,G8=g.property,X8=g.radians,Y8=g.rand,Z8=g.range,J8=g.rangeFog,Q8=g.rangeFogFactor,K8=g.reciprocal,tD=g.lightProjectionUV,eD=g.reference,rD=g.referenceBuffer,sD=g.reflect,iD=g.reflectVector,nD=g.reflectView,aD=g.reflector,oD=g.refract,lD=g.refractVector,uD=g.refractView,hD=g.reinhardToneMapping,cD=g.remainder,dD=g.remap,pD=g.remapClamp,mD=g.renderGroup,fD=g.renderOutput,gD=g.rendererReference,yD=g.rotate,xD=g.rotateUV,bD=g.roughness,vD=g.round,wD=g.rtt,MD=g.sRGBTransferEOTF,TD=g.sRGBTransferOETF,ND=g.sampler,SD=g.samplerComparison,_D=g.saturate,AD=g.saturation,zD=g.screen,CD=g.screenCoordinate,ED=g.screenSize,VD=g.screenUV,RD=g.scriptable,LD=g.scriptableValue,ID=g.select,PD=g.setCurrentStack,FD=g.shaderStages,OD=g.shadow,BD=g.pointShadow,kD=g.shadowPositionWorld,DD=g.sharedUniformGroup,UD=g.shapeCircle,$D=g.sheen,jD=g.sheenRoughness,WD=g.shiftLeft,qD=g.shiftRight,HD=g.shininess,GD=g.sign,XD=g.sin,YD=g.sinc,ZD=g.skinning,JD=g.smoothstep,QD=g.smoothstepElement,KD=g.specularColor,tU=g.specularF90,eU=g.spherizeUV,rU=g.split,sU=g.spritesheetUV,iU=g.sqrt,nU=g.stack,aU=g.step,oU=g.storage,lU=g.storageBarrier,uU=g.storageObject,hU=g.storageTexture,cU=g.string,dU=g.struct,pU=g.sub,mU=g.subgroupIndex,fU=g.subgroupSize,gU=g.tan,yU=g.tangentGeometry,xU=g.tangentLocal,bU=g.tangentView,vU=g.tangentWorld,wU=g.temp,MU=g.texture,TU=g.texture3D,NU=g.textureBarrier,SU=g.textureBicubic,_U=g.textureCubeUV,AU=g.textureLoad,zU=g.textureSize,CU=g.textureStore,EU=g.thickness,VU=g.time,RU=g.timerDelta,LU=g.timerGlobal,IU=g.timerLocal,PU=g.toneMapping,FU=g.toneMappingExposure,OU=g.toonOutlinePass,BU=g.transformDirection,kU=g.transformNormal,DU=g.transformNormalToView,UU=g.transformedBentNormalView,$U=g.transformedBitangentView,jU=g.transformedBitangentWorld,WU=g.transformedClearcoatNormalView,qU=g.transformedNormalView,HU=g.transformedNormalWorld,GU=g.transformedTangentView,XU=g.transformedTangentWorld,YU=g.transmission,ZU=g.transpose,JU=g.triNoise3D,QU=g.triplanarTexture,KU=g.triplanarTextures,t$=g.trunc,e$=g.tslFn,r$=g.uint,s$=g.uniform,i$=g.uniformCubeTexture,n$=g.uniformArray,a$=g.uniformGroup,o$=g.uniformTexture,l$=g.uniforms,u$=g.unpremult,h$=g.userData,c$=g.uv,d$=g.uvec2,p$=g.uvec3,m$=g.uvec4,f$=g.Var,g$=g.varying,y$=g.varyingProperty,x$=g.vec2,b$=g.vec3,v$=g.vec4,w$=g.vectorComponents,M$=g.velocity,T$=g.vertexColor,N$=g.vertexIndex,S$=g.vibrance,_$=g.viewZToLogarithmicDepth,A$=g.viewZToOrthographicDepth,z$=g.viewZToPerspectiveDepth,C$=g.viewport,E$=g.viewportBottomLeft,V$=g.viewportCoordinate,R$=g.viewportDepthTexture,L$=g.viewportLinearDepth,I$=g.viewportMipTexture,P$=g.viewportResolution,F$=g.viewportSafeUV,O$=g.viewportSharedTexture,B$=g.viewportSize,k$=g.viewportTexture,D$=g.viewportTopLeft,U$=g.viewportUV,$$=g.wgsl,j$=g.wgslFn,W$=g.workgroupArray,q$=g.workgroupBarrier,H$=g.workgroupId,G$=g.workingToColorSpace,X$=g.xor;var S1=function(r){function t(n){"@babel/helpers - typeof";return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t(n)}function e(n,a){if(t(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var l=o.call(n,a);if(t(l)!="object")return l;throw TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}function s(n){var a=e(n,"string");return t(a)=="symbol"?a:a+""}function i(n,a,o){return(a=s(a))in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o,n}return r.defineProperty=i,r}({}),wn,Mc;function he(r,t){let e=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map(a=>[a]));let s=t[0].length,i=t[0].map((a,o)=>t.map(l=>l[o])),n=r.map(a=>i.map(o=>{let l=0;if(!Array.isArray(a)){for(let h of o)l+=a*h;return l}for(let h=0;h<a.length;h++)l+=a[h]*(o[h]||0);return l}));return e===1&&(n=n[0]),s===1?n.map(a=>a[0]):n}function wh(r){return qn(r)==="string"}function qn(r){return(Object.prototype.toString.call(r).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function kd(r,{precision:t,unit:e}){return Qn(r)?"none":yN(r,t)+(e??"")}function Qn(r){return Number.isNaN(r)||r instanceof Number&&r?.none}function ke(r){return Qn(r)?0:r}function yN(r,t){if(r===0)return 0;let e=~~r,s=0;e&&t&&(s=~~Math.log10(Math.abs(e))+1);let i=10**(t-s);return Math.floor(r*i+.5)/i}const Y$={deg:1,grad:.9,rad:180/Math.PI,turn:360};function xN(r){if(!r)return;r=r.trim();let t=/^([a-z]+)\((.+?)\)$/i,e=/^-?[\d.]+$/,s=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,n=r.match(t);if(n){let a=[];return n[2].replace(i,(o,l)=>{let h=l.match(s),u=l;if(h){let c=h[0],d=u.slice(0,-c.length);c==="%"?(u=new Number(d/100),u.type="<percentage>"):(u=new Number(d*Y$[c]),u.type="<angle>",u.unit=c)}else e.test(u)?(u=new Number(u),u.type="<number>"):u==="none"&&(u=new Number(NaN),u.none=!0);o.startsWith("/")&&(u=u instanceof Number?u:new Number(u),u.alpha=!0),typeof u=="object"&&u instanceof Number&&(u.raw=l),a.push(u)}),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:a}}}function bN(r){return r[r.length-1]}function Xu(r,t,e){return isNaN(r)?t:isNaN(t)?r:r+(t-r)*e}function vN(r,t,e){return(e-r)/(t-r)}function qy(r,t,e){return Xu(t[0],t[1],vN(r[0],r[1],e))}function wN(r){return r.map(t=>t.split("|").map(e=>{e=e.trim();let s=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(s){let i=new String(s[1]);return i.range=[+s[2],+s[3]],i}return e}))}function MN(r,t,e){return Math.max(Math.min(e,t),r)}function zp(r,t){return Math.sign(r)===Math.sign(t)?r:-r}function ni(r,t){return zp(Math.abs(r)**t,r)}function Hy(r,t){return t===0?0:r/t}function TN(r,t,e=0,s=r.length){for(;e<s;){let i=e+s>>1;r[i]<t?e=i+1:s=i}return e}var Z$=Object.freeze({__proto__:null,bisectLeft:TN,clamp:MN,copySign:zp,interpolate:Xu,interpolateInv:vN,isNone:Qn,isString:wh,last:bN,mapRange:qy,multiplyMatrices:he,parseCoordGrammar:wN,parseFunction:xN,serializeNumber:kd,skipNone:ke,spow:ni,toPrecision:yN,type:qn,zdiv:Hy}),J$=class{add(t,e,s){if(typeof arguments[0]!="string"){for(var t in arguments[0])this.add(t,arguments[0][t],arguments[1]);return}(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],e&&this[i][s?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(s){s.call(e&&e.context?e.context:e,e)})}};const Kn=new J$;var es={gamut_mapping:"css",precision:5,deltaE:"76",verbose:((wn=globalThis)==null||(wn=wn.process)==null||(wn=wn.env)==null||(wn=wn.NODE_ENV)==null?void 0:wn.toLowerCase())!=="test",warn:function(r){var t,e;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(e=t.warn)==null||e.call(t,r))}};const Ar={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function ng(r){return Array.isArray(r)?r:Ar[r]}function Dd(r,t,e,s={}){if(r=ng(r),t=ng(t),!r||!t)throw TypeError(`Missing white point to convert ${r?"":"from"}${!r&&!t?"/":""}${t?"":"to"}`);if(r===t)return e;let i={W1:r,W2:t,XYZ:e,options:s};if(Kn.run("chromatic-adaptation-start",i),i.M||(i.W1===Ar.D65&&i.W2===Ar.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===Ar.D50&&i.W2===Ar.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Kn.run("chromatic-adaptation-end",i),i.M)return he(i.M,i.XYZ);throw TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const Q$=new Set(["<number>","<percentage>","<angle>"]);function _1(r,t,e,s){return Object.entries(r.coords).map(([n,a],o)=>{let l=t.coordGrammar[o],h=s[o],u=h?.type,c;if(c=h.none?l.find(m=>Q$.has(m)):l.find(m=>m==u),!c){let m=a.name||n;throw TypeError(`${u??h.raw} not allowed for ${m} in ${e}()`)}let d=c.range;u==="<percentage>"&&(d||(d=[0,1]));let p=a.range||a.refRange;return d&&p&&(s[o]=qy(d,p,s[o])),c})}function NN(r,{meta:t}={}){let e={str:String(r)?.trim()};if(Kn.run("parse-start",e),e.color)return e.color;if(e.parsed=xN(e.str),e.parsed){let i=e.parsed.name;if(i==="color"){let n=e.parsed.args.shift(),a=n.startsWith("--")?n.substring(2):`--${n}`,o=[n,a],l=e.parsed.rawArgs.indexOf("/")>0?e.parsed.args.pop():1;for(let c of lt.all){let d=c.getFormat("color");if(d&&(o.includes(d.id)||d.ids?.filter(p=>o.includes(p)).length)){let p=Object.keys(c.coords).map((f,x)=>e.parsed.args[x]||0),m;return d.coordGrammar&&(m=_1(c,d,"color",p)),t&&Object.assign(t,{formatId:"color",types:m}),d.id.startsWith("--")&&!n.startsWith("--")&&es.warn(`${c.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${d.id}) instead of color(${n}).`),n.startsWith("--")&&!d.id.startsWith("--")&&es.warn(`${c.name} is a standard space and supported in the CSS spec. Use color(${d.id}) instead of prefixed color(${n}).`),{spaceId:c.id,coords:p,alpha:l}}}let h="",u=n in lt.registry?n:a;if(u in lt.registry){var s;let c=(s=lt.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;c&&(h=`Did you mean color(${c})?`)}throw TypeError(`Cannot parse color(${n}). `+(h||"Missing a plugin?"))}else for(let n of lt.all){let a=n.getFormat(i);if(a&&a.type==="function"){let o=1;(a.lastAlpha||bN(e.parsed.args).alpha)&&(o=e.parsed.args.pop());let l=e.parsed.args,h;return a.coordGrammar&&(h=_1(n,a,i,l)),t&&Object.assign(t,{formatId:a.name,types:h}),{spaceId:n.id,coords:l,alpha:o}}}}else for(let i of lt.all)for(let n in i.formats){let a=i.formats[n];if(a.type!=="custom"||a.test&&!a.test(e.str))continue;let o=a.parse(e.str);if(o)return o.alpha??(o.alpha=1),t&&(t.formatId=n),o}throw TypeError(`Could not parse ${r} as a color. Missing a plugin?`)}function Mt(r){if(Array.isArray(r))return r.map(Mt);if(!r)throw TypeError("Empty color reference");wh(r)&&(r=NN(r));let t=r.space||r.spaceId;return t instanceof lt||(r.space=lt.get(t)),r.alpha===void 0&&(r.alpha=1),r}const K$=75e-6;var lt=(Mc=class Fs{constructor(t){this.id=t.id,this.name=t.name,this.base=t.base?Fs.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let e=t.coords??this.base.coords;for(let i in e)"name"in e[i]||(e[i].name=i);this.coords=e;let s=t.white??this.base.white??"D65";for(let i in this.white=ng(s),this.formats=t.formats??{},this.formats){let n=this.formats[i];n.type||(n.type="function"),n.name||(n.name=i)}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace==="self"?this:Fs.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(i,n)=>!0),this.referred=t.referred,Object.defineProperty(this,"path",{value:tj(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Kn.run("colorspace-init-end",this)}inGamut(t,{epsilon:e=K$}={}){if(!this.equals(this.gamutSpace))return t=this.to(this.gamutSpace,t),this.gamutSpace.inGamut(t,{epsilon:e});let s=Object.values(this.coords);return t.every((i,n)=>{let a=s[n];if(a.type!=="angle"&&a.range){if(Number.isNaN(i))return!0;let[o,l]=a.range;return(o===void 0||i>=o-e)&&(l===void 0||i<=l+e)}return!0})}get isUnbounded(){return Object.values(this.coords).every(t=>!("range"in t))}get cssId(){var t;return((t=this.formats)==null||(t=t.color)==null?void 0:t.id)||this.id}get isPolar(){for(let t in this.coords)if(this.coords[t].type==="angle")return!0;return!1}getFormat(t){if(typeof t=="object")return t=A1(t,this),t;let e;return e=t==="default"?Object.values(this.formats)[0]:this.formats[t],e?(e=A1(e,this),e):null}equals(t){return t?this===t||this.id===t||this.id===t.id:!1}to(t,e){if(arguments.length===1){let o=Mt(t);[t,e]=[o.space,o.coords]}if(t=Fs.get(t),this.equals(t))return e;e=e.map(o=>Number.isNaN(o)?0:o);let s=this.path,i=t.path,n,a;for(let o=0;o<s.length&&s[o].equals(i[o]);o++)n=s[o],a=o;if(!n)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let o=s.length-1;o>a;o--)e=s[o].toBase(e);for(let o=a+1;o<i.length;o++)e=i[o].fromBase(e);return e}from(t,e){if(arguments.length===1){let s=Mt(t);[t,e]=[s.space,s.coords]}return t=Fs.get(t),t.to(this,e)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let t=[];for(let e in this.coords){let s=this.coords[e],i=s.range||s.refRange;t.push(i?.min??0)}return t}static get all(){return[...new Set(Object.values(Fs.registry))]}static register(t,e){if(arguments.length===1&&(e=arguments[0],t=e.id),e=this.get(e),this.registry[t]&&this.registry[t]!==e)throw Error(`Duplicate color space registration: '${t}'`);if(this.registry[t]=e,arguments.length===1&&e.aliases)for(let s of e.aliases)this.register(s,e);return e}static get(t,...e){if(!t||t instanceof Fs)return t;if(qn(t)==="string"){let i=Fs.registry[t.toLowerCase()];if(!i)throw TypeError(`No color space found with id = "${t}"`);return i}if(e.length)return Fs.get(...e);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,e){let s=qn(t),i,n;if(s==="string"?t.includes(".")?[i,n]=t.split("."):[i,n]=[,t]:Array.isArray(t)?[i,n]=t:(i=t.space,n=t.coordId),i=Fs.get(i),i||(i=e),!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(s=qn(n),s==="number"||s==="string"&&n>=0){let l=Object.entries(i.coords)[n];if(l)return{space:i,id:l[0],index:n,...l[1]}}i=Fs.get(i);let a=n.toLowerCase(),o=0;for(let l in i.coords){let h=i.coords[l];if(l.toLowerCase()===a||h.name?.toLowerCase()===a)return{space:i,id:l,index:o,...h};o++}throw TypeError(`No "${n}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(", ")}`)}},S1.defineProperty(Mc,"registry",{}),S1.defineProperty(Mc,"DEFAULT_FORMAT",{type:"functions",name:"color"}),Mc);function tj(r){let t=[r];for(let e=r;e=e.base;)t.push(e);return t}function A1(r,{coords:t}={}){if(r.coords&&!r.coordGrammar){r.type||(r.type="function"),r.name||(r.name="color"),r.coordGrammar=wN(r.coords);let e=Object.entries(t).map(([s,i],n)=>{let a=r.coordGrammar[n][0],o=i.range||i.refRange,l=a.range,h="";return a=="<percentage>"?(l=[0,100],h="%"):a=="<angle>"&&(h="deg"),{fromRange:o,toRange:l,suffix:h}});r.serializeCoords=(s,i)=>s.map((n,a)=>{let{fromRange:o,toRange:l,suffix:h}=e[a];return o&&l&&(n=qy(o,l,n)),n=kd(n,{precision:i,unit:h}),n})}return r}var ur=new lt({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"]}),Or=class extends lt{constructor(t){t.coords||(t.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),t.base||(t.base=ur),t.toXYZ_M&&t.fromXYZ_M&&(t.toBase??(t.toBase=e=>{let s=he(t.toXYZ_M,e);return this.white!==this.base.white&&(s=Dd(this.white,this.base.white,s)),s}),t.fromBase??(t.fromBase=e=>(e=Dd(this.base.white,this.white,e),he(t.fromXYZ_M,e)))),t.referred??(t.referred="display"),super(t)}};function Mh(r,t){return r=Mt(r),!t||r.space.equals(t)?r.coords.slice():(t=lt.get(t),t.from(r))}function Jr(r,t){r=Mt(r);let{space:e,index:s}=lt.resolveCoord(t,r.space);return Mh(r,e)[s]}function Gy(r,t,e){return r=Mt(r),t=lt.get(t),r.coords=t.to(r.space,e),r}Gy.returns="color";function an(r,t,e){if(r=Mt(r),arguments.length===2&&qn(arguments[1])==="object"){let s=arguments[1];for(let i in s)an(r,i,s[i])}else{typeof e=="function"&&(e=e(Jr(r,t)));let{space:s,index:i}=lt.resolveCoord(t,r.space),n=Mh(r,s);n[i]=e,Gy(r,s,n)}return r}an.returns="color";var Xy=new lt({id:"xyz-d50",name:"XYZ D50",white:"D50",base:ur,fromBase:r=>Dd(ur.white,"D50",r),toBase:r=>Dd("D50",ur.white,r)});const ej=216/24389,z1=24/116,Tc=24389/27;let Dm=Ar.D50;var Qr=new lt({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Dm,base:Xy,fromBase(r){let t=r.map((s,i)=>s/Dm[i]),e=t.map(s=>s>ej?Math.cbrt(s):(Tc*s+16)/116);return[116*e[1]-16,500*(e[0]-e[1]),200*(e[1]-e[2])]},toBase(r){let t=[];return t[1]=(r[0]+16)/116,t[0]=r[1]/500+t[1],t[2]=t[1]-r[2]/200,[t[0]>z1?t[0]**3:(116*t[0]-16)/Tc,r[0]>8?((r[0]+16)/116)**3:r[0]/Tc,t[2]>z1?t[2]**3:(116*t[2]-16)/Tc].map((s,i)=>s*Dm[i])},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function _i(r){return(r%360+360)%360}function rj(r,t){if(r==="raw")return t;let[e,s]=t.map(_i),i=s-e;return r==="increasing"?i<0&&(s+=360):r==="decreasing"?i>0&&(e+=360):r==="longer"?-180<i&&i<180&&(i>0?e+=360:s+=360):r==="shorter"&&(i>180?e+=360:i<-180&&(s+=360)),[e,s]}var Yu=new lt({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:Qr,fromBase(r){let[t,e,s]=r,i,n=.02;return i=Math.abs(e)<n&&Math.abs(s)<n?NaN:Math.atan2(s,e)*180/Math.PI,[t,Math.sqrt(e**2+s**2),_i(i)]},toBase(r){let[t,e,s]=r;return e<0&&(e=0),isNaN(s)&&(s=0),[t,e*Math.cos(s*Math.PI/180),e*Math.sin(s*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const C1=25**7,Ud=Math.PI,E1=180/Ud,To=Ud/180;function V1(r){let t=r*r;return t*t*t*r}function SN(r,t,{kL:e=1,kC:s=1,kH:i=1}={}){[r,t]=Mt([r,t]);let[n,a,o]=Qr.from(r),l=Yu.from(Qr,[n,a,o])[1],[h,u,c]=Qr.from(t),d=Yu.from(Qr,[h,u,c])[1];l<0&&(l=0),d<0&&(d=0);let p=(l+d)/2,m=V1(p),f=.5*(1-Math.sqrt(m/(m+C1))),x=(1+f)*a,b=(1+f)*u,w=Math.sqrt(x**2+o**2),S=Math.sqrt(b**2+c**2),_=x===0&&o===0?0:Math.atan2(o,x),V=b===0&&c===0?0:Math.atan2(c,b);_<0&&(_+=2*Ud),V<0&&(V+=2*Ud),_*=E1,V*=E1;let z=h-n,A=S-w,I=V-_,et=_+V,nt=Math.abs(I),it;w*S===0?it=0:nt<=180?it=I:I>180?it=I-360:I<-180?it=I+360:es.warn("the unthinkable has happened");let vt=2*Math.sqrt(S*w)*Math.sin(it*To/2),mt=(n+h)/2,Rt=(w+S)/2,Vt=V1(Rt),Yt;Yt=w*S===0?et:nt<=180?et/2:et<360?(et+360)/2:(et-360)/2;let se=(mt-50)**2,te=1+.015*se/Math.sqrt(20+se),ft=1+.045*Rt,bt=1;bt-=.17*Math.cos((Yt-30)*To),bt+=.24*Math.cos(2*Yt*To),bt+=.32*Math.cos((3*Yt+6)*To),bt-=.2*Math.cos((4*Yt-63)*To);let Et=1+.015*Rt*bt,Tr=30*Math.exp(-1*((Yt-275)/25)**2),zs=2*Math.sqrt(Vt/(Vt+C1)),Gl=-1*Math.sin(2*Tr*To)*zs,ei=(z/(e*te))**2;return ei+=(A/(s*ft))**2,ei+=(vt/(i*Et))**2,ei+=Gl*(A/(s*ft))*(vt/(i*Et)),Math.sqrt(ei)}const sj=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],ij=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],nj=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],aj=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var El=new lt({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:ur,fromBase(r){let t=he(sj,r),e=t.map(s=>Math.cbrt(s));return he(nj,e)},toBase(r){let t=he(aj,r),e=t.map(s=>s**3);return he(ij,e)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function ag(r,t){[r,t]=Mt([r,t]);let[e,s,i]=El.from(r),[n,a,o]=El.from(t),l=e-n,h=s-a,u=i-o;return Math.sqrt(l**2+h**2+u**2)}const oj=75e-6;function Ia(r,t,{epsilon:e=oj}={}){r=Mt(r),t||(t=r.space),t=lt.get(t);let s=r.coords;return t!==r.space&&(s=t.from(r)),t.inGamut(s,{epsilon:e})}function Vl(r){return{space:r.space,coords:r.coords.slice(),alpha:r.alpha}}function _N(r,t,e="lab"){e=lt.get(e);let s=e.from(r),i=e.from(t);return Math.sqrt(s.reduce((n,a,o)=>{let l=i[o];return isNaN(a)||isNaN(l)?n:n+(l-a)**2},0))}function lj(r,t){return _N(r,t,"lab")}const uj=Math.PI,R1=uj/180;function hj(r,t,{l:e=2,c:s=1}={}){[r,t]=Mt([r,t]);let[i,n,a]=Qr.from(r),[,o,l]=Yu.from(Qr,[i,n,a]),[h,u,c]=Qr.from(t),d=Yu.from(Qr,[h,u,c])[1];o<0&&(o=0),d<0&&(d=0);let p=i-h,m=o-d,f=n-u,x=a-c,b=f**2+x**2-m**2,w=.511;i>=16&&(w=.040975*i/(1+.01765*i));let S=.0638*o/(1+.0131*o)+.638,_;Number.isNaN(l)&&(l=0),_=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*R1)):.36+Math.abs(.4*Math.cos((l+35)*R1));let V=o**4,z=Math.sqrt(V/(V+1900)),A=S*(z*_+1-z),I=(p/(e*w))**2;return I+=(m/(s*S))**2,I+=b/A**2,Math.sqrt(I)}const L1=203;var Yy=new lt({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:ur,fromBase(r){return r.map(t=>Math.max(t*L1,0))},toBase(r){return r.map(t=>Math.max(t/L1,0))}});const Nc=1.15,Sc=.66,I1=2610/2**14,cj=2**14/2610,P1=3424/2**12,F1=2413/2**7,O1=2392/2**7,dj=1.7*2523/2**5,B1=2**5/(1.7*2523),_c=-.56,Um=16295499532821565e-27,pj=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],mj=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],fj=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],gj=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var AN=new lt({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:Yy,fromBase(r){let[t,e,s]=r,i=Nc*t-(Nc-1)*s,n=Sc*e-(Sc-1)*t,a=he(pj,[i,n,s]),o=a.map(function(d){let p=P1+F1*(d/1e4)**I1,m=1+O1*(d/1e4)**I1;return(p/m)**dj}),[l,h,u]=he(fj,o);return[(1+_c)*l/(1+_c*l)-Um,h,u]},toBase(r){let[t,e,s]=r,i=(t+Um)/(1+_c-_c*(t+Um)),n=he(gj,[i,e,s]),a=n.map(function(d){let p=P1-d**B1,m=O1*d**B1-F1;return 1e4*(p/m)**cj}),[o,l,h]=he(mj,a),u=(o+(Nc-1)*h)/Nc,c=(l+(Sc-1)*u)/Sc;return[u,c,h]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),og=new lt({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:AN,fromBase(r){let[t,e,s]=r,i,n=2e-4;return i=Math.abs(e)<n&&Math.abs(s)<n?NaN:Math.atan2(s,e)*180/Math.PI,[t,Math.sqrt(e**2+s**2),_i(i)]},toBase(r){return[r[0],r[1]*Math.cos(r[2]*Math.PI/180),r[1]*Math.sin(r[2]*Math.PI/180)]}});function yj(r,t){[r,t]=Mt([r,t]);let[e,s,i]=og.from(r),[n,a,o]=og.from(t),l=e-n,h=s-a;Number.isNaN(i)&&Number.isNaN(o)?(i=0,o=0):Number.isNaN(i)?i=o:Number.isNaN(o)&&(o=i);let u=i-o,c=2*Math.sqrt(s*a)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(l**2+h**2+c**2)}const zN=3424/4096,CN=2413/128,EN=2392/128,k1=2610/16384,xj=2523/32,bj=16384/2610,D1=32/2523,vj=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],wj=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],Mj=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],Tj=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var lg=new lt({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:Yy,fromBase(r){let t=he(vj,r);return Nj(t)},toBase(r){let t=Sj(r);return he(Tj,t)}});function Nj(r){let t=r.map(function(e){let s=zN+CN*(e/1e4)**k1,i=1+EN*(e/1e4)**k1;return(s/i)**xj});return he(wj,t)}function Sj(r){return he(Mj,r).map(function(s){let i=Math.max(s**D1-zN,0),n=CN-EN*s**D1;return 1e4*(i/n)**bj})}function _j(r,t){[r,t]=Mt([r,t]);let[e,s,i]=lg.from(r),[n,a,o]=lg.from(t);return 720*Math.sqrt((e-n)**2+.25*(s-a)**2+(i-o)**2)}const Aj=Ar.D65,VN=.42,U1=1/VN,$m=2*Math.PI,RN=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],zj=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Cj=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Ej={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},_a={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Vj=180/Math.PI,$1=Math.PI/180;function LN(r,t){return r.map(s=>{let i=ni(t*Math.abs(s)*.01,VN);return 400*zp(i,s)/(i+27.13)})}function Rj(r,t){let e=100/t*27.13**U1;return r.map(s=>{let i=Math.abs(s);return zp(e*ni(i/(400-i),U1),s)})}function Lj(r){let t=_i(r);t<=_a.h[0]&&(t+=360);let e=TN(_a.h,t)-1,[s,i]=_a.h.slice(e,e+2),[n,a]=_a.e.slice(e,e+2),o=_a.H[e],l=(t-s)/n;return o+100*l/(l+(i-t)/a)}function Ij(r){let t=(r%400+400)%400,e=Math.floor(.01*t);t%=100;let[s,i]=_a.h.slice(e,e+2),[n,a]=_a.e.slice(e,e+2);return _i((t*(a*s-n*i)-100*s*a)/(t*(a-n)-100*a))}function IN(r,t,e,s,i){let n={};n.discounting=i,n.refWhite=r,n.surround=s;let a=r.map(f=>f*100);n.la=t,n.yb=e;let o=a[1],l=he(RN,a);s=Ej[n.surround];let h=s[0];n.c=s[1],n.nc=s[2];let u=1/(5*n.la+1),c=u**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;let d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=l.map(f=>Xu(1,o/f,d)),n.dRgbInv=n.dRgb.map(f=>1/f);let p=l.map((f,x)=>f*n.dRgb[x]),m=LN(p,n.fl);return n.aW=n.nbb*(2*m[0]+m[1]+.05*m[2]),n}const j1=IN(Aj,64/Math.PI*.2,20,"average",!1);function ug(r,t){if(!(r.J!==void 0^r.Q!==void 0))throw Error("Conversion requires one and only one: 'J' or 'Q'");if(!(r.C!==void 0^r.M!==void 0^r.s!==void 0))throw Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(r.h!==void 0^r.H!==void 0))throw Error("Conversion requires one and only one: 'h' or 'H'");if(r.J===0||r.Q===0)return[0,0,0];let e=0;e=r.h===void 0?Ij(r.H)*$1:_i(r.h)*$1;let s=Math.cos(e),i=Math.sin(e),n=0;r.J===void 0?r.Q!==void 0&&(n=.25*t.c*r.Q/((t.aW+4)*t.flRoot)):n=ni(r.J,1/2)*.1;let a=0;r.C===void 0?r.M===void 0?r.s!==void 0&&(a=4e-4*r.s**2*(t.aW+4)/t.c):a=r.M/t.flRoot/n:a=r.C/n;let o=ni(a*(1.64-.29**t.n)**-.73,10/9),l=.25*(Math.cos(e+2)+3.8),h=t.aW*ni(n,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*l,c=h/t.nbb,d=23*(c+.305)*Hy(o,23*u+o*(11*s+108*i)),p=d*s,m=d*i,f=Rj(he(Cj,[c,p,m]).map(x=>x*1/1403),t.fl);return he(zj,f.map((x,b)=>x*t.dRgbInv[b])).map(x=>x/100)}function PN(r,t){let e=r.map(S=>S*100),s=LN(he(RN,e).map((S,_)=>S*t.dRgb[_]),t.fl),i=s[0]+(-12*s[1]+s[2])/11,n=(s[0]+s[1]-2*s[2])/9,a=(Math.atan2(n,i)%$m+$m)%$m,o=.25*(Math.cos(a+2)+3.8),l=5e4/13*t.nc*t.ncb*Hy(o*Math.sqrt(i**2+n**2),s[0]+s[1]+1.05*s[2]+.305),h=ni(l,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*s[0]+s[1]+.05*s[2]),c=ni(u/t.aW,.5*t.c*t.z),d=100*ni(c,2),p=4/t.c*c*(t.aW+4)*t.flRoot,m=h*c,f=m*t.flRoot,x=_i(a*Vj),b=Lj(x),w=50*ni(t.c*h/(t.aW+4),1/2);return{J:d,C:m,h:x,s:w,Q:p,M:f,H:b}}var Pj=new lt({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:ur,fromBase(r){let t=PN(r,j1);return[t.J,t.M,t.h]},toBase(r){return ug({J:r[0],M:r[1],h:r[2]},j1)}});const Fj=Ar.D65,Oj=216/24389,FN=24389/27;function Bj(r){return 116*(r>Oj?Math.cbrt(r):(FN*r+16)/116)-16}function hg(r){return r>8?((r+16)/116)**3:r/FN}function kj(r,t){let[e,s,i]=r,n=[],a=0;if(i===0)return[0,0,0];let o=hg(i);a=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let l=2e-12,h=15,u=0,c=1/0;for(;u<=h;){n=ug({J:a,C:s,h:e},t);let d=Math.abs(n[1]-o);if(d<c){if(d<=l)return n;c=d}a-=(n[1]-o)*a/(2*n[1]),u+=1}return ug({J:a,C:s,h:e},t)}function Dj(r,t){let e=Bj(r[1]);if(e===0)return[0,0,0];let s=PN(r,Zy);return[_i(s.h),s.C,e]}const Zy=IN(Fj,200/Math.PI*hg(50),hg(50)*100,"average",!1);var Zu=new lt({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:ur,fromBase(r){return Dj(r)},toBase(r){return kj(r,Zy)},formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Uj=Math.PI/180,W1=[1,.007,.0228];function q1(r){r[1]<0&&(r=Zu.fromBase(Zu.toBase(r)));let t=Math.log(Math.max(1+W1[2]*r[1]*Zy.flRoot,1))/W1[2],e=r[0]*Uj,s=t*Math.cos(e),i=t*Math.sin(e);return[r[2],s,i]}function $j(r,t){[r,t]=Mt([r,t]);let[e,s,i]=q1(Zu.from(r)),[n,a,o]=q1(Zu.from(t));return Math.sqrt((e-n)**2+(s-a)**2+(i-o)**2)}var Rl={deltaE76:lj,deltaECMC:hj,deltaE2000:SN,deltaEJz:yj,deltaEITP:_j,deltaEOK:ag,deltaEHCT:$j};function jj(r){let t=r?Math.floor(Math.log10(Math.abs(r))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const H1={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 ta(r,{method:t=es.gamut_mapping,space:e=void 0,deltaEMethod:s="",jnd:i=2,blackWhiteClamp:n={}}={}){if(r=Mt(r),wh(arguments[1])?e=arguments[1]:e||(e=r.space),e=lt.get(e),Ia(r,e,{epsilon:0}))return r;let a;if(t==="css")a=Wj(r,{space:e});else{if(t!=="clip"&&!Ia(r,e)){Object.prototype.hasOwnProperty.call(H1,t)&&({method:t,jnd:i,deltaEMethod:s,blackWhiteClamp:n}=H1[t]);let o=SN;if(s!==""){for(let h in Rl)if("deltae"+s.toLowerCase()===h.toLowerCase()){o=Rl[h];break}}let l=ta(ue(r,e),{method:"clip",space:e});if(o(r,l)>i){if(Object.keys(n).length===3){let w=lt.resolveCoord(n.channel),S=Jr(ue(r,w.space),w.id);if(Qn(S)&&(S=0),S>=n.max)return ue({space:"xyz-d65",coords:Ar.D65},r.space);if(S<=n.min)return ue({space:"xyz-d65",coords:[0,0,0]},r.space)}let h=lt.resolveCoord(t),u=h.space,c=h.id,d=ue(r,u);d.coords.forEach((w,S)=>{Qn(w)&&(d.coords[S]=0)});let p=h.range||h.refRange,m=p[0],f=jj(i),x=m,b=Jr(d,c);for(;b-x>f;){let w=Vl(d);w=ta(w,{space:e,method:"clip"}),o(d,w)-i<f?x=Jr(d,c):b=Jr(d,c),an(d,c,(x+b)/2)}a=ue(d,e)}else a=l}else a=ue(r,e);if(t==="clip"||!Ia(a,e,{epsilon:0})){let o=Object.values(e.coords).map(l=>l.range||[]);a.coords=a.coords.map((l,h)=>{let[u,c]=o[h];return u!==void 0&&(l=Math.max(u,l)),c!==void 0&&(l=Math.min(l,c)),l})}}return e!==r.space&&(a=ue(a,r.space)),r.coords=a.coords,r}ta.returns="color";const G1={WHITE:{space:El,coords:[1,0,0]},BLACK:{space:El,coords:[0,0,0]}};function Wj(r,{space:t}={}){let e=.02,s=1e-4;r=Mt(r),t||(t=r.space),t=lt.get(t);let i=lt.get("oklch");if(t.isUnbounded)return ue(r,t);let n=ue(r,i),a=n.coords[0];if(a>=1){let m=ue(G1.WHITE,t);return m.alpha=r.alpha,ue(m,t)}if(a<=0){let m=ue(G1.BLACK,t);return m.alpha=r.alpha,ue(m,t)}if(Ia(n,t,{epsilon:0}))return ue(n,t);function o(m){let f=ue(m,t),x=Object.values(t.coords);return f.coords=f.coords.map((b,w)=>{if("range"in x[w]){let[S,_]=x[w].range;return MN(S,b,_)}return b}),f}let l=0,h=n.coords[1],u=!0,c=Vl(n),d=o(c),p=ag(d,c);if(p<e)return d;for(;h-l>s;){let m=(l+h)/2;if(c.coords[1]=m,u&&Ia(c,t,{epsilon:0}))l=m;else if(d=o(c),p=ag(d,c),p<e){if(e-p<s)break;u=!1,l=m}else h=m}return d}function ue(r,t,{inGamut:e}={}){r=Mt(r),t=lt.get(t);let s=t.from(r),i={space:t,coords:s,alpha:r.alpha};return e&&(i=ta(i,e===!0?void 0:e)),i}ue.returns="color";function Lu(r,{precision:t=es.precision,format:e="default",inGamut:s=!0,...i}={}){let n;r=Mt(r);let a=e;e=r.space.getFormat(e)??r.space.getFormat("default")??lt.DEFAULT_FORMAT;let o=r.coords.slice();if(s||(s=e.toGamut),s&&!Ia(r)&&(o=ta(Vl(r),s===!0?void 0:s).coords),e.type==="custom")if(i.precision=t,e.serialize)n=e.serialize(o,r.alpha,i);else throw TypeError(`format ${a} can only be used to parse colors, not for serialization`);else{let l=e.name||"color";e.serializeCoords?o=e.serializeCoords(o,t):t!==null&&(o=o.map(d=>kd(d,{precision:t})));let h=[...o];if(l==="color"){let d=e.id||e.ids?.[0]||r.space.id;h.unshift(d)}let u=r.alpha;t!==null&&(u=kd(u,{precision:t}));let c=r.alpha>=1||e.noAlpha?"":`${e.commas?",":" /"} ${u}`;n=`${l}(${h.join(e.commas?", ":" ")}${c})`}return n}const qj=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],Hj=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var Cp=new Or({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:qj,fromXYZ_M:Hj});const Ac=1.09929682680944,X1=.018053968510807;var ON=new Or({id:"rec2020",name:"REC.2020",base:Cp,toBase(r){return r.map(function(t){return t<X1*4.5?t/4.5:((t+Ac-1)/Ac)**(1/.45)})},fromBase(r){return r.map(function(t){return t>=X1?Ac*t**.45-(Ac-1):4.5*t})}});const Gj=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],Xj=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var BN=new Or({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:Gj,fromXYZ_M:Xj});const Yj=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],Ye=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var kN=new Or({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:Yj,fromXYZ_M:Ye}),Y1={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 Z1=[,,,].fill("<percentage> | <number>[0, 255]"),J1=[,,,].fill("<number>[0, 255]");var Ll=new Or({id:"srgb",name:"sRGB",base:kN,fromBase:r=>r.map(t=>{let e=t<0?-1:1,s=t*e;return s>.0031308?e*(1.055*s**(1/2.4)-.055):12.92*t}),toBase:r=>r.map(t=>{let e=t<0?-1:1,s=t*e;return s<=.04045?t/12.92:e*((s+.055)/1.055)**2.4}),formats:{rgb:{coords:Z1},rgb_number:{name:"rgb",commas:!0,coords:J1,noAlpha:!0},color:{},rgba:{coords:Z1,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:J1},hex:{type:"custom",toGamut:!0,test:r=>/^#([a-f0-9]{3,4}){1,2}$/i.test(r),parse(r){r.length<=5&&(r=r.replace(/[a-f0-9]/gi,"$&$&"));let t=[];return r.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:(r,t,{collapse:e=!0}={})=>{t<1&&r.push(t),r=r.map(n=>Math.round(n*255));let s=e&&r.every(n=>n%17==0);return"#"+r.map(n=>s?(n/17).toString(16):n.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:r=>/^[a-z]+$/i.test(r),parse(r){r=r.toLowerCase();let t={spaceId:"srgb",coords:null,alpha:1};if(r==="transparent"?(t.coords=Y1.black,t.alpha=0):t.coords=Y1[r],t.coords)return t}}}}),DN=new Or({id:"p3",cssId:"display-p3",name:"P3",base:BN,fromBase:Ll.fromBase,toBase:Ll.toBase});es.display_space=Ll;let Zj;if(typeof CSS<"u"&&CSS.supports)for(let r of[Qr,ON,DN]){let t=r.getMinCoords(),e={space:r,coords:t,alpha:1},s=Lu(e);if(CSS.supports("color",s)){es.display_space=r;break}}function Jj(r,{space:t=es.display_space,...e}={}){let s=Lu(r,e);if(typeof CSS>"u"||CSS.supports("color",s)||!es.display_space)s=new String(s),s.color=r;else{let i=r;if((r.coords.some(Qn)||Qn(r.alpha))&&!(Zj??(Zj=CSS.supports("color","hsl(none 50% 50%)")))&&(i=Vl(r),i.coords=i.coords.map(ke),i.alpha=ke(i.alpha),s=Lu(i,e),CSS.supports("color",s)))return s=new String(s),s.color=i,s;i=ue(i,t),s=new String(Lu(i,e)),s.color=i}return s}function Qj(r,t){return r=Mt(r),t=Mt(t),r.space===t.space&&r.alpha===t.alpha&&r.coords.every((e,s)=>e===t.coords[s])}function ea(r){return Jr(r,[ur,"y"])}function UN(r,t){an(r,[ur,"y"],t)}function Kj(r){Object.defineProperty(r.prototype,"luminance",{get(){return ea(this)},set(t){UN(this,t)}})}var tW=Object.freeze({__proto__:null,getLuminance:ea,register:Kj,setLuminance:UN});function eW(r,t){r=Mt(r),t=Mt(t);let e=Math.max(ea(r),0),s=Math.max(ea(t),0);return s>e&&([e,s]=[s,e]),(e+.05)/(s+.05)}const rW=.56,sW=.57,iW=.62,nW=.65,Q1=.022,aW=1.414,oW=.1,lW=5e-4,uW=1.14,K1=.027,hW=1.14;function tb(r){return r>=Q1?r:r+(Q1-r)**aW}function No(r){let t=r<0?-1:1,e=Math.abs(r);return t*e**2.4}function cW(r,t){t=Mt(t),r=Mt(r);let e,s,i,n,a,o;t=ue(t,"srgb"),[n,a,o]=t.coords;let l=No(n)*.2126729+No(a)*.7151522+No(o)*.072175;r=ue(r,"srgb"),[n,a,o]=r.coords;let h=No(n)*.2126729+No(a)*.7151522+No(o)*.072175,u=tb(l),c=tb(h),d=c>u;return Math.abs(c-u)<lW?s=0:d?(e=c**rW-u**sW,s=e*uW):(e=c**nW-u**iW,s=e*hW),i=Math.abs(s)<oW?0:s>0?s-K1:s+K1,i*100}function dW(r,t){r=Mt(r),t=Mt(t);let e=Math.max(ea(r),0),s=Math.max(ea(t),0);s>e&&([e,s]=[s,e]);let i=e+s;return i===0?0:(e-s)/i}const pW=5e4;function mW(r,t){r=Mt(r),t=Mt(t);let e=Math.max(ea(r),0),s=Math.max(ea(t),0);return s>e&&([e,s]=[s,e]),s===0?pW:(e-s)/s}function fW(r,t){r=Mt(r),t=Mt(t);let e=Jr(r,[Qr,"l"]),s=Jr(t,[Qr,"l"]);return Math.abs(e-s)}const gW=216/24389,eb=24/116,zc=24389/27;let jm=Ar.D65;var cg=new lt({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:jm,base:ur,fromBase(r){let t=r.map((s,i)=>s/jm[i]),e=t.map(s=>s>gW?Math.cbrt(s):(zc*s+16)/116);return[116*e[1]-16,500*(e[0]-e[1]),200*(e[1]-e[2])]},toBase(r){let t=[];return t[1]=(r[0]+16)/116,t[0]=r[1]/500+t[1],t[2]=t[1]-r[2]/200,[t[0]>eb?t[0]**3:(116*t[0]-16)/zc,r[0]>8?((r[0]+16)/116)**3:r[0]/zc,t[2]>eb?t[2]**3:(116*t[2]-16)/zc].map((s,i)=>s*jm[i])},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const yW=5**.5*.5+.5;function xW(r,t){r=Mt(r),t=Mt(t);let e=Jr(r,[cg,"l"]),s=Jr(t,[cg,"l"]),i=Math.abs(e**1.618033988749895-s**1.618033988749895),n=i**(1/yW)*Math.SQRT2-40;return n<7.5?0:n}var xd=Object.freeze({__proto__:null,contrastAPCA:cW,contrastDeltaPhi:xW,contrastLstar:fW,contrastMichelson:dW,contrastWCAG21:eW,contrastWeber:mW});function bW(r,t,e={}){wh(e)&&(e={algorithm:e});let{algorithm:s,...i}=e;if(!s){let n=Object.keys(xd).map(a=>a.replace(/^contrast/,"")).join(", ");throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${n}`)}for(let n in r=Mt(r),t=Mt(t),xd)if("contrast"+s.toLowerCase()===n.toLowerCase())return xd[n](r,t,i);throw TypeError(`Unknown contrast algorithm: ${s}`)}function Ep(r){let[t,e,s]=Mh(r,ur),i=t+15*e+3*s;return[4*t/i,9*e/i]}function $N(r){let[t,e,s]=Mh(r,ur),i=t+e+s;return[t/i,e/i]}function vW(r){Object.defineProperty(r.prototype,"uv",{get(){return Ep(this)}}),Object.defineProperty(r.prototype,"xy",{get(){return $N(this)}})}var wW=Object.freeze({__proto__:null,register:vW,uv:Ep,xy:$N});function Nu(r,t,e={}){wh(e)&&(e={method:e});let{method:s=es.deltaE,...i}=e;for(let n in Rl)if("deltae"+s.toLowerCase()===n.toLowerCase())return Rl[n](r,t,i);throw TypeError(`Unknown deltaE method: ${s}`)}function MW(r,t=.25){let e=lt.get("oklch","lch");return an(r,[e,"l"],i=>i*(1+t))}function TW(r,t=.25){let e=lt.get("oklch","lch");return an(r,[e,"l"],i=>i*(1-t))}var NW=Object.freeze({__proto__:null,darken:TW,lighten:MW});function jN(r,t,e=.5,s={}){return[r,t]=[Mt(r),Mt(t)],qn(e)==="object"&&([e,s]=[.5,e]),Th(r,t,s)(e)}function WN(r,t,e={}){let s;Jy(r)&&([s,e]=[r,t],[r,t]=s.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:n,steps:a=2,maxSteps:o=1e3,...l}=e;s||([r,t]=[Mt(r),Mt(t)],s=Th(r,t,l));let h=Nu(r,t),u=i>0?Math.max(a,Math.ceil(h/i)+1):a,c=[];if(o!==void 0&&(u=Math.min(u,o)),u===1)c=[{p:.5,color:s(.5)}];else{let d=1/(u-1);c=Array.from({length:u},(p,m)=>{let f=m*d;return{p:f,color:s(f)}})}if(i>0){let d=c.reduce((p,m,f)=>{if(f===0)return 0;let x=Nu(m.color,c[f-1].color,n);return Math.max(p,x)},0);for(;d>i;){d=0;for(let p=1;p<c.length&&c.length<o;p++){let m=c[p-1],f=c[p],x=(f.p+m.p)/2,b=s(x);d=Math.max(d,Nu(b,m.color),Nu(b,f.color)),c.splice(p,0,{p:x,color:s(x)}),p++}}}return c=c.map(d=>d.color),c}function Th(r,t,e={}){if(Jy(r)){let[l,h]=[r,t];return Th(...l.rangeArgs.colors,{...l.rangeArgs.options,...h})}let{space:s,outputSpace:i,progression:n,premultiplied:a}=e;r=Mt(r),t=Mt(t),r=Vl(r),t=Vl(t);let o={colors:[r,t],options:e};if(s=s?lt.get(s):lt.registry[es.interpolationSpace]||r.space,i=i?lt.get(i):s,r=ue(r,s),t=ue(t,s),r=ta(r),t=ta(t),s.coords.h&&s.coords.h.type==="angle"){let l=e.hue=e.hue||"shorter",h=[s,"h"],[u,c]=[Jr(r,h),Jr(t,h)];isNaN(u)&&!isNaN(c)?u=c:isNaN(c)&&!isNaN(u)&&(c=u),[u,c]=rj(l,[u,c]),an(r,h,u),an(t,h,c)}return a&&(r.coords=r.coords.map(l=>l*r.alpha),t.coords=t.coords.map(l=>l*t.alpha)),Object.assign(l=>{l=n?n(l):l;let h=r.coords.map((d,p)=>{let m=t.coords[p];return Xu(d,m,l)}),u=Xu(r.alpha,t.alpha,l),c={space:s,coords:h,alpha:u};return a&&(c.coords=c.coords.map(d=>d/u)),i!==s&&(c=ue(c,i)),c},{rangeArgs:o})}function Jy(r){return qn(r)==="function"&&!!r.rangeArgs}es.interpolationSpace="lab";function SW(r){r.defineFunction("mix",jN,{returns:"color"}),r.defineFunction("range",Th,{returns:"function<color>"}),r.defineFunction("steps",WN,{returns:"array<color>"})}var _W=Object.freeze({__proto__:null,isRange:Jy,mix:jN,range:Th,register:SW,steps:WN}),qN=new lt({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:Ll,fromBase:r=>{let t=Math.max(...r),e=Math.min(...r),[s,i,n]=r,[a,o,l]=[NaN,0,(e+t)/2],h=t-e;if(h!==0){switch(o=l===0||l===1?0:(t-l)/Math.min(l,1-l),t){case s:a=(i-n)/h+(i<n?6:0);break;case i:a=(n-s)/h+2;break;case n:a=(s-i)/h+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,o*100,l*100]},toBase:r=>{let[t,e,s]=r;t%=360,t<0&&(t+=360),e/=100,s/=100;function i(n){let a=(n+t/30)%12,o=e*Math.min(s,1-s);return s-o*Math.max(-1,Math.min(a-3,9-a,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}}}),HN=new lt({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:qN,fromBase(r){let[t,e,s]=r;e/=100,s/=100;let i=s+e*Math.min(s,1-s);return[t,i===0?0:200*(1-s/i),100*i]},toBase(r){let[t,e,s]=r;e/=100,s/=100;let i=s*(1-e/2);return[t,i===0||i===1?0:(s-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),AW=new lt({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:HN,fromBase(r){let[t,e,s]=r;return[t,s*(100-e)/100,100-s]},toBase(r){let[t,e,s]=r;e/=100,s/=100;let i=e+s;if(i>=1){let o=e/i;return[t,0,o*100]}let n=1-s,a=n===0?0:1-e/n;return[t,a*100,n*100]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const zW=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],CW=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var GN=new Or({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:zW,fromXYZ_M:CW}),EW=new Or({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:GN,toBase:r=>r.map(t=>Math.abs(t)**(563/256)*Math.sign(t)),fromBase:r=>r.map(t=>Math.abs(t)**(256/563)*Math.sign(t))});const VW=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],RW=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var XN=new Or({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:Xy,toXYZ_M:VW,fromXYZ_M:RW});const LW=1/512,IW=16/512;var PW=new Or({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:XN,toBase(r){return r.map(t=>t<IW?t/16:t**1.8)},fromBase(r){return r.map(t=>t>=LW?t**(1/1.8):16*t)}}),FW=new lt({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:El,fromBase(r){let[t,e,s]=r,i,n=2e-4;return i=Math.abs(e)<n&&Math.abs(s)<n?NaN:Math.atan2(s,e)*180/Math.PI,[t,Math.sqrt(e**2+s**2),_i(i)]},toBase(r){let[t,e,s]=r,i,n;return isNaN(s)?(i=0,n=0):(i=e*Math.cos(s*Math.PI/180),n=e*Math.sin(s*Math.PI/180)),[t,i,n]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let YN=Ar.D65;const OW=216/24389,rb=24389/27,[sb,ib]=Ep({space:ur,coords:YN});var ZN=new lt({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:YN,base:ur,fromBase(r){let t=[ke(r[0]),ke(r[1]),ke(r[2])],e=t[1],[s,i]=Ep({space:ur,coords:t});if(!Number.isFinite(s)||!Number.isFinite(i))return[0,0,0];let n=e<=OW?rb*e:116*Math.cbrt(e)-16;return[n,13*n*(s-sb),13*n*(i-ib)]},toBase(r){let[t,e,s]=r;if(t===0||Qn(t))return[0,0,0];e=ke(e),s=ke(s);let i=e/(13*t)+sb,n=s/(13*t)+ib,a=t<=8?t/rb:((t+16)/116)**3;return[a*(9*i/(4*n)),a,a*((12-3*i-20*n)/(4*n))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),Qy=new lt({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:ZN,fromBase(r){let[t,e,s]=r,i,n=.02;return i=Math.abs(e)<n&&Math.abs(s)<n?NaN:Math.atan2(s,e)*180/Math.PI,[t,Math.sqrt(e**2+s**2),_i(i)]},toBase(r){let[t,e,s]=r;return e<0&&(e=0),isNaN(s)&&(s=0),[t,e*Math.cos(s*Math.PI/180),e*Math.sin(s*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const BW=216/24389,kW=24389/27,nb=Ye[0][0],ab=Ye[0][1],Wm=Ye[0][2],ob=Ye[1][0],lb=Ye[1][1],qm=Ye[1][2],ub=Ye[2][0],hb=Ye[2][1],Hm=Ye[2][2];function So(r,t,e){let s=t/(Math.sin(e)-r*Math.cos(e));return s<0?1/0:s}function $d(r){let t=(r+16)**3/1560896,e=t>BW?t:r/kW,s=e*(284517*nb-94839*Wm),i=e*(838422*Wm+769860*ab+731718*nb),n=e*(632260*Wm-126452*ab),a=e*(284517*ob-94839*qm),o=e*(838422*qm+769860*lb+731718*ob),l=e*(632260*qm-126452*lb),h=e*(284517*ub-94839*Hm),u=e*(838422*Hm+769860*hb+731718*ub),c=e*(632260*Hm-126452*hb);return{r0s:s/n,r0i:i*r/n,r1s:s/(n+126452),r1i:(i-769860)*r/(n+126452),g0s:a/l,g0i:o*r/l,g1s:a/(l+126452),g1i:(o-769860)*r/(l+126452),b0s:h/c,b0i:u*r/c,b1s:h/(c+126452),b1i:(u-769860)*r/(c+126452)}}function cb(r,t){let e=t/360*Math.PI*2,s=So(r.r0s,r.r0i,e),i=So(r.r1s,r.r1i,e),n=So(r.g0s,r.g0i,e),a=So(r.g1s,r.g1i,e),o=So(r.b0s,r.b0i,e),l=So(r.b1s,r.b1i,e);return Math.min(s,i,n,a,o,l)}var DW=new lt({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:Qy,gamutSpace:Ll,fromBase(r){let[t,e,s]=[ke(r[0]),ke(r[1]),ke(r[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let n=$d(t),a=cb(n,s);i=e/a*100}return[s,i,t]},toBase(r){let[t,e,s]=[ke(r[0]),ke(r[1]),ke(r[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=$d(s);i=cb(n,t)/100*e}return[s,i,t]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});Ye[0][0],Ye[0][1],Ye[0][2],Ye[1][0],Ye[1][1],Ye[1][2],Ye[2][0],Ye[2][1],Ye[2][2];function _o(r,t){return Math.abs(t)/Math.sqrt(r**2+1)}function db(r){let t=_o(r.r0s,r.r0i),e=_o(r.r1s,r.r1i),s=_o(r.g0s,r.g0i),i=_o(r.g1s,r.g1i),n=_o(r.b0s,r.b0i),a=_o(r.b1s,r.b1i);return Math.min(t,e,s,i,n,a)}var UW=new lt({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:Qy,gamutSpace:"self",fromBase(r){let[t,e,s]=[ke(r[0]),ke(r[1]),ke(r[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let n=$d(t),a=db(n);i=e/a*100}return[s,i,t]},toBase(r){let[t,e,s]=[ke(r[0]),ke(r[1]),ke(r[2])],i;if(s>99.9999999)s=100,i=0;else if(s<1e-8)s=0,i=0;else{let n=$d(s);i=db(n)/100*e}return[s,i,t]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const pb=203,mb=2610/2**14,$W=2**14/2610,jW=2523/2**5,fb=2**5/2523,gb=3424/2**12,yb=2413/2**7,xb=2392/2**7;var WW=new Or({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:Cp,toBase(r){return r.map(function(t){return(Math.max(t**fb-gb,0)/(yb-xb*t**fb))**$W*1e4/pb})},fromBase(r){return r.map(function(t){let e=Math.max(t*pb/1e4,0),s=gb+yb*e**mb,i=1+xb*e**mb;return(s/i)**jW})}});const bb=.17883277,vb=.28466892,wb=.55991073,Gm=3.7743;var qW=new Or({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:Cp,toBase(r){return r.map(function(t){return t<=.5?t**2/3*Gm:(Math.exp((t-wb)/bb)+vb)/12*Gm})},fromBase(r){return r.map(function(t){return t/=Gm,t<=1/12?Math.sqrt(3*t):bb*Math.log(12*t-vb)+wb})}});const JN={};Kn.add("chromatic-adaptation-start",r=>{r.options.method&&(r.M=Mb(r.W1,r.W2,r.options.method))}),Kn.add("chromatic-adaptation-end",r=>{r.M||(r.M=Mb(r.W1,r.W2,r.options.method))});function Cc({id:r,toCone_M:t,fromCone_M:e}){JN[r]=arguments[0]}function Mb(r,t,e="Bradford"){let s=JN[e],[i,n,a]=he(s.toCone_M,r),[o,l,h]=he(s.toCone_M,t),u=[[o/i,0,0],[0,l/n,0],[0,0,h/a]],c=he(u,s.toCone_M);return he(s.fromCone_M,c)}Cc({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]]}),Cc({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]]}),Cc({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]]}),Cc({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(Ar,{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]}),Ar.ACES=[.32168/.33767,1,.34065/.33767];const HW=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],GW=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var QN=new Or({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:Ar.ACES,toXYZ_M:HW,fromXYZ_M:GW});const Ec=2**-16,Xm=-.35828683,Vc=(Math.log2(65504)+9.72)/17.52;var XW=new Or({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[Xm,Vc],name:"Red"},g:{range:[Xm,Vc],name:"Green"},b:{range:[Xm,Vc],name:"Blue"}},referred:"scene",base:QN,toBase(r){let t=-.3013698630136986;return r.map(function(e){return e<=t?(2**(e*17.52-9.72)-Ec)*2:e<Vc?2**(e*17.52-9.72):65504})},fromBase(r){return r.map(function(t){return t<=0?(Math.log2(Ec)+9.72)/17.52:t<Ec?(Math.log2(Ec+t*.5)+9.72)/17.52:(Math.log2(t)+9.72)/17.52})}}),Tb=Object.freeze({__proto__:null,A98RGB:EW,A98RGB_Linear:GN,ACEScc:XW,ACEScg:QN,CAM16_JMh:Pj,HCT:Zu,HPLuv:UW,HSL:qN,HSLuv:DW,HSV:HN,HWB:AW,ICTCP:lg,JzCzHz:og,Jzazbz:AN,LCH:Yu,LCHuv:Qy,Lab:Qr,Lab_D65:cg,Luv:ZN,OKLCH:FW,OKLab:El,P3:DN,P3_Linear:BN,ProPhoto:PW,ProPhoto_Linear:XN,REC_2020:ON,REC_2020_Linear:Cp,REC_2100_HLG:qW,REC_2100_PQ:WW,XYZ_ABS_D65:Yy,XYZ_D50:Xy,XYZ_D65:ur,sRGB:Ll,sRGB_Linear:kN}),qr=class zr{constructor(...t){let e;t.length===1&&(e=Mt(t[0]));let s,i,n;e?(s=e.space||e.spaceId,i=e.coords,n=e.alpha):[s,i,n]=t,Object.defineProperty(this,"space",{value:lt.get(s),writable:!1,enumerable:!0,configurable:!0}),this.coords=i?i.slice():[0,0,0],this.alpha=n>1||n===void 0?1:n<0?0:n;for(let a=0;a<this.coords.length;a++)this.coords[a]==="NaN"&&(this.coords[a]=NaN);for(let a in this.space.coords)Object.defineProperty(this,a,{get:()=>this.get(a),set:o=>this.set(a,o)})}get spaceId(){return this.space.id}clone(){return new zr(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let e=Jj(this,...t);return e.color=new zr(e.color),e}static get(t,...e){return t instanceof zr?t:new zr(t,...e)}static defineFunction(t,e,s=e){let{instance:i=!0,returns:n}=s,a=function(...o){let l=e(...o);if(n==="color")l=zr.get(l);else if(n==="function<color>"){let h=l;l=function(...u){let c=h(...u);return zr.get(c)},Object.assign(l,h)}else n==="array<color>"&&(l=l.map(h=>zr.get(h)));return l};t in zr||(zr[t]=a),i&&(zr.prototype[t]=function(...o){return a(this,...o)})}static defineFunctions(t){for(let e in t)zr.defineFunction(e,t[e],t[e])}static extend(t){if(t.register)t.register(zr);else for(let e in t)zr.defineFunction(e,t[e])}};qr.defineFunctions({get:Jr,getAll:Mh,set:an,setAll:Gy,to:ue,equals:Qj,inGamut:Ia,toGamut:ta,distance:_N,toString:Lu}),Object.assign(qr,{util:Z$,hooks:Kn,WHITES:Ar,Space:lt,spaces:lt.registry,parse:NN,defaults:es});for(let r of Object.keys(Tb))lt.register(Tb[r]);for(let r in lt.registry)dg(r,lt.registry[r]);Kn.add("colorspace-init-end",r=>{dg(r.id,r),r.aliases?.forEach(t=>{dg(t,r)})});function dg(r,t){let e=r.replace(/-/g,"_");Object.defineProperty(qr.prototype,e,{get(){let s=this.getAll(r);return typeof Proxy>"u"?s:new Proxy(s,{has:(i,n)=>{try{return lt.resolveCoord([t,n]),!0}catch{}return Reflect.has(i,n)},get:(i,n,a)=>{if(n&&typeof n!="symbol"&&!(n in i)){let{index:o}=lt.resolveCoord([t,n]);if(o>=0)return i[o]}return Reflect.get(i,n,a)},set:(i,n,a,o)=>{if(n&&typeof n!="symbol"&&!(n in i)||n>=0){let{index:l}=lt.resolveCoord([t,n]);if(l>=0)return i[l]=a,this.setAll(r,i),!0}return Reflect.set(i,n,a,o)}})},set(s){this.setAll(r,s)},configurable:!0,enumerable:!0})}qr.extend(Rl),qr.extend({deltaE:Nu}),Object.assign(qr,{deltaEMethods:Rl}),qr.extend(NW),qr.extend({contrast:bW}),qr.extend(wW),qr.extend(tW),qr.extend(_W),qr.extend(xd);const{vec2:YW,vec4:ZW}=rs,Ju=r=>{let t=new qr(r);return ZW(...t.to("p3-linear").coords,t.alpha).value},Ky=r=>{let t=.5,e=.5;if(typeof r=="string"){let s=r.toLowerCase().trim().split(/\s+/);s.includes("left")?t=0:s.includes("right")?t=1:(s.includes("center")||s.length===1&&(s[0]==="top"||s[0]==="bottom"))&&(t=.5),s.includes("top")?e=0:s.includes("bottom")?e=1:(s.includes("center")||s.length===1&&(s[0]==="left"||s[0]==="right"))&&(e=.5),s.length===1&&s[0]==="center"&&(t=.5,e=.5)}else typeof r=="object"&&r?(t=r.x,e=r.y):console.warn(`Invalid position value provided: ${r}. Defaulting to center.`);return YW(t,1-e).value},{vec2:Nb,viewportSize:JW}=rs,Sb=(r=Nb(0))=>{let t=JW,e=t.x.div(t.y),s=r.x.mul(e);return Nb(s,r.y)},ul={name:"Circle",props:{color:{type:String,default:"#ffffff",transform:Ju,description:"The color of the circle"},backgroundColor:{type:String,default:"transparent",transform:Ju,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:Ky}},fragmentNode:({uniforms:r})=>{let{vec2:t,vec4:e,length:s,mix:i,smoothstep:n,uv:a}=rs,o=t(r.center.uniform.x.mul(.5).add(.25),r.center.uniform.y.mul(.5).add(.25)),l=Sb(a()),h=Sb(o),u=s(l.sub(h)),c=r.softness.uniform,d=r.radius.uniform.mul(.25),p=n(d,d.sub(c),u);return e(i(r.backgroundColor.uniform,r.color.uniform,p),1)}};/**
|
|
90
|
+
* @license
|
|
91
|
+
* Copyright 2010-2025 Three.js Authors
|
|
92
|
+
* SPDX-License-Identifier: MIT
|
|
93
|
+
*/const KN="177",QW=0,bd=3,pg=0,Vp=1,KW=0,mg=1,_b=100,Ab=204,zb=205,Cb=3,tq=0,fg=0,t0=300,jd=301,gg=302,eq=306,Eb=1e3,Su=1001,Vb=1002,ra=1003,Qu=1006,tS=1008,rq=1008,sq=1009,iq=1013,eS=1014,rS=1015,Dn=1016,sS=1023,Rb=1026,nq=1027,Rc=1030,Lb=0,aq=1,Wd="",Ds="srgb",qd="srgb-linear",Ib="linear",Iu="srgb",Ao=7680,Pb=519,oq=513,Hd=35044,_u=35048,Wi=2e3,ja=2001;class Za{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return s===void 0?!1:s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){const s=this._listeners;if(s===void 0)return;const i=s[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const s=e[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,a=i.length;n<a;n++)i[n].call(this,t);t.target=null}}}const mr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Fb=1234567;const Pu=Math.PI/180,Gd=180/Math.PI;function Ji(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(mr[r&255]+mr[r>>8&255]+mr[r>>16&255]+mr[r>>24&255]+"-"+mr[t&255]+mr[t>>8&255]+"-"+mr[t>>16&15|64]+mr[t>>24&255]+"-"+mr[e&63|128]+mr[e>>8&255]+"-"+mr[e>>16&255]+mr[e>>24&255]+mr[s&255]+mr[s>>8&255]+mr[s>>16&255]+mr[s>>24&255]).toLowerCase()}function At(r,t,e){return Math.max(t,Math.min(e,r))}function e0(r,t){return(r%t+t)%t}function lq(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function uq(r,t,e){return r!==t?(e-r)/(t-r):0}function Fu(r,t,e){return(1-e)*r+e*t}function hq(r,t,e,s){return Fu(r,t,1-Math.exp(-e*s))}function cq(r,t=1){return t-Math.abs(e0(r,t*2)-t)}function dq(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function pq(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function mq(r,t){return r+Math.floor(Math.random()*(t-r+1))}function fq(r,t){return r+Math.random()*(t-r)}function gq(r){return r*(.5-Math.random())}function yq(r){r!==void 0&&(Fb=r);let t=Fb+=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 xq(r){return r*Pu}function bq(r){return r*Gd}function vq(r){return(r&r-1)===0&&r!==0}function wq(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Mq(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Tq(r,t,e,s,i){const n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ws(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function qt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const iS={DEG2RAD:Pu,RAD2DEG:Gd,generateUUID:Ji,clamp:At,euclideanModulo:e0,mapLinear:lq,inverseLerp:uq,lerp:Fu,damp:hq,pingpong:cq,smoothstep:dq,smootherstep:pq,randInt:mq,randFloat:fq,randFloatSpread:gq,seededRandom:yq,degToRad:xq,radToDeg:bq,isPowerOfTwo:vq,ceilPowerOfTwo:wq,floorPowerOfTwo:Mq,setQuaternionFromProperEuler:Tq,normalize:qt,denormalize:Ws};class ge{constructor(t=0,e=0){ge.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(At(s,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(At(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Nh{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,a,o){let l=s[i+0],h=s[i+1],u=s[i+2],c=s[i+3];const d=n[a+0],p=n[a+1],m=n[a+2],f=n[a+3];if(o===0){t[e+0]=l,t[e+1]=h,t[e+2]=u,t[e+3]=c;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=m,t[e+3]=f;return}if(c!==f||l!==d||h!==p||u!==m){let x=1-o;const b=l*d+h*p+u*m+c*f,w=b>=0?1:-1,S=1-b*b;if(S>Number.EPSILON){const V=Math.sqrt(S),z=Math.atan2(V,b*w);x=Math.sin(x*z)/V,o=Math.sin(o*z)/V}const _=o*w;if(l=l*x+d*_,h=h*x+p*_,u=u*x+m*_,c=c*x+f*_,x===1-o){const V=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=V,h*=V,u*=V,c*=V}}t[e]=l,t[e+1]=h,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,s,i,n,a){const o=s[i],l=s[i+1],h=s[i+2],u=s[i+3],c=n[a],d=n[a+1],p=n[a+2],m=n[a+3];return t[e]=o*m+u*c+l*p-h*d,t[e+1]=l*m+u*d+h*c-o*p,t[e+2]=h*m+u*p+o*d-l*c,t[e+3]=u*m-o*c-l*d-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t._x,i=t._y,n=t._z,a=t._order,o=Math.cos,l=Math.sin,h=o(s/2),u=o(i/2),c=o(n/2),d=l(s/2),p=l(i/2),m=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c-d*p*m;break;case"YXZ":this._x=d*u*c+h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c+d*p*m;break;case"ZXY":this._x=d*u*c-h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c-d*p*m;break;case"ZYX":this._x=d*u*c-h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c+d*p*m;break;case"YZX":this._x=d*u*c+h*p*m,this._y=h*p*c+d*u*m,this._z=h*u*m-d*p*c,this._w=h*u*c-d*p*m;break;case"XZY":this._x=d*u*c-h*p*m,this._y=h*p*c-d*u*m,this._z=h*u*m+d*p*c,this._w=h*u*c+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],a=e[1],o=e[5],l=e[9],h=e[2],u=e[6],c=e[10],d=s+o+c;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(n-h)*p,this._z=(a-i)*p}else if(s>o&&s>c){const p=2*Math.sqrt(1+s-o-c);this._w=(u-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(n+h)/p}else if(o>c){const p=2*Math.sqrt(1+o-s-c);this._w=(n-h)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+c-s-o);this._w=(a-i)/p,this._x=(n+h)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(At(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,a=t._w,o=e._x,l=e._y,h=e._z,u=e._w;return this._x=s*u+a*o+i*h-n*l,this._y=i*u+a*l+n*o-s*h,this._z=n*u+a*h+s*l-i*o,this._w=a*u-s*o-i*l-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,a=this._w;let o=a*t._w+s*t._x+i*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=s,this._y=i,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*s+e*this._x,this._y=p*i+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-e)*u)/h,d=Math.sin(e*u)/h;return this._w=a*c+this._w*d,this._x=s*c+this._x*d,this._y=i*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{constructor(t=0,e=0,s=0){k.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ob.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ob.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this.z=At(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this.z=At(this.z,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(At(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Ym.copy(this).projectOnVector(t),this.sub(Ym)}reflect(t){return this.sub(Ym.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(At(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ym=new k,Ob=new Nh;class Ns{constructor(t,e,s,i,n,a,o,l,h){Ns.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){const u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],V=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*V,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*V,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*V,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/m;return t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Zm.makeScale(t,e)),this}rotate(t){return this.premultiply(Zm.makeRotation(-t)),this}translate(t,e){return this.premultiply(Zm.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Zm=new Ns;function Nq(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function Bb(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const kb={};function Db(r){r in kb||(kb[r]=!0,console.warn(r))}const Ub=new Ns().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$b=new Ns().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Sq(){const r={enabled:!0,workingColorSpace:qd,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Iu&&(i.r=Qi(i.r),i.g=Qi(i.g),i.b=Qi(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Iu&&(i.r=hl(i.r),i.g=hl(i.g),i.b=hl(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Wd?Ib:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return Db("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return Db("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[qd]:{primaries:t,whitePoint:s,transfer:Ib,toXYZ:Ub,fromXYZ:$b,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ds},outputColorSpaceConfig:{drawingBufferColorSpace:Ds}},[Ds]:{primaries:t,whitePoint:s,transfer:Iu,toXYZ:Ub,fromXYZ:$b,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ds}}}),r}const Te=Sq();function Qi(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function hl(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let zo;class _q{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let s;if(t instanceof HTMLCanvasElement)s=t;else{zo===void 0&&(zo=Bb("canvas")),zo.width=t.width,zo.height=t.height;const i=zo.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),s=zo}return s.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Bb("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let a=0;a<n.length;a++)n[a]=Qi(n[a]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(Qi(e[s]/255)*255):e[s]=Qi(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Aq=0;class r0{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Aq++}),this.uuid=Ji(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?n.push(Jm(i[a].image)):n.push(Jm(i[a]))}else n=Jm(i);s.url=n}return e||(t.images[this.uuid]=s),s}}function Jm(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?_q.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let zq=0;const Qm=new k;class Rr extends Za{constructor(t=Rr.DEFAULT_IMAGE,e=Rr.DEFAULT_MAPPING,s=Su,i=Su,n=Qu,a=tS,o=sS,l=sq,h=Rr.DEFAULT_ANISOTROPY,u=Wd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zq++}),this.uuid=Ji(),this.name="",this.source=new r0(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ge(0,0),this.repeat=new ge(1,1),this.center=new ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ns,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(Qm).x}get height(){return this.source.getSize(Qm).y}get depth(){return this.source.getSize(Qm).z}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const s=t[e];if(s===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==t0)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Eb:t.x=t.x-Math.floor(t.x);break;case Su:t.x=t.x<0?0:1;break;case Vb:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Eb:t.y=t.y-Math.floor(t.y);break;case Su:t.y=t.y<0?0:1;break;case Vb:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Rr.DEFAULT_IMAGE=null;Rr.DEFAULT_MAPPING=t0;Rr.DEFAULT_ANISOTROPY=1;class Mr{constructor(t=0,e=0,s=0,i=1){Mr.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n;const l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<.01&&Math.abs(c-f)<.01&&Math.abs(m-x)<.01){if(Math.abs(u+d)<.1&&Math.abs(c+f)<.1&&Math.abs(m+x)<.1&&Math.abs(h+p+b-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const S=(h+1)/2,_=(p+1)/2,V=(b+1)/2,z=(u+d)/4,A=(c+f)/4,I=(m+x)/4;return S>_&&S>V?S<.01?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>V?_<.01?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=I/i):V<.01?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(V),s=A/n,i=I/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this.z=At(this.z,t.z,e.z),this.w=At(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this.z=At(this.z,t,e),this.w=At(this.w,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(At(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Sh extends Za{constructor(t=1,e=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Qu,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},s),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=s.depth,this.scissor=new Mr(0,0,t,e),this.scissorTest=!1,this.viewport=new Mr(0,0,t,e);const i={width:t,height:e,depth:s.depth},n=new Rr(i);this.textures=[];const a=s.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview}_setTextureOptions(t={}){const e={minFilter:Qu,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let i=0,n=this.textures.length;i<n;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=s,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,s=t.textures.length;e<s;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new r0(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cq extends Rr{constructor(t=null,e=1,s=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:s,depth:i},this.magFilter=ra,this.minFilter=ra,this.wrapR=Su,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class _h{constructor(t=new k(1/0,1/0,1/0),e=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Rs.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(Rs.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Rs.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const n=s.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Rs):Rs.fromBufferAttribute(n,a),Rs.applyMatrix4(t.matrixWorld),this.expandByPoint(Rs);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Lc.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Lc.copy(s.boundingBox)),Lc.applyMatrix4(t.matrixWorld),this.union(Lc)}const i=t.children;for(let n=0,a=i.length;n<a;n++)this.expandByObject(i[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Rs),Rs.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(au),Ic.subVectors(this.max,au),Co.subVectors(t.a,au),Eo.subVectors(t.b,au),Vo.subVectors(t.c,au),Mn.subVectors(Eo,Co),Tn.subVectors(Vo,Eo),ma.subVectors(Co,Vo);let e=[0,-Mn.z,Mn.y,0,-Tn.z,Tn.y,0,-ma.z,ma.y,Mn.z,0,-Mn.x,Tn.z,0,-Tn.x,ma.z,0,-ma.x,-Mn.y,Mn.x,0,-Tn.y,Tn.x,0,-ma.y,ma.x,0];return!Km(e,Co,Eo,Vo,Ic)||(e=[1,0,0,0,1,0,0,0,1],!Km(e,Co,Eo,Vo,Ic))?!1:(Pc.crossVectors(Mn,Tn),e=[Pc.x,Pc.y,Pc.z],Km(e,Co,Eo,Vo,Ic))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Rs).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Rs).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ii[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ii[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ii[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ii[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ii[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ii[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ii[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ii[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ii),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Ii=[new k,new k,new k,new k,new k,new k,new k,new k],Rs=new k,Lc=new _h,Co=new k,Eo=new k,Vo=new k,Mn=new k,Tn=new k,ma=new k,au=new k,Ic=new k,Pc=new k,fa=new k;function Km(r,t,e,s,i){for(let n=0,a=r.length-3;n<=a;n+=3){fa.fromArray(r,n);const o=i.x*Math.abs(fa.x)+i.y*Math.abs(fa.y)+i.z*Math.abs(fa.z),l=t.dot(fa),h=e.dot(fa),u=s.dot(fa);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const Eq=new _h,ou=new k,tf=new k;class s0{constructor(t=new k,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):Eq.setFromPoints(t).getCenter(s);let i=0;for(let n=0,a=t.length;n<a;n++)i=Math.max(i,s.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ou.subVectors(t,this.center);const e=ou.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(ou,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(tf.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ou.copy(t.center).add(tf)),this.expandByPoint(ou.copy(t.center).sub(tf))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Pi=new k,ef=new k,Fc=new k,Nn=new k,rf=new k,Oc=new k,sf=new k;class Vq{constructor(t=new k,e=new k(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Pi)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Pi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Pi.copy(this.origin).addScaledVector(this.direction,e),Pi.distanceToSquared(t))}distanceSqToSegment(t,e,s,i){ef.copy(t).add(e).multiplyScalar(.5),Fc.copy(e).sub(t).normalize(),Nn.copy(this.origin).sub(ef);const n=t.distanceTo(e)*.5,a=-this.direction.dot(Fc),o=Nn.dot(this.direction),l=-Nn.dot(Fc),h=Nn.lengthSq(),u=Math.abs(1-a*a);let c,d,p,m;if(u>0)if(c=a*l-o,d=a*o-l,m=n*u,c>=0)if(d>=-m)if(d<=m){const f=1/u;c*=f,d*=f,p=c*(c+a*d+2*o)+d*(a*c+d+2*l)+h}else d=n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;else d=-n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;else d<=-m?(c=Math.max(0,-(-a*n+o)),d=c>0?-n:Math.min(Math.max(-n,-l),n),p=-c*c+d*(d+2*l)+h):d<=m?(c=0,d=Math.min(Math.max(-n,-l),n),p=d*(d+2*l)+h):(c=Math.max(0,-(a*n+o)),d=c>0?n:Math.min(Math.max(-n,-l),n),p=-c*c+d*(d+2*l)+h);else d=a>0?-n:n,c=Math.max(0,-(a*d+o)),p=-c*c+d*(d+2*l)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(ef).addScaledVector(Fc,d),p}intersectSphere(t,e){Pi.subVectors(t.center,this.origin);const s=Pi.dot(this.direction),i=Pi.dot(Pi)-s*s,n=t.radius*t.radius;if(i>n)return null;const a=Math.sqrt(n-i),o=s-a,l=s+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,i,n,a,o,l;const h=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,d=this.origin;return h>=0?(s=(t.min.x-d.x)*h,i=(t.max.x-d.x)*h):(s=(t.max.x-d.x)*h,i=(t.min.x-d.x)*h),u>=0?(n=(t.min.y-d.y)*u,a=(t.max.y-d.y)*u):(n=(t.max.y-d.y)*u,a=(t.min.y-d.y)*u),s>a||n>i||((n>s||isNaN(s))&&(s=n),(a<i||isNaN(i))&&(i=a),c>=0?(o=(t.min.z-d.z)*c,l=(t.max.z-d.z)*c):(o=(t.max.z-d.z)*c,l=(t.min.z-d.z)*c),s>l||o>i)||((o>s||s!==s)&&(s=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(s>=0?s:i,e)}intersectsBox(t){return this.intersectBox(t,Pi)!==null}intersectTriangle(t,e,s,i,n){rf.subVectors(e,t),Oc.subVectors(s,t),sf.crossVectors(rf,Oc);let a=this.direction.dot(sf),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Nn.subVectors(this.origin,t);const l=o*this.direction.dot(Oc.crossVectors(Nn,Oc));if(l<0)return null;const h=o*this.direction.dot(rf.cross(Nn));if(h<0||l+h>a)return null;const u=-o*Nn.dot(sf);return u<0?null:this.at(u/a,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Zt{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Zt.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,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){const b=this.elements;return b[0]=t,b[4]=e,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=x,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 Zt().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/Ro.setFromMatrixColumn(t,0).length(),n=1/Ro.setFromMatrixColumn(t,1).length(),a=1/Ro.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){const d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){const d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){const d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Rq,t,Lq)}lookAt(t,e,s){const i=this.elements;return Ur.subVectors(t,e),Ur.lengthSq()===0&&(Ur.z=1),Ur.normalize(),Sn.crossVectors(s,Ur),Sn.lengthSq()===0&&(Math.abs(s.z)===1?Ur.x+=1e-4:Ur.z+=1e-4,Ur.normalize(),Sn.crossVectors(s,Ur)),Sn.normalize(),Bc.crossVectors(Ur,Sn),i[0]=Sn.x,i[4]=Bc.x,i[8]=Ur.x,i[1]=Sn.y,i[5]=Bc.y,i[9]=Ur.y,i[2]=Sn.z,i[6]=Bc.z,i[10]=Ur.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],V=s[15],z=i[0],A=i[4],I=i[8],et=i[12],nt=i[1],it=i[5],vt=i[9],mt=i[13],Rt=i[2],Vt=i[6],Yt=i[10],se=i[14],te=i[3],ft=i[7],bt=i[11],Et=i[15];return n[0]=a*z+o*nt+l*Rt+h*te,n[4]=a*A+o*it+l*Vt+h*ft,n[8]=a*I+o*vt+l*Yt+h*bt,n[12]=a*et+o*mt+l*se+h*Et,n[1]=u*z+c*nt+d*Rt+p*te,n[5]=u*A+c*it+d*Vt+p*ft,n[9]=u*I+c*vt+d*Yt+p*bt,n[13]=u*et+c*mt+d*se+p*Et,n[2]=m*z+f*nt+x*Rt+b*te,n[6]=m*A+f*it+x*Vt+b*ft,n[10]=m*I+f*vt+x*Yt+b*bt,n[14]=m*et+f*mt+x*se+b*Et,n[3]=w*z+S*nt+_*Rt+V*te,n[7]=w*A+S*it+_*Vt+V*ft,n[11]=w*I+S*vt+_*Yt+V*bt,n[15]=w*et+S*mt+_*se+V*Et,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,V=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*V;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=V*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,V=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*V,i[1]=(p+_)*V,i[2]=(m-S)*V,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=Ro.set(i[0],i[1],i[2]).length();const a=Ro.set(i[4],i[5],i[6]).length(),o=Ro.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Ls.copy(this);const h=1/n,u=1/a,c=1/o;return Ls.elements[0]*=h,Ls.elements[1]*=h,Ls.elements[2]*=h,Ls.elements[4]*=u,Ls.elements[5]*=u,Ls.elements[6]*=u,Ls.elements[8]*=c,Ls.elements[9]*=c,Ls.elements[10]*=c,e.setFromRotationMatrix(Ls),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Wi){const l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i);let p,m;if(o===Wi)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===ja)p=-a/(a-n),m=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,s,i,n,a,o=Wi){const l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u;let m,f;if(o===Wi)m=(a+n)*c,f=-2*c;else if(o===ja)m=n*c,f=-1*c;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Ro=new k,Ls=new Zt,Rq=new k(0,0,0),Lq=new k(1,1,1),Sn=new k,Bc=new k,Ur=new k,jb=new Zt,Wb=new Nh;class Ja{constructor(t=0,e=0,s=0,i=Ja.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,n=i[0],a=i[4],o=i[8],l=i[1],h=i[5],u=i[9],c=i[2],d=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(At(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-At(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(At(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-At(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(At(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-At(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return jb.makeRotationFromQuaternion(t),this.setFromRotationMatrix(jb,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Wb.setFromEuler(this),this.setFromQuaternion(Wb,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ja.DEFAULT_ORDER="XYZ";class Iq{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Pq=0;const qb=new k,Lo=new Nh,Fi=new Zt,kc=new k,lu=new k,Fq=new k,Oq=new Nh,Hb=new k(1,0,0),Gb=new k(0,1,0),Xb=new k(0,0,1),Yb={type:"added"},Bq={type:"removed"},Io={type:"childadded",child:null},nf={type:"childremoved",child:null};class Zs extends Za{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Pq++}),this.uuid=Ji(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zs.DEFAULT_UP.clone();const t=new k,e=new Ja,s=new Nh,i=new k(1,1,1);function n(){s.setFromEuler(e,!1)}function a(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Zt},normalMatrix:{value:new Ns}}),this.matrix=new Zt,this.matrixWorld=new Zt,this.matrixAutoUpdate=Zs.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Iq,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(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Lo.setFromAxisAngle(t,e),this.quaternion.multiply(Lo),this}rotateOnWorldAxis(t,e){return Lo.setFromAxisAngle(t,e),this.quaternion.premultiply(Lo),this}rotateX(t){return this.rotateOnAxis(Hb,t)}rotateY(t){return this.rotateOnAxis(Gb,t)}rotateZ(t){return this.rotateOnAxis(Xb,t)}translateOnAxis(t,e){return qb.copy(t).applyQuaternion(this.quaternion),this.position.add(qb.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Hb,t)}translateY(t){return this.translateOnAxis(Gb,t)}translateZ(t){return this.translateOnAxis(Xb,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Fi.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?kc.copy(t):kc.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),lu.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fi.lookAt(lu,kc,this.up):Fi.lookAt(kc,lu,this.up),this.quaternion.setFromRotationMatrix(Fi),i&&(Fi.extractRotation(i.matrixWorld),Lo.setFromRotationMatrix(Fi),this.quaternion.premultiply(Lo.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Yb),Io.child=t,this.dispatchEvent(Io),Io.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Bq),nf.child=t,this.dispatchEvent(nf),nf.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Fi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Fi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Fi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Yb),Io.child=t,this.dispatchEvent(Io),Io.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){const a=this.children[s].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let n=0,a=i.length;n<a;n++)i[n].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(lu,t,Fq),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(lu,Oq,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.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)),e===!0){const i=this.children;for(let n=0,a=i.length;n<a;n++)i[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,u=l.length;h<u;h++){const c=l[h];n(t.shapes,c)}else n(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(t.materials,this.material[l]));i.material=o}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(n(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),h=a(t.textures),u=a(t.images),c=a(t.shapes),d=a(t.skeletons),p=a(t.animations),m=a(t.nodes);o.length>0&&(s.geometries=o),l.length>0&&(s.materials=l),h.length>0&&(s.textures=h),u.length>0&&(s.images=u),c.length>0&&(s.shapes=c),d.length>0&&(s.skeletons=d),p.length>0&&(s.animations=p),m.length>0&&(s.nodes=m)}return s.object=i,s;function a(o){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const i=t.children[s];this.add(i.clone())}return this}}Zs.DEFAULT_UP=new k(0,1,0);Zs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Is=new k,Oi=new k,af=new k,Bi=new k,Po=new k,Fo=new k,Zb=new k,of=new k,lf=new k,uf=new k,hf=new Mr,cf=new Mr,df=new Mr;class qs{constructor(t=new k,e=new k,s=new k){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),Is.subVectors(t,e),i.cross(Is);const n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,e,s,i,n){Is.subVectors(i,e),Oi.subVectors(s,e),af.subVectors(t,e);const a=Is.dot(Is),o=Is.dot(Oi),l=Is.dot(af),h=Oi.dot(Oi),u=Oi.dot(af),c=a*h-o*o;if(c===0)return n.set(0,0,0),null;const d=1/c,p=(h*l-o*u)*d,m=(a*u-o*l)*d;return n.set(1-p-m,m,p)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,Bi)===null?!1:Bi.x>=0&&Bi.y>=0&&Bi.x+Bi.y<=1}static getInterpolation(t,e,s,i,n,a,o,l){return this.getBarycoord(t,e,s,i,Bi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(n,Bi.x),l.addScaledVector(a,Bi.y),l.addScaledVector(o,Bi.z),l)}static getInterpolatedAttribute(t,e,s,i,n,a){return hf.setScalar(0),cf.setScalar(0),df.setScalar(0),hf.fromBufferAttribute(t,e),cf.fromBufferAttribute(t,s),df.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(hf,n.x),a.addScaledVector(cf,n.y),a.addScaledVector(df,n.z),a}static isFrontFacing(t,e,s,i){return Is.subVectors(s,e),Oi.subVectors(t,e),Is.cross(Oi).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Is.subVectors(this.c,this.b),Oi.subVectors(this.a,this.b),Is.cross(Oi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return qs.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return qs.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,n){return qs.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return qs.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return qs.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,n=this.c;let a,o;Po.subVectors(i,s),Fo.subVectors(n,s),of.subVectors(t,s);const l=Po.dot(of),h=Fo.dot(of);if(l<=0&&h<=0)return e.copy(s);lf.subVectors(t,i);const u=Po.dot(lf),c=Fo.dot(lf);if(u>=0&&c<=u)return e.copy(i);const d=l*c-u*h;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),e.copy(s).addScaledVector(Po,a);uf.subVectors(t,n);const p=Po.dot(uf),m=Fo.dot(uf);if(m>=0&&p<=m)return e.copy(n);const f=p*h-l*m;if(f<=0&&h>=0&&m<=0)return o=h/(h-m),e.copy(s).addScaledVector(Fo,o);const x=u*m-p*c;if(x<=0&&c-u>=0&&p-m>=0)return Zb.subVectors(n,i),o=(c-u)/(c-u+(p-m)),e.copy(i).addScaledVector(Zb,o);const b=1/(x+f+d);return a=f*b,o=d*b,e.copy(s).addScaledVector(Po,a).addScaledVector(Fo,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const nS={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},_n={h:0,s:0,l:0},Dc={h:0,s:0,l:0};function pf(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class dn{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ds){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Te.colorSpaceToWorking(this,e),this}setRGB(t,e,s,i=Te.workingColorSpace){return this.r=t,this.g=e,this.b=s,Te.colorSpaceToWorking(this,i),this}setHSL(t,e,s,i=Te.workingColorSpace){if(t=e0(t,1),e=At(e,0,1),s=At(s,0,1),e===0)this.r=this.g=this.b=s;else{const n=s<=.5?s*(1+e):s+e-s*e,a=2*s-n;this.r=pf(a,n,t+1/3),this.g=pf(a,n,t),this.b=pf(a,n,t-1/3)}return Te.colorSpaceToWorking(this,i),this}setStyle(t,e=Ds){function s(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ds){const s=nS[t.toLowerCase()];return s!==void 0?this.setHex(s,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Qi(t.r),this.g=Qi(t.g),this.b=Qi(t.b),this}copyLinearToSRGB(t){return this.r=hl(t.r),this.g=hl(t.g),this.b=hl(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ds){return Te.workingToColorSpace(fr.copy(this),t),Math.round(At(fr.r*255,0,255))*65536+Math.round(At(fr.g*255,0,255))*256+Math.round(At(fr.b*255,0,255))}getHexString(t=Ds){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Te.workingColorSpace){Te.workingToColorSpace(fr.copy(this),e);const s=fr.r,i=fr.g,n=fr.b,a=Math.max(s,i,n),o=Math.min(s,i,n);let l,h;const u=(o+a)/2;if(o===a)l=0,h=0;else{const c=a-o;switch(h=u<=.5?c/(a+o):c/(2-a-o),a){case s:l=(i-n)/c+(i<n?6:0);break;case i:l=(n-s)/c+2;break;case n:l=(s-i)/c+4;break}l/=6}return t.h=l,t.s=h,t.l=u,t}getRGB(t,e=Te.workingColorSpace){return Te.workingToColorSpace(fr.copy(this),e),t.r=fr.r,t.g=fr.g,t.b=fr.b,t}getStyle(t=Ds){Te.workingToColorSpace(fr.copy(this),t);const e=fr.r,s=fr.g,i=fr.b;return t!==Ds?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(t,e,s){return this.getHSL(_n),this.setHSL(_n.h+t,_n.s+e,_n.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(_n),t.getHSL(Dc);const s=Fu(_n.h,Dc.h,e),i=Fu(_n.s,Dc.s,e),n=Fu(_n.l,Dc.l,e);return this.setHSL(s,i,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,i=this.b,n=t.elements;return this.r=n[0]*e+n[3]*s+n[6]*i,this.g=n[1]*e+n[4]*s+n[7]*i,this.b=n[2]*e+n[5]*s+n[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const fr=new dn;dn.NAMES=nS;let kq=0;class yg extends Za{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:kq++}),this.uuid=Ji(),this.name="",this.type="Material",this.blending=mg,this.side=pg,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ab,this.blendDst=zb,this.blendEquation=_b,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new dn(0,0,0),this.blendAlpha=0,this.depthFunc=Cb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Pb,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ao,this.stencilZFail=Ao,this.stencilZPass=Ao,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const s=t[e];if(s===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(t).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(t).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(t).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(t).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(t).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==mg&&(s.blending=this.blending),this.side!==pg&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==Ab&&(s.blendSrc=this.blendSrc),this.blendDst!==zb&&(s.blendDst=this.blendDst),this.blendEquation!==_b&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==Cb&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Pb&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ao&&(s.stencilFail=this.stencilFail),this.stencilZFail!==Ao&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==Ao&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(e){const n=i(t.textures),a=i(t.images);n.length>0&&(s.textures=n),a.length>0&&(s.images=a)}return s}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let s=null;if(e!==null){const i=e.length;s=new Array(i);for(let n=0;n!==i;++n)s[n]=e[n].clone()}return this.clippingPlanes=s,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class aS extends yg{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new dn(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 Ja,this.combine=tq,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Pe=new k,Uc=new ge;let Dq=0;class gs{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Dq++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=Hd,this.updateRanges=[],this.gpuType=rS,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)Uc.fromBufferAttribute(this,e),Uc.applyMatrix3(t),this.setXY(e,Uc.x,Uc.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)Pe.fromBufferAttribute(this,e),Pe.applyMatrix3(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)Pe.fromBufferAttribute(this,e),Pe.applyMatrix4(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)Pe.fromBufferAttribute(this,e),Pe.applyNormalMatrix(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)Pe.fromBufferAttribute(this,e),Pe.transformDirection(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Ws(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=qt(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ws(e,this.array)),e}setX(t,e){return this.normalized&&(e=qt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ws(e,this.array)),e}setY(t,e){return this.normalized&&(e=qt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ws(e,this.array)),e}setZ(t,e){return this.normalized&&(e=qt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ws(e,this.array)),e}setW(t,e){return this.normalized&&(e=qt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array),i=qt(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t*=this.itemSize,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array),i=qt(i,this.array),n=qt(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Hd&&(t.usage=this.usage),t}}class Uq extends gs{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class $q extends gs{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class cl extends gs{constructor(t,e,s){super(new Float32Array(t),e,s)}}let jq=0;const ns=new Zt,mf=new Zs,Oo=new k,$r=new _h,uu=new _h,rr=new k;class $l extends Za{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jq++}),this.uuid=Ji(),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(t){return Array.isArray(t)?this.index=new(Nq(t)?$q:Uq)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const n=new Ns().getNormalMatrix(t);s.applyNormalMatrix(n),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return ns.makeRotationFromQuaternion(t),this.applyMatrix4(ns),this}rotateX(t){return ns.makeRotationX(t),this.applyMatrix4(ns),this}rotateY(t){return ns.makeRotationY(t),this.applyMatrix4(ns),this}rotateZ(t){return ns.makeRotationZ(t),this.applyMatrix4(ns),this}translate(t,e,s){return ns.makeTranslation(t,e,s),this.applyMatrix4(ns),this}scale(t,e,s){return ns.makeScale(t,e,s),this.applyMatrix4(ns),this}lookAt(t){return mf.lookAt(t),mf.updateMatrix(),this.applyMatrix4(mf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Oo).negate(),this.translate(Oo.x,Oo.y,Oo.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const s=[];for(let i=0,n=t.length;i<n;i++){const a=t[i];s.push(a.x,a.y,a.z||0)}this.setAttribute("position",new cl(s,3))}else{const s=Math.min(t.length,e.count);for(let i=0;i<s;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _h);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){const n=e[s];$r.setFromBufferAttribute(n),this.morphTargetsRelative?(rr.addVectors(this.boundingBox.min,$r.min),this.boundingBox.expandByPoint(rr),rr.addVectors(this.boundingBox.max,$r.max),this.boundingBox.expandByPoint(rr)):(this.boundingBox.expandByPoint($r.min),this.boundingBox.expandByPoint($r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new s0);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(t){const s=this.boundingSphere.center;if($r.setFromBufferAttribute(t),e)for(let n=0,a=e.length;n<a;n++){const o=e[n];uu.setFromBufferAttribute(o),this.morphTargetsRelative?(rr.addVectors($r.min,uu.min),$r.expandByPoint(rr),rr.addVectors($r.max,uu.max),$r.expandByPoint(rr)):($r.expandByPoint(uu.min),$r.expandByPoint(uu.max))}$r.getCenter(s);let i=0;for(let n=0,a=t.count;n<a;n++)rr.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(rr));if(e)for(let n=0,a=e.length;n<a;n++){const o=e[n],l=this.morphTargetsRelative;for(let h=0,u=o.count;h<u;h++)rr.fromBufferAttribute(o,h),l&&(Oo.fromBufferAttribute(t,h),rr.add(Oo)),i=Math.max(i,s.distanceToSquared(rr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,i=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new gs(new Float32Array(4*s.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<s.count;I++)o[I]=new k,l[I]=new k;const h=new k,u=new k,c=new k,d=new ge,p=new ge,m=new ge,f=new k,x=new k;function b(I,et,nt){h.fromBufferAttribute(s,I),u.fromBufferAttribute(s,et),c.fromBufferAttribute(s,nt),d.fromBufferAttribute(n,I),p.fromBufferAttribute(n,et),m.fromBufferAttribute(n,nt),u.sub(h),c.sub(h),p.sub(d),m.sub(d);const it=1/(p.x*m.y-m.x*p.y);isFinite(it)&&(f.copy(u).multiplyScalar(m.y).addScaledVector(c,-p.y).multiplyScalar(it),x.copy(c).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(it),o[I].add(f),o[et].add(f),o[nt].add(f),l[I].add(x),l[et].add(x),l[nt].add(x))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let I=0,et=w.length;I<et;++I){const nt=w[I],it=nt.start,vt=nt.count;for(let mt=it,Rt=it+vt;mt<Rt;mt+=3)b(t.getX(mt+0),t.getX(mt+1),t.getX(mt+2))}const S=new k,_=new k,V=new k,z=new k;function A(I){V.fromBufferAttribute(i,I),z.copy(V);const et=o[I];S.copy(et),S.sub(V.multiplyScalar(V.dot(et))).normalize(),_.crossVectors(z,et);const it=_.dot(l[I])<0?-1:1;a.setXYZW(I,S.x,S.y,S.z,it)}for(let I=0,et=w.length;I<et;++I){const nt=w[I],it=nt.start,vt=nt.count;for(let mt=it,Rt=it+vt;mt<Rt;mt+=3)A(t.getX(mt+0)),A(t.getX(mt+1)),A(t.getX(mt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new gs(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,p=s.count;d<p;d++)s.setXYZ(d,0,0,0);const i=new k,n=new k,a=new k,o=new k,l=new k,h=new k,u=new k,c=new k;if(t)for(let d=0,p=t.count;d<p;d+=3){const m=t.getX(d+0),f=t.getX(d+1),x=t.getX(d+2);i.fromBufferAttribute(e,m),n.fromBufferAttribute(e,f),a.fromBufferAttribute(e,x),u.subVectors(a,n),c.subVectors(i,n),u.cross(c),o.fromBufferAttribute(s,m),l.fromBufferAttribute(s,f),h.fromBufferAttribute(s,x),o.add(u),l.add(u),h.add(u),s.setXYZ(m,o.x,o.y,o.z),s.setXYZ(f,l.x,l.y,l.z),s.setXYZ(x,h.x,h.y,h.z)}else for(let d=0,p=e.count;d<p;d+=3)i.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),u.subVectors(a,n),c.subVectors(i,n),u.cross(c),s.setXYZ(d+0,u.x,u.y,u.z),s.setXYZ(d+1,u.x,u.y,u.z),s.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)rr.fromBufferAttribute(t,e),rr.normalize(),t.setXYZ(e,rr.x,rr.y,rr.z)}toNonIndexed(){function t(o,l){const h=o.array,u=o.itemSize,c=o.normalized,d=new h.constructor(l.length*u);let p=0,m=0;for(let f=0,x=l.length;f<x;f++){o.isInterleavedBufferAttribute?p=l[f]*o.data.stride+o.offset:p=l[f]*u;for(let b=0;b<u;b++)d[m++]=h[p++]}return new gs(d,u,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new $l,s=this.index.array,i=this.attributes;for(const o in i){const l=i[o],h=t(l,s);e.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let u=0,c=h.length;u<c;u++){const d=h[u],p=t(d,s);l.push(p)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(t[h]=l[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const l in s){const h=s[l];t.data.attributes[l]=h.toJSON(t.data)}const i={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],u=[];for(let c=0,d=h.length;c<d;c++){const p=h[c];u.push(p.toJSON(t.data))}u.length>0&&(i[l]=u,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone());const i=t.attributes;for(const h in i){const u=i[h];this.setAttribute(h,u.clone(e))}const n=t.morphAttributes;for(const h in n){const u=[],c=n[h];for(let d=0,p=c.length;d<p;d++)u.push(c[d].clone(e));this.morphAttributes[h]=u}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let h=0,u=a.length;h<u;h++){const c=a[h];this.addGroup(c.start,c.count,c.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Jb=new Zt,ga=new Vq,$c=new s0,Qb=new k,jc=new k,Wc=new k,qc=new k,ff=new k,Hc=new k,Kb=new k,Gc=new k;class Xd extends Zs{constructor(t=new $l,e=new aS){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,s=Object.keys(e);if(s.length>0){const i=e[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,a=i.length;n<a;n++){const o=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(t,e){const s=this.geometry,i=s.attributes.position,n=s.morphAttributes.position,a=s.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(n&&o){Hc.set(0,0,0);for(let l=0,h=n.length;l<h;l++){const u=o[l],c=n[l];u!==0&&(ff.fromBufferAttribute(c,t),a?Hc.addScaledVector(ff,u):Hc.addScaledVector(ff.sub(e),u))}e.add(Hc)}return e}raycast(t,e){const s=this.geometry,i=this.material,n=this.matrixWorld;i!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),$c.copy(s.boundingSphere),$c.applyMatrix4(n),ga.copy(t.ray).recast(t.near),!($c.containsPoint(ga.origin)===!1&&(ga.intersectSphere($c,Qb)===null||ga.origin.distanceToSquared(Qb)>(t.far-t.near)**2))&&(Jb.copy(n).invert(),ga.copy(t.ray).applyMatrix4(Jb),!(s.boundingBox!==null&&ga.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(t,e,ga)))}_computeIntersections(t,e,s){let i;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,h=n.attributes.uv,u=n.attributes.uv1,c=n.attributes.normal,d=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,f=d.length;m<f;m++){const x=d[m],b=a[x.materialIndex],w=Math.max(x.start,p.start),S=Math.min(o.count,Math.min(x.start+x.count,p.start+p.count));for(let _=w,V=S;_<V;_+=3){const z=o.getX(_),A=o.getX(_+1),I=o.getX(_+2);i=Xc(this,b,t,s,h,u,c,z,A,I),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=x.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),f=Math.min(o.count,p.start+p.count);for(let x=m,b=f;x<b;x+=3){const w=o.getX(x),S=o.getX(x+1),_=o.getX(x+2);i=Xc(this,a,t,s,h,u,c,w,S,_),i&&(i.faceIndex=Math.floor(x/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,f=d.length;m<f;m++){const x=d[m],b=a[x.materialIndex],w=Math.max(x.start,p.start),S=Math.min(l.count,Math.min(x.start+x.count,p.start+p.count));for(let _=w,V=S;_<V;_+=3){const z=_,A=_+1,I=_+2;i=Xc(this,b,t,s,h,u,c,z,A,I),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=x.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),f=Math.min(l.count,p.start+p.count);for(let x=m,b=f;x<b;x+=3){const w=x,S=x+1,_=x+2;i=Xc(this,a,t,s,h,u,c,w,S,_),i&&(i.faceIndex=Math.floor(x/3),e.push(i))}}}}function Wq(r,t,e,s,i,n,a,o){let l;if(t.side===Vp?l=s.intersectTriangle(a,n,i,!0,o):l=s.intersectTriangle(i,n,a,t.side===pg,o),l===null)return null;Gc.copy(o),Gc.applyMatrix4(r.matrixWorld);const h=e.ray.origin.distanceTo(Gc);return h<e.near||h>e.far?null:{distance:h,point:Gc.clone(),object:r}}function Xc(r,t,e,s,i,n,a,o,l,h){r.getVertexPosition(o,jc),r.getVertexPosition(l,Wc),r.getVertexPosition(h,qc);const u=Wq(r,t,e,s,jc,Wc,qc,Kb);if(u){const c=new k;qs.getBarycoord(Kb,jc,Wc,qc,c),i&&(u.uv=qs.getInterpolatedAttribute(i,o,l,h,c,new ge)),n&&(u.uv1=qs.getInterpolatedAttribute(n,o,l,h,c,new ge)),a&&(u.normal=qs.getInterpolatedAttribute(a,o,l,h,c,new k),u.normal.dot(s.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c:h,normal:new k,materialIndex:0};qs.getNormal(jc,Wc,qc,d.normal),u.face=d,u.barycoord=c}return u}class i0 extends $l{constructor(t=1,e=1,s=1,i=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:s,widthSegments:i,heightSegments:n,depthSegments:a};const o=this;i=Math.floor(i),n=Math.floor(n),a=Math.floor(a);const l=[],h=[],u=[],c=[];let d=0,p=0;m("z","y","x",-1,-1,s,e,t,a,n,0),m("z","y","x",1,-1,s,e,-t,a,n,1),m("x","z","y",1,1,t,s,e,i,a,2),m("x","z","y",1,-1,t,s,-e,i,a,3),m("x","y","z",1,-1,t,e,s,i,n,4),m("x","y","z",-1,-1,t,e,-s,i,n,5),this.setIndex(l),this.setAttribute("position",new cl(h,3)),this.setAttribute("normal",new cl(u,3)),this.setAttribute("uv",new cl(c,2));function m(f,x,b,w,S,_,V,z,A,I,et){const nt=_/A,it=V/I,vt=_/2,mt=V/2,Rt=z/2,Vt=A+1,Yt=I+1;let se=0,te=0;const ft=new k;for(let bt=0;bt<Yt;bt++){const Et=bt*it-mt;for(let Tr=0;Tr<Vt;Tr++){const zs=Tr*nt-vt;ft[f]=zs*w,ft[x]=Et*S,ft[b]=Rt,h.push(ft.x,ft.y,ft.z),ft[f]=0,ft[x]=0,ft[b]=z>0?1:-1,u.push(ft.x,ft.y,ft.z),c.push(Tr/A),c.push(1-bt/I),se+=1}}for(let bt=0;bt<I;bt++)for(let Et=0;Et<A;Et++){const Tr=d+Et+Vt*bt,zs=d+Et+Vt*(bt+1),Gl=d+(Et+1)+Vt*(bt+1),ei=d+(Et+1)+Vt*bt;l.push(Tr,zs,ei),l.push(zs,Gl,ei),te+=6}o.addGroup(p,te,et),p+=te,d+=se}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i0(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class oS extends Zs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Zt,this.projectionMatrix=new Zt,this.projectionMatrixInverse=new Zt,this.coordinateSystem=Wi}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const An=new k,tv=new ge,ev=new ge;class qq extends oS{constructor(t=50,e=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Gd*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Pu*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Gd*2*Math.atan(Math.tan(Pu*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,s){An.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(An.x,An.y).multiplyScalar(-t/An.z),An.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(An.x,An.y).multiplyScalar(-t/An.z)}getViewSize(t,e){return this.getViewBounds(t,tv,ev),e.subVectors(ev,tv)}setViewOffset(t,e,s,i,n,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=s,this.view.offsetY=i,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Pu*.5*this.fov)/this.zoom,s=2*e,i=this.aspect*s,n=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,h=a.fullHeight;n+=a.offsetX*i/l,e-=a.offsetY*s/h,i*=a.width/l,s*=a.height/h}const o=this.filmOffset;o!==0&&(n+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,e,e-s,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class Hq extends Rr{constructor(t=[],e=jd,s,i,n,a,o,l,h,u){super(t,e,s,i,n,a,o,l,h,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class lS{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Hd,this.updateRanges=[],this.version=0,this.uuid=Ji()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let i=0,n=this.stride;i<n;i++)this.array[t+i]=e.array[s+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ji()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ji()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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 Sr=new k;class n0{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix4(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)Sr.fromBufferAttribute(this,e),Sr.applyNormalMatrix(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)Sr.fromBufferAttribute(this,e),Sr.transformDirection(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Ws(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=qt(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ws(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ws(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ws(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ws(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array),i=qt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),s=qt(s,this.array),i=qt(i,this.array),n=qt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=n,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return new gs(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 n0(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class dl extends gs{constructor(t,e,s,i=1){super(t,e,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const gf=new k,Gq=new k,Xq=new Ns;class Yq{constructor(t=new k(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,i){return this.normal.set(t,e,s),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const i=gf.subVectors(s,e).cross(Gq.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(gf),i=this.normal.dot(s);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/i;return n<0||n>1?null:e.copy(t.start).addScaledVector(s,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Xq.getNormalMatrix(t),i=this.coplanarPoint(gf).applyMatrix4(t),n=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class uS extends Rr{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=ra,this.minFilter=ra,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ah extends Rr{constructor(t,e,s=eS,i,n,a,o=ra,l=ra,h,u=Rb,c=1){if(u!==Rb&&u!==nq)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:c};super(d,i,n,a,o,l,u,s,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new r0(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class hS extends oS{constructor(t=-1,e=1,s=1,i=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=s,this.bottom=i,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,s,i,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=s,this.view.offsetY=i,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=s-t,a=s+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,a=n+h*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(n,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class Zq extends lS{constructor(t,e,s=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class a0{constructor(t,e,s,i){a0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){const n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:KN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=KN);/**
|
|
94
|
+
* @license
|
|
95
|
+
* Copyright 2010-2025 Three.js Authors
|
|
96
|
+
* SPDX-License-Identifier: MIT
|
|
97
|
+
*/const Jq=["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"];class Qq{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=Jq,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1?(this.getRenderObjectData(t),!0):!1}needsVelocity(t){const e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){const{geometry:s,material:i,object:n}=t;if(e={material:this.getMaterialData(i),geometry:{id:s.id,attributes:this.getAttributesData(s.attributes),indexVersion:s.index?s.index.version:null,drawRange:{start:s.drawRange.start,count:s.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(e.center=n.center.clone()),n.morphTargetInfluences&&(e.morphTargetInfluences=n.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),e.material.transmission>0){const{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}this.renderObjects.set(t,e)}return e}getAttributesData(t){const e={};for(const s in t){const i=t[s];e[s]={version:i.version}}return e}containsNode(t){const e=t.material;for(const s in e)if(e[s]&&e[s].isNode)return!0;return t.renderer.overrideNodes.modelViewMatrix!==null||t.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(t){const e={};for(const s of this.refreshUniforms){const i=t[s];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?e[s]={id:i.id,version:i.version}:e[s]=i.clone():e[s]=i)}return e}equals(t){const{object:e,material:s,geometry:i}=t,n=this.getRenderObjectData(t);if(n.worldMatrix.equals(e.matrixWorld)!==!0)return n.worldMatrix.copy(e.matrixWorld),!1;const a=n.material;for(const f in a){const x=a[f],b=s[f];if(x.equals!==void 0){if(x.equals(b)===!1)return x.copy(b),!1}else if(b.isTexture===!0){if(x.id!==b.id||x.version!==b.version)return x.id=b.id,x.version=b.version,!1}else if(x!==b)return a[f]=b,!1}if(a.transmission>0){const{width:f,height:x}=t.context;if(n.bufferWidth!==f||n.bufferHeight!==x)return n.bufferWidth=f,n.bufferHeight=x,!1}const o=n.geometry,l=i.attributes,h=o.attributes,u=Object.keys(h),c=Object.keys(l);if(o.id!==i.id)return o.id=i.id,!1;if(u.length!==c.length)return n.geometry.attributes=this.getAttributesData(l),!1;for(const f of u){const x=h[f],b=l[f];if(b===void 0)return delete h[f],!1;if(x.version!==b.version)return x.version=b.version,!1}const d=i.index,p=o.indexVersion,m=d?d.version:null;if(p!==m)return o.indexVersion=m,!1;if(o.drawRange.start!==i.drawRange.start||o.drawRange.count!==i.drawRange.count)return o.drawRange.start=i.drawRange.start,o.drawRange.count=i.drawRange.count,!1;if(n.morphTargetInfluences){let f=!1;for(let x=0;x<n.morphTargetInfluences.length;x++)n.morphTargetInfluences[x]!==e.morphTargetInfluences[x]&&(f=!0);if(f)return!0}return n.center&&n.center.equals(e.center)===!1?(n.center.copy(e.center),!0):(t.bundle!==null&&(n.version=t.bundle.version),!0)}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;const{renderId:s}=e;if(this.renderId!==s)return this.renderId=s,!0;const i=t.object.static===!0,n=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;return i||n?!1:this.equals(t)!==!0}}function Ku(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const Kq=r=>Ku(r),cS=r=>Ku(r),dS=(...r)=>Ku(r);function pS(r,t=!1){const e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(const{property:s,childNode:i}of Yd(r))e.push(Ku(s.slice(0,-4)),i.getCacheKey(t));return Ku(e)}function*Yd(r,t=!1){for(const e in r){if(e.startsWith("_")===!0)continue;const s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){const n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(const i in s){const n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}const tH=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),rv=new WeakMap;function eH(r){return tH.get(r)}function Zd(r){if(/[iu]?vec\d/.test(r))return r.startsWith("ivec")?Int32Array:r.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(r)||/float/.test(r))return Float32Array;if(/uint/.test(r))return Uint32Array;if(/int/.test(r))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${r}`)}function mS(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 9;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function rH(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 12;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function sH(r){if(/float|int|uint/.test(r))return 4;if(/vec2/.test(r))return 8;if(/vec3/.test(r)||/vec4/.test(r))return 16;if(/mat2/.test(r))return 8;if(/mat3/.test(r))return 48;if(/mat4/.test(r))return 64;console.error("THREE.TSL: Unsupported type:",r)}function Un(r){if(r==null)return null;const t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function fS(r,...t){const e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new dn(...t):e==="vec2"?new ge(...t):e==="vec3"?new k(...t):e==="vec4"?new Mr(...t):e==="mat2"?new a0(...t):e==="mat3"?new Ns(...t):e==="mat4"?new Zt(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?xS(t[0]):null}function gS(r){let t=rv.get(r);return t===void 0&&(t={},rv.set(r,t)),t}function yS(r){let t="";const e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function xS(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}const Au={VERTEX:"vertex",FRAGMENT:"fragment"},$t={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},iH={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ai={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},bS=["fragment","vertex"],nH=["setup","analyze","generate"],aH=[...bS,"compute"],jl=["x","y","z","w"],oH={analyze:"setup",generate:"analyze"};let lH=0;class ot extends Za{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=$t.NONE,this.updateBeforeType=$t.NONE,this.updateAfterType=$t.NONE,this.uuid=iS.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:lH++})}set needsUpdate(t){t===!0&&this.version++}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this.getSelf()),this}onFrameUpdate(t){return this.onUpdate(t,$t.FRAME)}onRenderUpdate(t){return this.onUpdate(t,$t.RENDER)}onObjectUpdate(t){return this.onUpdate(t,$t.OBJECT)}onReference(t){return this.updateReference=t.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:t}of Yd(this))yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(const e of this.getChildren())e.traverse(t)}getCacheKey(t=!1){return t=t||this.version!==this._cacheKeyVersion,(t===!0||this._cacheKey===null)&&(this._cacheKey=dS(pS(this,t),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(t){const e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t){const e=t.getNodeProperties(this);return e.outputNode?e.outputNode.getNodeType(t):this.nodeType}getShared(t){const e=this.getHash(t);return t.getNodeFromHash(e)||this}setup(t){const e=t.getNodeProperties(this);let s=0;for(const i of this.getChildren())e["node"+s++]=i;return e.outputNode||null}analyze(t,e=null){const s=t.increaseUsage(this);if(this.parents===!0){const i=t.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[t.shaderStage]=i.stages[t.shaderStage]||[],i.stages[t.shaderStage].push(e)}if(s===1){const i=t.getNodeProperties(this);for(const n of Object.values(i))n&&n.isNode===!0&&n.build(t,this)}}generate(t,e){const{outputNode:s}=t.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(t,e)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(t,e=null){const s=this.getShared(t);if(this!==s)return s.build(t,e);const i=t.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[t.buildStage]=!0;const n=oH[t.buildStage];if(n&&i.buildStages[n]!==!0){const l=t.getBuildStage();t.setBuildStage(n),this.build(t),t.setBuildStage(l)}t.addNode(this),t.addChain(this);let a=null;const o=t.getBuildStage();if(o==="setup"){this.updateReference(t);const l=t.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(t)||l.outputNode||null;for(const h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){const u=t.getNodeProperties(h);u.parents=u.parents||[],u.parents.push(this)}h.build(t)}}a=l.outputNode}else if(o==="analyze")this.analyze(t,e);else if(o==="generate")if(this.generate.length===1){const h=this.getNodeType(t),u=t.getDataFromNode(this);a=u.snippet,a===void 0?u.generated===void 0?(u.generated=!0,a=this.generate(t)||"",u.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):u.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),a=t.format(a,h,e)}else a=this.generate(t,e)||"";return t.removeChain(this),t.addSequentialNode(this),a}getSerializeChildren(){return Yd(this)}serialize(t){const e=this.getSerializeChildren(),s={};for(const{property:i,index:n,childNode:a}of e)n!==void 0?(s[i]===void 0&&(s[i]=Number.isInteger(n)?[]:{}),s[i][n]=a.toJSON(t.meta).uuid):s[i]=a.toJSON(t.meta).uuid;Object.keys(s).length>0&&(t.inputNodes=s)}deserialize(t){if(t.inputNodes!==void 0){const e=t.meta.nodes;for(const s in t.inputNodes)if(Array.isArray(t.inputNodes[s])){const i=[];for(const n of t.inputNodes[s])i.push(e[n]);this[s]=i}else if(typeof t.inputNodes[s]=="object"){const i={};for(const n in t.inputNodes[s]){const a=t.inputNodes[s][n];i[n]=e[a]}this[s]=i}else{const i=t.inputNodes[s];this[s]=e[i]}}}toJSON(t){const{uuid:e,type:s}=this,i=t===void 0||typeof t=="string";i&&(t={textures:{},images:{},nodes:{}});let n=t.nodes[e];n===void 0&&(n={uuid:e,type:s,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(t.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}if(i){const o=a(t.textures),l=a(t.images),h=a(t.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}}class Qa extends ot{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}getNodeType(t){return this.node.getElementType(t)}generate(t){const e=this.indexNode.getNodeType(t),s=this.node.build(t),i=this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint");return`${s}[ ${i} ]`}}class vS extends ot{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}getNodeType(t){const e=this.node.getNodeType(t);let s=null;for(const i of this.convertTo.split("|"))(s===null||t.getTypeLength(e)===t.getTypeLength(i))&&(s=i);return s}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){const s=this.node,i=this.getNodeType(t),n=s.build(t,i);return t.format(n,i,e)}}class Re extends ot{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){const i=t.getVectorType(this.getNodeType(t,e)),n=t.getDataFromNode(this);if(n.propertyName!==void 0)return t.format(n.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){const a=super.build(t,i),o=t.getVarFromNode(this,null,i),l=t.getPropertyName(o);return t.addLineFlowCode(`${l} = ${a}`,this),n.snippet=a,n.propertyName=l,t.format(n.propertyName,i,e)}}return super.build(t,e)}}class uH extends Re{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}getNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,s)=>e+t.getTypeLength(s.getNodeType(t)),0))}generate(t,e){const s=this.getNodeType(t),i=t.getTypeLength(s),n=this.nodes,a=t.getComponentType(s),o=[];let l=0;for(const u of n){if(l>=i){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${s}()' type.`);break}let c=u.getNodeType(t),d=t.getTypeLength(c),p;l+d>i&&(console.error(`THREE.TSL: Length of '${s}()' data exceeds maximum length of output type.`),d=i-l,c=t.getTypeFromLength(d)),l+=d,p=u.build(t,c);const m=t.getComponentType(c);m!==a&&(p=t.format(p,m,a)),o.push(p)}const h=`${t.getType(s)}( ${o.join(", ")} )`;return t.format(h,s,e)}}const hH=jl.join("");class xg extends ot{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(const e of this.components)t=Math.max(jl.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}getNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}generate(t,e){const s=this.node,i=t.getTypeLength(s.getNodeType(t));let n=null;if(i>1){let a=null;this.getVectorLength()>=i&&(a=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));const l=s.build(t,a);this.components.length===i&&this.components===hH.slice(0,this.components.length)?n=t.format(l,a,e):n=t.format(`${l}.${this.components}`,this.getNodeType(t),e)}else n=s.build(t,e);return n}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}}class cH extends Re{static get type(){return"SetNode"}constructor(t,e,s){super(),this.sourceNode=t,this.components=e,this.targetNode=s}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{sourceNode:e,components:s,targetNode:i}=this,n=this.getNodeType(t),a=t.getComponentType(i.getNodeType(t)),o=t.getTypeFromLength(s.length,a),l=i.build(t,o),h=e.build(t,n),u=t.getTypeLength(n),c=[];for(let d=0;d<u;d++){const p=jl[d];p===s[0]?(c.push(l),d+=s.length-1):c.push(h+"."+p)}return`${t.getType(n)}( ${c.join(", ")} )`}}class dH extends Re{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){const{components:e,sourceNode:s}=this,i=this.getNodeType(t),n=s.build(t),a=t.getVarFromNode(this),o=t.getPropertyName(a);t.addLineFlowCode(o+" = "+n,this);const l=t.getTypeLength(i),h=[];let u=0;for(let c=0;c<l;c++){const d=jl[c];d===e[u]?(h.push("1.0 - "+(o+"."+d)),u++):h.push(o+"."+d)}return`${t.getType(i)}( ${h.join(", ")} )`}}class o0 extends ot{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}getNodeType(){return this.nodeType===null?Un(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Un(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=yS(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?fS(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){console.warn("Abstract function.")}}const sv=/float|u?int/;class Ks extends o0{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){const s=this.getNodeType(t);return sv.test(s)&&sv.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),s,e)}}class pH extends ot{static get type(){return"MemberNode"}constructor(t,e){super(),this.node=t,this.property=e,this.isMemberNode=!0}getNodeType(t){return this.node.getMemberType(t,this.property)}generate(t){return this.node.build(t)+"."+this.property}}let Wa=null;const Ko=new Map;function $(r,t){if(Ko.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw new Error(`THREE.TSL: Node element ${r} is not a function`);Ko.set(r,t)}const wS=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),iv=r=>wS(r).split("").sort().join(""),MS={setup(r,t){const e=t.shift();return r(zh(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(Wa.assign(e,...s),e);if(Ko.has(t)){const s=Ko.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&Ko.has(t.slice(0,t.length-6))){const s=Ko.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=wS(t),q(new xg(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=iv(t.slice(3).toLowerCase()),s=>q(new cH(r,t,q(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=iv(t.slice(4).toLowerCase()),()=>q(new dH(q(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),q(new xg(r,t));if(/^\d+$/.test(t)===!0)return q(new Qa(e,new Ks(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>q(new pH(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},yf=new WeakMap,nv=new WeakMap,mH=function(r,t=null){const e=Un(r);if(e==="node"){let s=yf.get(r);return s===void 0&&(s=new Proxy(r,MS),yf.set(r,s),yf.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return q(bg(r,t));if(e==="shader")return L(r)}return r},fH=function(r,t=null){for(const e in r)r[e]=q(r[e],t);return r},gH=function(r,t=null){const e=r.length;for(let s=0;s<e;s++)r[s]=q(r[s],t);return r},yH=function(r,t=null,e=null,s=null){const i=u=>q(s!==null?Object.assign(u,s):u);let n,a=t,o,l;function h(u){let c;return a?c=/[a-z]/i.test(a)?a+"()":a:c=r.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(new Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return t===null?n=(...u)=>i(new r(...Pa(h(u)))):e!==null?(e=q(e),n=(...u)=>i(new r(t,...Pa(h(u)),e))):n=(...u)=>i(new r(t,...Pa(h(u)))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n},xH=function(r,...t){return q(new r(...Pa(t)))};class bH extends ot{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){const{shaderNode:e,inputNodes:s}=this,i=t.getNodeProperties(e),n=e.namespace&&e.namespace===t.namespace?t.getNamespace("once"):"once";if(i[n])return i[n];let a=null;if(e.layout){let o=nv.get(t.constructor);o===void 0&&(o=new WeakMap,nv.set(t.constructor,o));let l=o.get(e);l===void 0&&(l=q(t.buildFunctionNode(e)),o.set(e,l)),t.addInclude(l),a=q(l.call(s))}else{const o=e.jsFunc,l=s!==null||o.length>1?o(s||[],t):o(t);a=q(l)}return e.once&&(i[n]=a),a}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){const e=t.getNodeProperties(this),s=t.getOutputNamespace();return e[s]=e[s]||this.setupOutput(t),e[s]}build(t,e=null){let s=null;const i=t.getBuildStage(),n=t.getNodeProperties(this),a=t.getOutputNamespace(),o=this.getOutputNode(t);if(i==="setup"){const l=t.getNamespace("initialized");n[l]!==!0&&(n[l]=!0,n[a]=this.getOutputNode(t),n[a].build(t)),s=n[a]}else i==="analyze"?o.build(t,e):i==="generate"&&(s=o.build(t,e)||"");return s}}class vH extends ot{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(t){return this.layout=t,this}call(t=null){return zh(t),q(new bH(this,t))}setup(){return this.call()}}const wH=[!1,!0],MH=[0,1,2,3],TH=[-1,-2],TS=[.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],l0=new Map;for(const r of wH)l0.set(r,new Ks(r));const u0=new Map;for(const r of MH)u0.set(r,new Ks(r,"uint"));const h0=new Map([...u0].map(r=>new Ks(r.value,"int")));for(const r of TH)h0.set(r,new Ks(r,"int"));const Rp=new Map([...h0].map(r=>new Ks(r.value)));for(const r of TS)Rp.set(r,new Ks(r));for(const r of TS)Rp.set(-r,new Ks(-r));const Lp={bool:l0,uint:u0,ints:h0,float:Rp},av=new Map([...l0,...Rp]),bg=(r,t)=>av.has(r)?av.get(r):r.isNode===!0?r:new Ks(r,t),NH=r=>{try{return r.getNodeType()}catch{return}},Ue=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[fS(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return q(t.get(e[0]));if(e.length===1){const i=bg(e[0],r);return NH(i)===r?q(i):q(new vS(i,r))}const s=e.map(i=>bg(i));return q(new uH(s,r))}},th=r=>typeof r=="object"&&r!==null?r.value:r,NS=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function tl(r,t){return new Proxy(new vH(r,t),MS)}const q=(r,t=null)=>mH(r,t),zh=(r,t=null)=>new fH(r,t),Pa=(r,t=null)=>new gH(r,t),G=(...r)=>new yH(...r),K=(...r)=>new xH(...r);let SH=0;const L=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new tl(r,e),i=(...n)=>{let a;zh(n),n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?a=[...n]:a=n[0];const l=s.call(a);return e==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),t!==null){if(typeof t.inputs!="object"){const n={name:"fn"+SH++,type:e,inputs:[]};for(const a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i},vg=r=>{Wa=r},SS=()=>Wa,wt=(...r)=>Wa.If(...r),_H=(...r)=>Wa.Switch(...r);function Ip(r){return Wa&&Wa.add(r),r}$("toStack",Ip);const _S=new Ue("color"),M=new Ue("float",Lp.float),N=new Ue("int",Lp.ints),st=new Ue("uint",Lp.uint),xi=new Ue("bool",Lp.bool),Z=new Ue("vec2"),Ze=new Ue("ivec2"),AS=new Ue("uvec2"),zS=new Ue("bvec2"),P=new Ue("vec3"),CS=new Ue("ivec3"),Wl=new Ue("uvec3"),c0=new Ue("bvec3"),pt=new Ue("vec4"),ES=new Ue("ivec4"),VS=new Ue("uvec4"),RS=new Ue("bvec4"),Pp=new Ue("mat2"),bs=new Ue("mat3"),Fa=new Ue("mat4"),AH=(r="")=>q(new Ks(r,"string")),zH=r=>q(new Ks(r,"ArrayBuffer"));$("toColor",_S);$("toFloat",M);$("toInt",N);$("toUint",st);$("toBool",xi);$("toVec2",Z);$("toIVec2",Ze);$("toUVec2",AS);$("toBVec2",zS);$("toVec3",P);$("toIVec3",CS);$("toUVec3",Wl);$("toBVec3",c0);$("toVec4",pt);$("toIVec4",ES);$("toUVec4",VS);$("toBVec4",RS);$("toMat2",Pp);$("toMat3",bs);$("toMat4",Fa);const LS=G(Qa).setParameterLength(2),IS=(r,t)=>q(new vS(q(r),t)),CH=(r,t)=>q(new xg(q(r),t));$("element",LS);$("convert",IS);const EH=r=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),Ip(r));$("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),Ip(r)));const VH=(...r)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),L(...r));class Ot extends ot{static get type(){return"PropertyNode"}constructor(t,e=null,s=!1){super(t),this.name=e,this.varying=s,this.isPropertyNode=!0,this.global=!0}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}}const ql=(r,t)=>q(new Ot(r,t)),eh=(r,t)=>q(new Ot(r,t,!0)),os=K(Ot,"vec4","DiffuseColor"),wg=K(Ot,"vec3","EmissiveColor"),PS=K(Ot,"float","Roughness"),RH=K(Ot,"float","Metalness"),LH=K(Ot,"float","Clearcoat"),IH=K(Ot,"float","ClearcoatRoughness"),PH=K(Ot,"vec3","Sheen"),FH=K(Ot,"float","SheenRoughness"),FS=K(Ot,"float","Iridescence"),OH=K(Ot,"float","IridescenceIOR"),BH=K(Ot,"float","IridescenceThickness"),Mg=K(Ot,"float","AlphaT"),OS=K(Ot,"float","Anisotropy"),vd=K(Ot,"vec3","AnisotropyT"),pl=K(Ot,"vec3","AnisotropyB"),kH=K(Ot,"color","SpecularColor"),DH=K(Ot,"float","SpecularF90"),UH=K(Ot,"float","Shininess"),ml=K(Ot,"vec4","Output"),$H=K(Ot,"float","dashSize"),jH=K(Ot,"float","gapSize"),WH=K(Ot,"float","pointWidth"),qH=K(Ot,"float","IOR"),HH=K(Ot,"float","Transmission"),GH=K(Ot,"float","Thickness"),XH=K(Ot,"float","AttenuationDistance"),YH=K(Ot,"color","AttenuationColor"),ZH=K(Ot,"float","Dispersion");class BS extends ot{static get type(){return"UniformGroupNode"}constructor(t,e=!1,s=1){super("string"),this.name=t,this.shared=e,this.order=s,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}}const kS=r=>new BS(r),Fp=(r,t=0)=>new BS(r,!0,t),JH=Fp("frame"),Nt=Fp("render"),DS=kS("object");class Ch extends o0{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=DS}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){const s=this.getSelf();return t=t.bind(s),super.onUpdate(i=>{const n=t(i,s);n!==void 0&&(this.value=n)},e)}generate(t,e){const s=this.getNodeType(t),i=this.getUniformHash(t);let n=t.getNodeFromHash(i);n===void 0&&(t.setHashNode(this,i),n=this);const a=n.getInputType(t),o=t.getUniformFromNode(n,a,t.shaderStage,this.name||t.context.label),l=t.getPropertyName(o);return t.context.label!==void 0&&delete t.context.label,t.format(l,s,e)}}const dt=(r,t)=>{const e=NS(t||r),s=r&&r.isNode===!0?r.node&&r.node.value||r.value:r;return q(new Ch(s,e))};class ov extends Re{static get type(){return"ArrayNode"}constructor(t,e,s=null){super(t),this.count=e,this.values=s,this.isArrayNode=!0}getNodeType(t){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(t)),this.nodeType}getElementType(t){return this.getNodeType(t)}generate(t){const e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}}const US=(...r)=>{let t;if(r.length===1){const e=r[0];t=new ov(null,e.length,e)}else{const e=r[0],s=r[1];t=new ov(e,s)}return q(t)};$("toArray",(r,t)=>US(Array(t).fill(r)));class QH extends Re{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){const{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){const s=t.getTypeLength(e.node.getNodeType(t));return jl.join("").slice(0,s)!==e.components}return!1}setup(t){const{targetNode:e,sourceNode:s}=this,i=t.getNodeProperties(this);i.sourceNode=s,i.targetNode=e.context({assign:!0})}generate(t,e){const{targetNode:s,sourceNode:i}=t.getNodeProperties(this),n=this.needsSplitAssign(t),a=s.getNodeType(t),o=s.build(t),l=i.build(t,a),h=i.getNodeType(t),u=t.getDataFromNode(this);let c;if(u.initialized===!0)e!=="void"&&(c=o);else if(n){const d=t.getVarFromNode(this,null,a),p=t.getPropertyName(d);t.addLineFlowCode(`${p} = ${l}`,this);const m=s.node,x=m.node.context({assign:!0}).build(t);for(let b=0;b<m.components.length;b++){const w=m.components[b];t.addLineFlowCode(`${x}.${w} = ${p}[ ${b} ]`,this)}e!=="void"&&(c=o)}else c=`${o} = ${l}`,(e==="void"||h==="void")&&(t.addLineFlowCode(c,this),e!=="void"&&(c=o));return u.initialized=!0,t.format(c,a,e)}}const $S=G(QH).setParameterLength(2);$("assign",$S);class KH extends Re{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){const e=[],s=this.functionNode,i=s.getInputs(t),n=this.parameters,a=(l,h)=>{const u=h.type,c=u==="pointer";let d;return c?d="&"+l.build(t):d=l.build(t,u),d};if(Array.isArray(n)){if(n.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=i.length;else if(n.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<i.length;)n.push(M(0));for(let l=0;l<n.length;l++)e.push(a(n[l],i[l]))}else for(const l of i){const h=n[l.name];h!==void 0?e.push(a(h,l)):(console.error(`THREE.TSL: Input '${l.name}' not found in 'Fn()'.`),e.push(a(M(0),l)))}return`${s.build(t,"property")}( ${e.join(", ")} )`}}const jS=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Pa(t):zh(t[0]),q(new KH(q(r),t)));$("call",jS);const tG={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ce extends Re{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new ce(t,e,s);for(let a=0;a<i.length-1;a++)n=new ce(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(tG[this.op],e)}getNodeType(t){const e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){const o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){const s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t);let o=null,l=null;a!=="void"?(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):t.isMatrix(l)?o==="float"?o="float":t.isVector(o)?o=t.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){const d=t.renderer.coordinateSystem===Wi;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d?t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}}const Ee=G(ce,"+").setParameterLength(2,1/0).setName("add"),Ct=G(ce,"-").setParameterLength(2,1/0).setName("sub"),yt=G(ce,"*").setParameterLength(2,1/0).setName("mul"),bi=G(ce,"/").setParameterLength(2,1/0).setName("div"),Eh=G(ce,"%").setParameterLength(2).setName("mod"),d0=G(ce,"==").setParameterLength(2).setName("equal"),WS=G(ce,"!=").setParameterLength(2).setName("notEqual"),qS=G(ce,"<").setParameterLength(2).setName("lessThan"),p0=G(ce,">").setParameterLength(2).setName("greaterThan"),HS=G(ce,"<=").setParameterLength(2).setName("lessThanEqual"),GS=G(ce,">=").setParameterLength(2).setName("greaterThanEqual"),XS=G(ce,"&&").setParameterLength(2,1/0).setName("and"),YS=G(ce,"||").setParameterLength(2,1/0).setName("or"),ZS=G(ce,"!").setParameterLength(1).setName("not"),JS=G(ce,"^^").setParameterLength(2).setName("xor"),QS=G(ce,"&").setParameterLength(2).setName("bitAnd"),KS=G(ce,"~").setParameterLength(2).setName("bitNot"),t_=G(ce,"|").setParameterLength(2).setName("bitOr"),e_=G(ce,"^").setParameterLength(2).setName("bitXor"),r_=G(ce,"<<").setParameterLength(2).setName("shiftLeft"),s_=G(ce,">>").setParameterLength(2).setName("shiftRight"),i_=L(([r])=>(r.addAssign(1),r)),n_=L(([r])=>(r.subAssign(1),r)),a_=L(([r])=>{const t=N(r).toConst();return r.addAssign(1),t}),o_=L(([r])=>{const t=N(r).toConst();return r.subAssign(1),t});$("add",Ee);$("sub",Ct);$("mul",yt);$("div",bi);$("mod",Eh);$("equal",d0);$("notEqual",WS);$("lessThan",qS);$("greaterThan",p0);$("lessThanEqual",HS);$("greaterThanEqual",GS);$("and",XS);$("or",YS);$("not",ZS);$("xor",JS);$("bitAnd",QS);$("bitNot",KS);$("bitOr",t_);$("bitXor",e_);$("shiftLeft",r_);$("shiftRight",s_);$("incrementBefore",i_);$("decrementBefore",n_);$("increment",a_);$("decrement",o_);const l_=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Eh(r,t)),u_=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Eh(N(r),N(t)));$("remainder",l_);$("modInt",u_);class R extends Re{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===R.MAX||t===R.MIN)&&arguments.length>3){let n=new R(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new R(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){const e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){const e=this.method;return e===R.LENGTH||e===R.DISTANCE||e===R.DOT?"float":e===R.CROSS?"vec3":e===R.ALL||e===R.ANY?"bool":e===R.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){const{aNode:e,bNode:s,method:i}=this;let n=null;if(i===R.ONE_MINUS)n=Ct(1,e);else if(i===R.RECIPROCAL)n=bi(1,e);else if(i===R.DIFFERENCE)n=Qt(Ct(e,s));else if(i===R.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=pt(P(o),0):a=pt(P(a),0);const l=yt(a,o).xyz;n=Ka(l)}return n!==null?n:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method;const n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===R.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{const c=[];return i===R.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Wi&&i===R.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Wi&&(i===R.MIN||i===R.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===R.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===R.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===ja&&i===R.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===R.DFDX||i===R.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}R.ALL="all";R.ANY="any";R.RADIANS="radians";R.DEGREES="degrees";R.EXP="exp";R.EXP2="exp2";R.LOG="log";R.LOG2="log2";R.SQRT="sqrt";R.INVERSE_SQRT="inversesqrt";R.FLOOR="floor";R.CEIL="ceil";R.NORMALIZE="normalize";R.FRACT="fract";R.SIN="sin";R.COS="cos";R.TAN="tan";R.ASIN="asin";R.ACOS="acos";R.ATAN="atan";R.ABS="abs";R.SIGN="sign";R.LENGTH="length";R.NEGATE="negate";R.ONE_MINUS="oneMinus";R.DFDX="dFdx";R.DFDY="dFdy";R.ROUND="round";R.RECIPROCAL="reciprocal";R.TRUNC="trunc";R.FWIDTH="fwidth";R.TRANSPOSE="transpose";R.BITCAST="bitcast";R.EQUALS="equals";R.MIN="min";R.MAX="max";R.STEP="step";R.REFLECT="reflect";R.DISTANCE="distance";R.DIFFERENCE="difference";R.DOT="dot";R.CROSS="cross";R.POW="pow";R.TRANSFORM_DIRECTION="transformDirection";R.MIX="mix";R.CLAMP="clamp";R.REFRACT="refract";R.SMOOTHSTEP="smoothstep";R.FACEFORWARD="faceforward";const h_=M(1e-6),eG=M(1e6),Jd=M(Math.PI),rG=M(Math.PI*2),c_=G(R,R.ALL).setParameterLength(1),d_=G(R,R.ANY).setParameterLength(1),p_=G(R,R.RADIANS).setParameterLength(1),m_=G(R,R.DEGREES).setParameterLength(1),f_=G(R,R.EXP).setParameterLength(1),Il=G(R,R.EXP2).setParameterLength(1),m0=G(R,R.LOG).setParameterLength(1),Ki=G(R,R.LOG2).setParameterLength(1),Ai=G(R,R.SQRT).setParameterLength(1),f0=G(R,R.INVERSE_SQRT).setParameterLength(1),di=G(R,R.FLOOR).setParameterLength(1),Op=G(R,R.CEIL).setParameterLength(1),Ka=G(R,R.NORMALIZE).setParameterLength(1),pn=G(R,R.FRACT).setParameterLength(1),Yr=G(R,R.SIN).setParameterLength(1),Ui=G(R,R.COS).setParameterLength(1),g_=G(R,R.TAN).setParameterLength(1),y_=G(R,R.ASIN).setParameterLength(1),x_=G(R,R.ACOS).setParameterLength(1),g0=G(R,R.ATAN).setParameterLength(1,2),Qt=G(R,R.ABS).setParameterLength(1),rh=G(R,R.SIGN).setParameterLength(1),Qd=G(R,R.LENGTH).setParameterLength(1),b_=G(R,R.NEGATE).setParameterLength(1),v_=G(R,R.ONE_MINUS).setParameterLength(1),y0=G(R,R.DFDX).setParameterLength(1),x0=G(R,R.DFDY).setParameterLength(1),w_=G(R,R.ROUND).setParameterLength(1),M_=G(R,R.RECIPROCAL).setParameterLength(1),b0=G(R,R.TRUNC).setParameterLength(1),T_=G(R,R.FWIDTH).setParameterLength(1),N_=G(R,R.TRANSPOSE).setParameterLength(1),sG=G(R,R.BITCAST).setParameterLength(2),S_=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),d0(r,t)),vs=G(R,R.MIN).setParameterLength(2,1/0),Ke=G(R,R.MAX).setParameterLength(2,1/0),Bp=G(R,R.STEP).setParameterLength(2),__=G(R,R.REFLECT).setParameterLength(2),A_=G(R,R.DISTANCE).setParameterLength(2),z_=G(R,R.DIFFERENCE).setParameterLength(2),aa=G(R,R.DOT).setParameterLength(2),kp=G(R,R.CROSS).setParameterLength(2),Ys=G(R,R.POW).setParameterLength(2),C_=G(R,R.POW,2).setParameterLength(1),E_=G(R,R.POW,3).setParameterLength(1),V_=G(R,R.POW,4).setParameterLength(1),R_=G(R,R.TRANSFORM_DIRECTION).setParameterLength(2),L_=r=>yt(rh(r),Ys(Qt(r),1/3)),v0=r=>aa(r,r),Ne=G(R,R.MIX).setParameterLength(3),on=(r,t=0,e=1)=>q(new R(R.CLAMP,q(r),q(t),q(e))),I_=r=>on(r),P_=G(R,R.REFRACT).setParameterLength(3),qa=G(R,R.SMOOTHSTEP).setParameterLength(3),w0=G(R,R.FACEFORWARD).setParameterLength(3),F_=L(([r])=>{const s=43758.5453,i=aa(r.xy,Z(12.9898,78.233)),n=Eh(i,Jd);return pn(Yr(n).mul(s))}),O_=(r,t,e)=>Ne(t,e,r),B_=(r,t,e)=>qa(t,e,r),k_=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),g0(r,t)),iG=w0,nG=f0;$("all",c_);$("any",d_);$("equals",S_);$("radians",p_);$("degrees",m_);$("exp",f_);$("exp2",Il);$("log",m0);$("log2",Ki);$("sqrt",Ai);$("inverseSqrt",f0);$("floor",di);$("ceil",Op);$("normalize",Ka);$("fract",pn);$("sin",Yr);$("cos",Ui);$("tan",g_);$("asin",y_);$("acos",x_);$("atan",g0);$("abs",Qt);$("sign",rh);$("length",Qd);$("lengthSq",v0);$("negate",b_);$("oneMinus",v_);$("dFdx",y0);$("dFdy",x0);$("round",w_);$("reciprocal",M_);$("trunc",b0);$("fwidth",T_);$("atan2",k_);$("min",vs);$("max",Ke);$("step",Bp);$("reflect",__);$("distance",A_);$("dot",aa);$("cross",kp);$("pow",Ys);$("pow2",C_);$("pow3",E_);$("pow4",V_);$("transformDirection",R_);$("mix",O_);$("clamp",on);$("refract",P_);$("smoothstep",B_);$("faceForward",w0);$("difference",z_);$("saturate",I_);$("cbrt",L_);$("transpose",N_);$("rand",F_);class aG extends ot{static get type(){return"ConditionalNode"}constructor(t,e,s=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=s}getNodeType(t){const{ifNode:e,elseNode:s}=t.getNodeProperties(this);if(e===void 0)return this.setup(t),this.getNodeType(t);const i=e.getNodeType(t);if(s!==null){const n=s.getNodeType(t);if(t.getTypeLength(n)>t.getTypeLength(i))return n}return i}setup(t){const e=this.condNode.cache(),s=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,n=t.context.nodeBlock;t.getDataFromNode(s).parentNodeBlock=n,i!==null&&(t.getDataFromNode(i).parentNodeBlock=n);const a=t.getNodeProperties(this);a.condNode=e,a.ifNode=s.context({nodeBlock:s}),a.elseNode=i?i.context({nodeBlock:i}):null}generate(t,e){const s=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:n,ifNode:a,elseNode:o}=t.getNodeProperties(this),l=t.currentFunctionNode,h=e!=="void",u=h?ql(s).build(t):"";i.nodeProperty=u;const c=n.build(t,"bool");t.addFlowCode(`
|
|
98
|
+
${t.tab}if ( ${c} ) {
|
|
99
|
+
|
|
100
|
+
`).addFlowTab();let d=a.build(t,s);if(d&&(h?d=u+" = "+d+";":(d="return "+d+";",l===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),d="// "+d))),t.removeFlowTab().addFlowCode(t.tab+" "+d+`
|
|
101
|
+
|
|
102
|
+
`+t.tab+"}"),o!==null){t.addFlowCode(` else {
|
|
103
|
+
|
|
104
|
+
`).addFlowTab();let p=o.build(t,s);p&&(h?p=u+" = "+p+";":(p="return "+p+";",l===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),p="// "+p))),t.removeFlowTab().addFlowCode(t.tab+" "+p+`
|
|
105
|
+
|
|
106
|
+
`+t.tab+`}
|
|
107
|
+
|
|
108
|
+
`)}else t.addFlowCode(`
|
|
109
|
+
|
|
110
|
+
`);return t.format(u,s,e)}}const xr=G(aG).setParameterLength(2,3);$("select",xr);const D_=(...r)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),xr(...r));$("cond",D_);class U_ extends ot{static get type(){return"ContextNode"}constructor(t,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}analyze(t){const e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}setup(t){const e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}generate(t,e){const s=t.getContext();t.setContext({...t.context,...this.value});const i=this.node.build(t,e);return t.setContext(s),i}}const M0=G(U_).setParameterLength(1,2),$_=(r,t)=>M0(r,{label:t});$("context",M0);$("label",$_);class oG extends ot{static get type(){return"VarNode"}constructor(t,e=null,s=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=s,this.parents=!0}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}getNodeType(t){return this.node.getNodeType(t)}generate(t){const{node:e,name:s,readOnly:i}=this,{renderer:n}=t,a=n.backend.isWebGPUBackend===!0;let o=!1,l=!1;i&&(o=t.isDeterministic(e),l=a?i:o);const h=t.getVectorType(this.getNodeType(t)),u=e.build(t,h),c=t.getVarFromNode(this,s,h,void 0,l),d=t.getPropertyName(c);let p=d;if(l)if(a)p=o?`const ${d}`:`let ${d}`;else{const m=t.getArrayCount(e);p=`const ${t.getVar(c.type,d,m)}`}return t.addLineFlowCode(`${p} = ${u}`,this),d}}const T0=G(oG),j_=(r,t=null)=>T0(r,t).toStack(),W_=(r,t=null)=>T0(r,t,!0).toStack();$("toVar",j_);$("toConst",W_);const q_=r=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),T0(r));$("temp",q_);class lG extends ot{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){const e=t.getNodeProperties(this);let s=e.varying;if(s===void 0){const i=this.name,n=this.getNodeType(t),a=this.interpolationType,o=this.interpolationSampling;e.varying=s=t.getVaryingFromNode(this,i,n,a,o),e.node=this.node}return s.needsInterpolation||(s.needsInterpolation=t.shaderStage==="fragment"),s}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(Au.VERTEX,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(Au.VERTEX,this.node)}generate(t){const e=t.getNodeProperties(this),s=this.setupVarying(t);if(e.propertyName===void 0){const i=this.getNodeType(t),n=t.getPropertyName(s,Au.VERTEX);t.flowNodeFromShaderStage(Au.VERTEX,this.node,i,n),e.propertyName=n}return t.getPropertyName(s)}}const Ss=G(lG).setParameterLength(1,2),H_=r=>Ss(r);$("toVarying",Ss);$("toVertexStage",H_);$("varying",(...r)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Ss(...r)));$("vertexStage",(...r)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Ss(...r)));const G_=L(([r])=>{const t=r.mul(.9478672986).add(.0521327014).pow(2.4),e=r.mul(.0773993808),s=r.lessThanEqual(.04045);return Ne(t,e,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),X_=L(([r])=>{const t=r.pow(.41666).mul(1.055).sub(.055),e=r.mul(12.92),s=r.lessThanEqual(.0031308);return Ne(t,e,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),N0="WorkingColorSpace",uG="OutputColorSpace";class S0 extends Re{static get type(){return"ColorSpaceNode"}constructor(t,e,s){super("vec4"),this.colorNode=t,this.source=e,this.target=s}resolveColorSpace(t,e){return e===N0?Te.workingColorSpace:e===uG?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){const{colorNode:e}=this,s=this.resolveColorSpace(t,this.source),i=this.resolveColorSpace(t,this.target);let n=e;return Te.enabled===!1||s===i||!s||!i||(Te.getTransfer(s)===Iu&&(n=pt(G_(n.rgb),n.a)),Te.getPrimaries(s)!==Te.getPrimaries(i)&&(n=pt(bs(Te._getMatrix(new Ns,s,i)).mul(n.rgb),n.a)),Te.getTransfer(i)===Iu&&(n=pt(X_(n.rgb),n.a))),n}}const Y_=(r,t)=>q(new S0(q(r),N0,t)),_0=(r,t)=>q(new S0(q(r),t,N0)),hG=(r,t,e)=>q(new S0(q(r),t,e));$("workingToColorSpace",Y_);$("colorSpaceToWorking",_0);let cG=class extends Qa{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),s=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,s,i)}};class dG extends ot{static get type(){return"ReferenceBaseNode"}constructor(t,e,s=null,i=null){super(),this.property=t,this.uniformType=e,this.object=s,this.count=i,this.properties=t.split("."),this.reference=s,this.node=null,this.group=null,this.updateType=$t.OBJECT}setGroup(t){return this.group=t,this}element(t){return q(new cG(this,q(t)))}setNodeType(t){const e=dt(null,t).getSelf();this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let s=t[e[0]];for(let i=1;i<e.length;i++)s=s[e[i]];return s}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}class pG extends dG{static get type(){return"RendererReferenceNode"}constructor(t,e,s=null){super(t,e,s),this.renderer=s,this.setGroup(Nt)}updateReference(t){return this.reference=this.renderer!==null?this.renderer:t.renderer,this.reference}}const Z_=(r,t,e=null)=>q(new pG(r,t,e));class mG extends Re{static get type(){return"ToneMappingNode"}constructor(t,e=Q_,s=null){super("vec3"),this.toneMapping=t,this.exposureNode=e,this.colorNode=s}customCacheKey(){return dS(this.toneMapping)}setup(t){const e=this.colorNode||t.context.color,s=this.toneMapping;if(s===fg)return e;let i=null;const n=t.renderer.library.getToneMappingFunction(s);return n!==null?i=pt(n(e.rgb,this.exposureNode),e.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),i=e),i}}const J_=(r,t,e)=>q(new mG(r,q(t),q(e))),Q_=Z_("toneMappingExposure","float");$("toneMapping",(r,t,e)=>J_(t,e,r));class fG extends o0{static get type(){return"BufferAttributeNode"}constructor(t,e=null,s=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=s,this.bufferOffset=i,this.usage=Hd,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;const e=this.getNodeType(t),s=this.value,i=t.getTypeLength(e),n=this.bufferStride||i,a=this.bufferOffset,o=s.isInterleavedBuffer===!0?s:new lS(s,n),l=new n0(o,i,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){const e=this.getNodeType(t),s=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(s);let n=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,n=i):n=Ss(this).build(t,e),n}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}}const Vh=(r,t=null,e=0,s=0)=>q(new fG(r,t,e,s)),K_=(r,t=null,e=0,s=0)=>Vh(r,t,e,s).setUsage(_u),Kd=(r,t=null,e=0,s=0)=>Vh(r,t,e,s).setInstanced(!0),Tg=(r,t=null,e=0,s=0)=>K_(r,t,e,s).setInstanced(!0);$("toAttribute",r=>Vh(r.value));class gG extends ot{static get type(){return"ComputeNode"}constructor(t,e,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=t,this.count=e,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=$t.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(t){return this.name=t,this}updateDispatchCount(){const{count:t,workgroupSize:e}=this;let s=e[0];for(let i=1;i<e.length;i++)s*=e[i];this.dispatchCount=Math.ceil(t/s)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){const e=this.computeNode.build(t);if(e){const s=t.getNodeProperties(this);s.outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){const{shaderStage:s}=t;if(s==="compute"){const i=this.computeNode.build(t,"void");i!==""&&t.addLineFlowCode(i,this)}else{const n=t.getNodeProperties(this).outputComputeNode;if(n)return n.build(t,e)}}}const t3=(r,t,e)=>q(new gG(q(r),t,e));$("compute",t3);class yG extends ot{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){const e=t.getCache(),s=t.getCacheFromNode(this,this.parent);t.setCache(s);const i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){const s=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);const n=this.node.build(t,...e);return t.setCache(s),n}}const e3=(r,t)=>q(new yG(q(r),t)),r3=(r,t)=>r.context({namespace:t});$("cache",e3);class xG extends ot{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){const e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}}const s3=G(xG).setParameterLength(2);$("bypass",s3);class i3 extends ot{static get type(){return"RemapNode"}constructor(t,e,s,i=M(0),n=M(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=s,this.outLowNode=i,this.outHighNode=n,this.doClamp=!0}setup(){const{node:t,inLowNode:e,inHighNode:s,outLowNode:i,outHighNode:n,doClamp:a}=this;let o=t.sub(e).div(s.sub(e));return a===!0&&(o=o.clamp()),o.mul(n.sub(i)).add(i)}}const n3=G(i3,null,null,{doClamp:!1}).setParameterLength(3,5),a3=G(i3).setParameterLength(3,5);$("remap",n3);$("remapClamp",a3);class bG extends ot{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){const s=this.getNodeType(t),i=this.snippet;if(s==="void")t.addLineFlowCode(i,this);else return t.format(i,s,e)}}const ln=G(bG).setParameterLength(1,2),o3=r=>(r?xr(r,ln("discard")):ln("discard")).toStack(),vG=()=>ln("return").toStack();$("discard",o3);class wG extends Re{static get type(){return"RenderOutputNode"}constructor(t,e,s){super("vec4"),this.colorNode=t,this.toneMapping=e,this.outputColorSpace=s,this.isRenderOutputNode=!0}setup({context:t}){let e=this.colorNode||t.color;const s=(this.toneMapping!==null?this.toneMapping:t.toneMapping)||fg,i=(this.outputColorSpace!==null?this.outputColorSpace:t.outputColorSpace)||Wd;return s!==fg&&(e=e.toneMapping(s)),i!==Wd&&i!==Te.workingColorSpace&&(e=e.workingToColorSpace(i)),e}}const l3=(r,t=null,e=null)=>q(new wG(q(r),t,e));$("renderOutput",l3);class MG extends Re{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}getNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){const e=this.callback,s=this.node.build(t),i="--- TSL debug - "+t.shaderStage+" shader ---",n="-".repeat(i.length);let a="";return a+="// #"+i+`#
|
|
111
|
+
`,a+=t.flow.code.replace(/^\t/mg,"")+`
|
|
112
|
+
`,a+="/* ... */ "+s+` /* ... */
|
|
113
|
+
`,a+="// #"+n+`#
|
|
114
|
+
`,e!==null?e(t,a):console.log(a),s}}const u3=(r,t=null)=>q(new MG(q(r),t));$("debug",u3);function TG(r){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",r)}class h3 extends ot{static get type(){return"AttributeNode"}constructor(t,e=null){super(e),this.global=!0,this._attributeName=t}getHash(t){return this.getAttributeName(t)}getNodeType(t){let e=this.nodeType;if(e===null){const s=this.getAttributeName(t);if(t.hasGeometryAttribute(s)){const i=t.geometry.getAttribute(s);e=t.getTypeFromAttribute(i)}else e="float"}return e}setAttributeName(t){return this._attributeName=t,this}getAttributeName(){return this._attributeName}generate(t){const e=this.getAttributeName(t),s=this.getNodeType(t);if(t.hasGeometryAttribute(e)===!0){const n=t.geometry.getAttribute(e),a=t.getTypeFromAttribute(n),o=t.getAttribute(e,a);return t.shaderStage==="vertex"?t.format(o.name,a,s):Ss(this).build(t,s)}else return console.warn(`AttributeNode: Vertex attribute "${e}" not found on geometry.`),t.generateConst(s)}serialize(t){super.serialize(t),t.global=this.global,t._attributeName=this._attributeName}deserialize(t){super.deserialize(t),this.global=t.global,this._attributeName=t._attributeName}}const sa=(r,t=null)=>q(new h3(r,t)),le=(r=0)=>sa("uv"+(r>0?r:""),"vec2");class NG extends ot{static get type(){return"TextureSizeNode"}constructor(t,e=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=t,this.levelNode=e}generate(t,e){const s=this.textureNode.build(t,"property"),i=this.levelNode===null?"0":this.levelNode.build(t,"int");return t.format(`${t.getMethod("textureDimensions")}( ${s}, ${i} )`,this.getNodeType(t),e)}}const Hn=G(NG).setParameterLength(1,2);class SG extends Ch{static get type(){return"MaxMipLevelNode"}constructor(t){super(0),this._textureNode=t,this.updateType=$t.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const t=this.texture,e=t.images,s=e&&e.length>0?e[0]&&e[0].image||e[0]:t.image;if(s&&s.width!==void 0){const{width:i,height:n}=s;this.value=Math.log2(Math.max(i,n))}}}const c3=G(SG).setParameterLength(1),A0=new Rr;class un extends Ch{static get type(){return"TextureNode"}constructor(t=A0,e=null,s=null,i=null){super(t),this.isTextureNode=!0,this.uvNode=e,this.levelNode=s,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=$t.NONE,this.referenceNode=null,this._value=t,this._matrixUniform=null,this.setUpdateMatrix(e===null)}set value(t){this.referenceNode?this.referenceNode.value=t:this._value=t}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===eS?"uvec4":this.value.type===iq?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return le(this.value.channel)}updateReference(){return this.value}getTransformedUV(t){return this._matrixUniform===null&&(this._matrixUniform=dt(this.value.matrix)),this._matrixUniform.mul(P(t,1)).xy}setUpdateMatrix(t){return this.updateMatrix=t,this.updateType=t?$t.OBJECT:$t.NONE,this}setupUV(t,e){const s=this.value;return t.isFlipY()&&(s.image instanceof ImageBitmap&&s.flipY===!0||s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0||s.isDepthTexture===!0)&&(this.sampler?e=e.flipY():e=e.setY(N(Hn(this,this.levelNode).y).sub(e.y).sub(1))),e}setup(t){const e=t.getNodeProperties(this);e.referenceNode=this.referenceNode;const s=this.value;if(!s||s.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let i=this.uvNode;(i===null||t.context.forceUVContext===!0)&&t.context.getUV&&(i=t.context.getUV(this,t)),i||(i=this.getDefaultUV()),this.updateMatrix===!0&&(i=this.getTransformedUV(i)),i=this.setupUV(t,i);let n=this.levelNode;n===null&&t.context.getTextureLevel&&(n=t.context.getTextureLevel(this)),e.uvNode=i,e.levelNode=n,e.biasNode=this.biasNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.depthNode=this.depthNode}generateUV(t,e){return e.build(t,this.sampler===!0?"vec2":"ivec2")}generateSnippet(t,e,s,i,n,a,o,l){const h=this.value;let u;return i?u=t.generateTextureLevel(h,e,s,i,a):n?u=t.generateTextureBias(h,e,s,n,a):l?u=t.generateTextureGrad(h,e,s,l,a):o?u=t.generateTextureCompare(h,e,s,o,a):this.sampler===!1?u=t.generateTextureLoad(h,e,s,a):u=t.generateTexture(h,e,s,a),u}generate(t,e){const s=this.value,i=t.getNodeProperties(this),n=super.generate(t,"property");if(/^sampler/.test(e))return n+"_sampler";if(t.isReference(e))return n;{const a=t.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:c,biasNode:d,compareNode:p,depthNode:m,gradNode:f}=i,x=this.generateUV(t,u),b=c?c.build(t,"float"):null,w=d?d.build(t,"float"):null,S=m?m.build(t,"int"):null,_=p?p.build(t,"float"):null,V=f?[f[0].build(t,"vec2"),f[1].build(t,"vec2")]:null,z=t.getVarFromNode(this);o=t.getPropertyName(z);const A=this.generateSnippet(t,n,x,b,w,S,_,V);t.addLineFlowCode(`${o} = ${A}`,this),a.snippet=A,a.propertyName=o}let l=o;const h=this.getNodeType(t);return t.needsToWorkingColorSpace(s)&&(l=_0(ln(l,h),s.colorSpace).setup(t).build(t,h)),t.format(l,h,e)}}setSampler(t){return this.sampler=t,this}getSampler(){return this.sampler}uv(t){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(t)}sample(t){const e=this.clone();return e.uvNode=q(t),e.referenceNode=this.getSelf(),q(e)}blur(t){const e=this.clone();e.biasNode=q(t).mul(c3(e)),e.referenceNode=this.getSelf();const s=e.value;return e.generateMipmaps===!1&&(s&&s.generateMipmaps===!1||s.minFilter===ra||s.magFilter===ra)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),e.biasNode=null),q(e)}level(t){const e=this.clone();return e.levelNode=q(t),e.referenceNode=this.getSelf(),q(e)}size(t){return Hn(this,t)}bias(t){const e=this.clone();return e.biasNode=q(t),e.referenceNode=this.getSelf(),q(e)}compare(t){const e=this.clone();return e.compareNode=q(t),e.referenceNode=this.getSelf(),q(e)}grad(t,e){const s=this.clone();return s.gradNode=[q(t),q(e)],s.referenceNode=this.getSelf(),q(s)}depth(t){const e=this.clone();return e.depthNode=q(t),e.referenceNode=this.getSelf(),q(e)}serialize(t){super.serialize(t),t.value=this.value.toJSON(t.meta).uuid,t.sampler=this.sampler,t.updateMatrix=this.updateMatrix,t.updateType=this.updateType}deserialize(t){super.deserialize(t),this.value=t.meta.textures[t.value],this.sampler=t.sampler,this.updateMatrix=t.updateMatrix,this.updateType=t.updateType}update(){const t=this.value,e=this._matrixUniform;e!==null&&(e.value=t.matrix),t.matrixAutoUpdate===!0&&t.updateMatrix()}clone(){const t=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return t.sampler=this.sampler,t.depthNode=this.depthNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t}}const _G=G(un).setParameterLength(1,4).setName("texture"),Gt=(r=A0,t=null,e=null,s=null)=>{let i;return r&&r.isTextureNode===!0?(i=q(r.clone()),i.referenceNode=r.getSelf(),t!==null&&(i.uvNode=q(t)),e!==null&&(i.levelNode=q(e)),s!==null&&(i.biasNode=q(s))):i=_G(r,t,e,s),i},AG=(r=A0)=>Gt(r),ve=(...r)=>Gt(...r).setSampler(!1),zG=r=>(r.isNode===!0?r:Gt(r)).convert("sampler"),CG=r=>(r.isNode===!0?r:Gt(r)).convert("samplerComparison");class z0 extends Ch{static get type(){return"BufferNode"}constructor(t,e,s=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferCount=s}getElementType(t){return this.getNodeType(t)}getInputType(){return"buffer"}}const Rh=(r,t,e)=>q(new z0(r,t,e));class EG extends Qa{static get type(){return"UniformArrayElementNode"}constructor(t,e){super(t,e),this.isArrayBufferElementNode=!0}generate(t){const e=super.generate(t),s=this.getNodeType(),i=this.node.getPaddedType();return t.format(e,i,s)}}class d3 extends z0{static get type(){return"UniformArrayNode"}constructor(t,e=null){super(null),this.array=t,this.elementType=e===null?Un(t[0]):e,this.paddedType=this.getPaddedType(),this.updateType=$t.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const t=this.elementType;let e="vec4";return t==="mat2"?e="mat2":/mat/.test(t)===!0?e="mat4":t.charAt(0)==="i"?e="ivec4":t.charAt(0)==="u"&&(e="uvec4"),e}update(){const{array:t,value:e}=this,s=this.elementType;if(s==="float"||s==="int"||s==="uint")for(let i=0;i<t.length;i++){const n=i*4;e[n]=t[i]}else if(s==="color")for(let i=0;i<t.length;i++){const n=i*4,a=t[i];e[n]=a.r,e[n+1]=a.g,e[n+2]=a.b||0}else if(s==="mat2")for(let i=0;i<t.length;i++){const n=i*4,a=t[i];e[n]=a.elements[0],e[n+1]=a.elements[1],e[n+2]=a.elements[2],e[n+3]=a.elements[3]}else if(s==="mat3")for(let i=0;i<t.length;i++){const n=i*16,a=t[i];e[n]=a.elements[0],e[n+1]=a.elements[1],e[n+2]=a.elements[2],e[n+4]=a.elements[3],e[n+5]=a.elements[4],e[n+6]=a.elements[5],e[n+8]=a.elements[6],e[n+9]=a.elements[7],e[n+10]=a.elements[8],e[n+15]=1}else if(s==="mat4")for(let i=0;i<t.length;i++){const n=i*16,a=t[i];for(let o=0;o<a.elements.length;o++)e[n+o]=a.elements[o]}else for(let i=0;i<t.length;i++){const n=i*4,a=t[i];e[n]=a.x,e[n+1]=a.y,e[n+2]=a.z||0,e[n+3]=a.w||0}}setup(t){const e=this.array.length,s=this.elementType;let i=Float32Array;const n=this.paddedType,a=t.getTypeLength(n);return s.charAt(0)==="i"&&(i=Int32Array),s.charAt(0)==="u"&&(i=Uint32Array),this.value=new i(e*a),this.bufferCount=e,this.bufferType=n,super.setup(t)}element(t){return q(new EG(this,q(t)))}}const Hs=(r,t)=>q(new d3(r,t)),VG=(r,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),q(new d3(r,t)));class RG extends ot{constructor(t){super("float"),this.name=t,this.isBuiltinNode=!0}generate(){return this.name}}const Dp=G(RG).setParameterLength(1),Up=dt(0,"uint").label("u_cameraIndex").setGroup(Fp("cameraIndex")).toVarying("v_cameraIndex"),Fn=dt("float").label("cameraNear").setGroup(Nt).onRenderUpdate(({camera:r})=>r.near),On=dt("float").label("cameraFar").setGroup(Nt).onRenderUpdate(({camera:r})=>r.far),Lh=L(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const i of r.cameras)e.push(i.projectionMatrix);t=Hs(e).setGroup(Nt).label("cameraProjectionMatrices").element(r.isMultiViewCamera?Dp("gl_ViewID_OVR"):Up).toVar("cameraProjectionMatrix")}else t=dt("mat4").label("cameraProjectionMatrix").setGroup(Nt).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),LG=L(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const i of r.cameras)e.push(i.projectionMatrixInverse);t=Hs(e).setGroup(Nt).label("cameraProjectionMatricesInverse").element(r.isMultiViewCamera?Dp("gl_ViewID_OVR"):Up).toVar("cameraProjectionMatrixInverse")}else t=dt("mat4").label("cameraProjectionMatrixInverse").setGroup(Nt).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),_s=L(({camera:r})=>{let t;if(r.isArrayCamera&&r.cameras.length>0){const e=[];for(const i of r.cameras)e.push(i.matrixWorldInverse);t=Hs(e).setGroup(Nt).label("cameraViewMatrices").element(r.isMultiViewCamera?Dp("gl_ViewID_OVR"):Up).toVar("cameraViewMatrix")}else t=dt("mat4").label("cameraViewMatrix").setGroup(Nt).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),IG=dt("mat4").label("cameraWorldMatrix").setGroup(Nt).onRenderUpdate(({camera:r})=>r.matrixWorld),PG=dt("mat3").label("cameraNormalMatrix").setGroup(Nt).onRenderUpdate(({camera:r})=>r.normalMatrix),FG=dt(new k).label("cameraPosition").setGroup(Nt).onRenderUpdate(({camera:r},t)=>t.value.setFromMatrixPosition(r.matrixWorld)),lv=new s0;class St extends ot{static get type(){return"Object3DNode"}constructor(t,e=null){super(),this.scope=t,this.object3d=e,this.updateType=$t.OBJECT,this.uniformNode=new Ch(null)}getNodeType(){const t=this.scope;if(t===St.WORLD_MATRIX)return"mat4";if(t===St.POSITION||t===St.VIEW_POSITION||t===St.DIRECTION||t===St.SCALE)return"vec3";if(t===St.RADIUS)return"float"}update(t){const e=this.object3d,s=this.uniformNode,i=this.scope;if(i===St.WORLD_MATRIX)s.value=e.matrixWorld;else if(i===St.POSITION)s.value=s.value||new k,s.value.setFromMatrixPosition(e.matrixWorld);else if(i===St.SCALE)s.value=s.value||new k,s.value.setFromMatrixScale(e.matrixWorld);else if(i===St.DIRECTION)s.value=s.value||new k,e.getWorldDirection(s.value);else if(i===St.VIEW_POSITION){const n=t.camera;s.value=s.value||new k,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(n.matrixWorldInverse)}else if(i===St.RADIUS){const n=t.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),lv.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),s.value=lv.radius}}generate(t){const e=this.scope;return e===St.WORLD_MATRIX?this.uniformNode.nodeType="mat4":e===St.POSITION||e===St.VIEW_POSITION||e===St.DIRECTION||e===St.SCALE?this.uniformNode.nodeType="vec3":e===St.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(t)}serialize(t){super.serialize(t),t.scope=this.scope}deserialize(t){super.deserialize(t),this.scope=t.scope}}St.WORLD_MATRIX="worldMatrix";St.POSITION="position";St.SCALE="scale";St.VIEW_POSITION="viewPosition";St.DIRECTION="direction";St.RADIUS="radius";const OG=G(St,St.DIRECTION).setParameterLength(1),BG=G(St,St.WORLD_MATRIX).setParameterLength(1),p3=G(St,St.POSITION).setParameterLength(1),kG=G(St,St.SCALE).setParameterLength(1),DG=G(St,St.VIEW_POSITION).setParameterLength(1),UG=G(St,St.RADIUS).setParameterLength(1);class ws extends St{static get type(){return"ModelNode"}constructor(t){super(t)}update(t){this.object3d=t.object,super.update(t)}}const $G=K(ws,ws.DIRECTION),qi=K(ws,ws.WORLD_MATRIX),jG=K(ws,ws.POSITION),WG=K(ws,ws.SCALE),qG=K(ws,ws.VIEW_POSITION),HG=K(ws,ws.RADIUS),m3=dt(new Ns).onObjectUpdate(({object:r},t)=>t.value.getNormalMatrix(r.matrixWorld)),GG=dt(new Zt).onObjectUpdate(({object:r},t)=>t.value.copy(r.matrixWorld).invert()),Ih=L(r=>r.renderer.overrideNodes.modelViewMatrix||f3).once()().toVar("modelViewMatrix"),f3=_s.mul(qi),XG=L(r=>(r.context.isHighPrecisionModelViewMatrix=!0,dt("mat4").onObjectUpdate(({object:t,camera:e})=>t.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld)))).once()().toVar("highpModelViewMatrix"),YG=L(r=>{const t=r.context.isHighPrecisionModelViewMatrix;return dt("mat3").onObjectUpdate(({object:e,camera:s})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),C0=sa("position","vec3"),_e=C0.toVarying("positionLocal"),tp=C0.toVarying("positionPrevious"),Oa=L(r=>qi.mul(_e).xyz.toVarying(r.getNamespace("v_positionWorld")),"vec3").once("POSITION")(),g3=L(r=>_e.transformDirection(qi).toVarying(r.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection"),"vec3").once("POSITION")(),or=L(r=>r.context.setupPositionView().toVarying(r.getNamespace("v_positionView")),"vec3").once("POSITION")(),Zr=or.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class ZG extends ot{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(t){const{renderer:e,material:s}=t;return e.coordinateSystem===Wi&&s.side===Vp?"false":t.getFrontFacing()}}const y3=K(ZG),Ph=M(y3).mul(2).sub(1),E0=sa("normal","vec3"),Fr=L(r=>r.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),P(0,1,0)):E0,"vec3").once()().toVar("normalLocal"),x3=or.dFdx().cross(or.dFdy()).normalize().toVar("normalFlat"),vi=L(r=>{let t;return r.material.flatShading===!0?t=x3:t=Ss(V0(Fr),"v_normalView").normalize(),t},"vec3").once()().toVar("normalView"),b3=L(r=>{let t=vi.transformDirection(_s);return r.material.flatShading!==!0&&(t=Ss(t,"v_normalWorld")),t},"vec3").once()().normalize().toVar("normalWorld"),hn=L(r=>{let t=r.context.setupNormal().context({getUV:null});return r.material.flatShading!==!0&&(t=t.mul(Ph)),t},"vec3").once()().toVar("transformedNormalView"),v3=hn.transformDirection(_s).toVar("transformedNormalWorld"),JG=L(r=>{let t=r.context.setupClearcoatNormal().context({getUV:null});return r.material.flatShading!==!0&&(t=t.mul(Ph)),t},"vec3").once()().toVar("transformedClearcoatNormalView"),w3=L(([r,t=qi])=>{const e=bs(t),s=r.div(P(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2])));return e.mul(s).xyz}),V0=L(([r],t)=>{const e=t.renderer.overrideNodes.modelNormalViewMatrix;if(e!==null)return e.transformDirection(r);const s=m3.mul(r);return _s.transformDirection(s)}),uv=new Ja,xf=new Zt,M3=dt(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),QG=dt(1).onReference(({material:r})=>r).onObjectUpdate(function({material:r,scene:t}){return r.envMap?r.envMapIntensity:t.environmentIntensity}),R0=dt(new Zt).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:t}){const e=t.environment!==null&&r.envMap===null?t.environmentRotation:r.envMapRotation;return e?(uv.copy(e),xf.makeRotationFromEuler(uv)):xf.identity(),xf}),T3=Zr.negate().reflect(hn),N3=Zr.negate().refract(hn,M3),S3=T3.transformDirection(_s).toVar("reflectVector"),_3=N3.transformDirection(_s).toVar("reflectVector"),A3=new Hq;class KG extends un{static get type(){return"CubeTextureNode"}constructor(t,e=null,s=null,i=null){super(t,e,s,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const t=this.value;return t.mapping===jd?S3:t.mapping===gg?_3:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',t.mapping),P(0,0,0))}setUpdateMatrix(){}setupUV(t,e){const s=this.value;return(t.renderer.coordinateSystem===ja||!s.isRenderTargetTexture)&&(e=P(e.x.negate(),e.yz)),R0.mul(e)}generateUV(t,e){return e.build(t,"vec3")}}const L0=G(KG).setParameterLength(1,4).setName("cubeTexture"),I0=(r=A3,t=null,e=null,s=null)=>{let i;return r&&r.isCubeTextureNode===!0?(i=q(r.clone()),i.referenceNode=r.getSelf(),t!==null&&(i.uvNode=q(t)),e!==null&&(i.levelNode=q(e)),s!==null&&(i.biasNode=q(s))):i=L0(r,t,e,s),i},tX=(r=A3)=>L0(r);class eX extends Qa{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){const e=super.generate(t),s=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,s,i)}}class $p extends ot{static get type(){return"ReferenceNode"}constructor(t,e,s=null,i=null){super(),this.property=t,this.uniformType=e,this.object=s,this.count=i,this.properties=t.split("."),this.reference=s,this.node=null,this.group=null,this.name=null,this.updateType=$t.OBJECT}element(t){return q(new eX(this,q(t)))}setGroup(t){return this.group=t,this}label(t){return this.name=t,this}setNodeType(t){let e=null;this.count!==null?e=Rh(null,t,this.count):Array.isArray(this.getValueFromReference())?e=Hs(null,t):t==="texture"?e=Gt(null):t==="cubeTexture"?e=I0(null):e=dt(null,t),this.group!==null&&e.setGroup(this.group),this.name!==null&&e.label(this.name),this.node=e.getSelf()}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){const{properties:e}=this;let s=t[e[0]];for(let i=1;i<e.length;i++)s=s[e[i]];return s}updateReference(t){return this.reference=this.object!==null?this.object:t.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}}const me=(r,t,e)=>q(new $p(r,t,e)),Ng=(r,t,e,s)=>q(new $p(r,t,s,e));class rX extends $p{static get type(){return"MaterialReferenceNode"}constructor(t,e,s=null){super(t,e,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(t){return this.reference=this.material!==null?this.material:t.material,this.reference}}const Aa=(r,t,e=null)=>q(new rX(r,t,e)),jp=L(r=>(r.geometry.hasAttribute("tangent")===!1&&r.geometry.computeTangents(),sa("tangent","vec4")))(),Fh=jp.xyz.toVar("tangentLocal"),Oh=Ih.mul(pt(Fh,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),z3=Oh.transformDirection(_s).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),P0=Oh.toVar("transformedTangentView"),sX=P0.transformDirection(_s).normalize().toVar("transformedTangentWorld"),Bh=L(([r,t],e)=>{let s=r.mul(jp.w).xyz;return e.material.flatShading!==!0&&(s=Ss(s,t)),s}).once(),iX=Bh(E0.cross(jp),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),nX=Bh(Fr.cross(Fh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),C3=Bh(vi.cross(Oh),"v_bitangentView").normalize().toVar("bitangentView"),aX=Bh(b3.cross(z3),"v_bitangentWorld").normalize().toVar("bitangentWorld"),E3=Bh(hn.cross(P0),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),oX=E3.transformDirection(_s).normalize().toVar("transformedBitangentWorld"),F0=bs(Oh,C3,vi),V3=Zr.mul(F0),lX=(r,t)=>r.sub(V3.mul(t)),uX=(()=>{let r=pl.cross(Zr);return r=r.cross(pl).normalize(),r=Ne(r,hn,OS.mul(PS.oneMinus()).oneMinus().pow2().pow2()).normalize(),r})(),hX=L(r=>{const{eye_pos:t,surf_norm:e,mapN:s,uv:i}=r,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),l=i.dFdy(),h=e,u=a.cross(h),c=h.cross(n),d=u.mul(o.x).add(c.mul(l.x)),p=u.mul(o.y).add(c.mul(l.y)),m=d.dot(d).max(p.dot(p)),f=Ph.mul(m.inverseSqrt());return Ee(d.mul(s.x,f),p.mul(s.y,f),h.mul(s.z)).normalize()});class cX extends Re{static get type(){return"NormalMapNode"}constructor(t,e=null){super("vec3"),this.node=t,this.scaleNode=e,this.normalMapType=Lb}setup(t){const{normalMapType:e,scaleNode:s}=this;let i=this.node.mul(2).sub(1);s!==null&&(i=P(i.xy.mul(s),i.z));let n=null;return e===aq?n=V0(i):e===Lb&&(t.hasGeometryAttribute("tangent")===!0?n=F0.mul(i).normalize():n=hX({eye_pos:or,surf_norm:vi,mapN:i,uv:le()})),n}}const Sg=G(cX).setParameterLength(1,2),dX=L(({textureNode:r,bumpScale:t})=>{const e=i=>r.cache().context({getUV:n=>i(n.uvNode||le()),forceUVContext:!0}),s=M(e(i=>i));return Z(M(e(i=>i.add(i.dFdx()))).sub(s),M(e(i=>i.add(i.dFdy()))).sub(s)).mul(t)}),pX=L(r=>{const{surf_pos:t,surf_norm:e,dHdxy:s}=r,i=t.dFdx().normalize(),n=t.dFdy().normalize(),a=e,o=n.cross(a),l=a.cross(i),h=i.dot(o).mul(Ph),u=h.sign().mul(s.x.mul(o).add(s.y.mul(l)));return h.abs().mul(e).sub(u).normalize()});class mX extends Re{static get type(){return"BumpMapNode"}constructor(t,e=null){super("vec3"),this.textureNode=t,this.scaleNode=e}setup(){const t=this.scaleNode!==null?this.scaleNode:1,e=dX({textureNode:this.textureNode,bumpScale:t});return pX({surf_pos:or,surf_norm:vi,dHdxy:e})}}const R3=G(mX).setParameterLength(1,2),hv=new Map;class U extends ot{static get type(){return"MaterialNode"}constructor(t){super(),this.scope=t}getCache(t,e){let s=hv.get(t);return s===void 0&&(s=Aa(t,e),hv.set(t,s)),s}getFloat(t){return this.getCache(t,"float")}getColor(t){return this.getCache(t,"color")}getTexture(t){return this.getCache(t==="map"?"map":t+"Map","texture")}setup(t){const e=t.context.material,s=this.scope;let i=null;if(s===U.COLOR){const n=e.color!==void 0?this.getColor(s):P();e.map&&e.map.isTexture===!0?i=n.mul(this.getTexture("map")):i=n}else if(s===U.OPACITY){const n=this.getFloat(s);e.alphaMap&&e.alphaMap.isTexture===!0?i=n.mul(this.getTexture("alpha")):i=n}else if(s===U.SPECULAR_STRENGTH)e.specularMap&&e.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=M(1);else if(s===U.SPECULAR_INTENSITY){const n=this.getFloat(s);e.specularIntensityMap&&e.specularIntensityMap.isTexture===!0?i=n.mul(this.getTexture(s).a):i=n}else if(s===U.SPECULAR_COLOR){const n=this.getColor(s);e.specularColorMap&&e.specularColorMap.isTexture===!0?i=n.mul(this.getTexture(s).rgb):i=n}else if(s===U.ROUGHNESS){const n=this.getFloat(s);e.roughnessMap&&e.roughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).g):i=n}else if(s===U.METALNESS){const n=this.getFloat(s);e.metalnessMap&&e.metalnessMap.isTexture===!0?i=n.mul(this.getTexture(s).b):i=n}else if(s===U.EMISSIVE){const n=this.getFloat("emissiveIntensity"),a=this.getColor(s).mul(n);e.emissiveMap&&e.emissiveMap.isTexture===!0?i=a.mul(this.getTexture(s)):i=a}else if(s===U.NORMAL)e.normalMap?(i=Sg(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=e.normalMapType):e.bumpMap?i=R3(this.getTexture("bump").r,this.getFloat("bumpScale")):i=vi;else if(s===U.CLEARCOAT){const n=this.getFloat(s);e.clearcoatMap&&e.clearcoatMap.isTexture===!0?i=n.mul(this.getTexture(s).r):i=n}else if(s===U.CLEARCOAT_ROUGHNESS){const n=this.getFloat(s);e.clearcoatRoughnessMap&&e.clearcoatRoughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).r):i=n}else if(s===U.CLEARCOAT_NORMAL)e.clearcoatNormalMap?i=Sg(this.getTexture(s),this.getCache(s+"Scale","vec2")):i=vi;else if(s===U.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));e.sheenColorMap&&e.sheenColorMap.isTexture===!0?i=n.mul(this.getTexture("sheenColor").rgb):i=n}else if(s===U.SHEEN_ROUGHNESS){const n=this.getFloat(s);e.sheenRoughnessMap&&e.sheenRoughnessMap.isTexture===!0?i=n.mul(this.getTexture(s).a):i=n,i=i.clamp(.07,1)}else if(s===U.ANISOTROPY)if(e.anisotropyMap&&e.anisotropyMap.isTexture===!0){const n=this.getTexture(s);i=Pp(Xo.x,Xo.y,Xo.y.negate(),Xo.x).mul(n.rg.mul(2).sub(Z(1)).normalize().mul(n.b))}else i=Xo;else if(s===U.IRIDESCENCE_THICKNESS){const n=me("1","float",e.iridescenceThicknessRange);if(e.iridescenceThicknessMap){const a=me("0","float",e.iridescenceThicknessRange);i=n.sub(a).mul(this.getTexture(s).g).add(a)}else i=n}else if(s===U.TRANSMISSION){const n=this.getFloat(s);e.transmissionMap?i=n.mul(this.getTexture(s).r):i=n}else if(s===U.THICKNESS){const n=this.getFloat(s);e.thicknessMap?i=n.mul(this.getTexture(s).g):i=n}else if(s===U.IOR)i=this.getFloat(s);else if(s===U.LIGHT_MAP)i=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===U.AO)i=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(s===U.LINE_DASH_OFFSET)i=e.dashOffset?this.getFloat(s):M(0);else{const n=this.getNodeType(t);i=this.getCache(s,n)}return i}}U.ALPHA_TEST="alphaTest";U.COLOR="color";U.OPACITY="opacity";U.SHININESS="shininess";U.SPECULAR="specular";U.SPECULAR_STRENGTH="specularStrength";U.SPECULAR_INTENSITY="specularIntensity";U.SPECULAR_COLOR="specularColor";U.REFLECTIVITY="reflectivity";U.ROUGHNESS="roughness";U.METALNESS="metalness";U.NORMAL="normal";U.CLEARCOAT="clearcoat";U.CLEARCOAT_ROUGHNESS="clearcoatRoughness";U.CLEARCOAT_NORMAL="clearcoatNormal";U.EMISSIVE="emissive";U.ROTATION="rotation";U.SHEEN="sheen";U.SHEEN_ROUGHNESS="sheenRoughness";U.ANISOTROPY="anisotropy";U.IRIDESCENCE="iridescence";U.IRIDESCENCE_IOR="iridescenceIOR";U.IRIDESCENCE_THICKNESS="iridescenceThickness";U.IOR="ior";U.TRANSMISSION="transmission";U.THICKNESS="thickness";U.ATTENUATION_DISTANCE="attenuationDistance";U.ATTENUATION_COLOR="attenuationColor";U.LINE_SCALE="scale";U.LINE_DASH_SIZE="dashSize";U.LINE_GAP_SIZE="gapSize";U.LINE_WIDTH="linewidth";U.LINE_DASH_OFFSET="dashOffset";U.POINT_SIZE="size";U.DISPERSION="dispersion";U.LIGHT_MAP="light";U.AO="ao";const L3=K(U,U.ALPHA_TEST),I3=K(U,U.COLOR),fX=K(U,U.SHININESS),P3=K(U,U.EMISSIVE),F3=K(U,U.OPACITY),gX=K(U,U.SPECULAR),yX=K(U,U.SPECULAR_INTENSITY),xX=K(U,U.SPECULAR_COLOR),bX=K(U,U.SPECULAR_STRENGTH),vX=K(U,U.REFLECTIVITY),wX=K(U,U.ROUGHNESS),MX=K(U,U.METALNESS),O3=K(U,U.NORMAL),TX=K(U,U.CLEARCOAT),NX=K(U,U.CLEARCOAT_ROUGHNESS),SX=K(U,U.CLEARCOAT_NORMAL),_X=K(U,U.ROTATION),AX=K(U,U.SHEEN),zX=K(U,U.SHEEN_ROUGHNESS),CX=K(U,U.ANISOTROPY),EX=K(U,U.IRIDESCENCE),VX=K(U,U.IRIDESCENCE_IOR),RX=K(U,U.IRIDESCENCE_THICKNESS),LX=K(U,U.TRANSMISSION),IX=K(U,U.THICKNESS),PX=K(U,U.IOR),FX=K(U,U.ATTENUATION_DISTANCE),OX=K(U,U.ATTENUATION_COLOR),BX=K(U,U.LINE_SCALE),kX=K(U,U.LINE_DASH_SIZE),DX=K(U,U.LINE_GAP_SIZE),UX=K(U,U.LINE_WIDTH),$X=K(U,U.LINE_DASH_OFFSET),jX=K(U,U.POINT_SIZE),WX=K(U,U.DISPERSION),B3=K(U,U.LIGHT_MAP),k3=K(U,U.AO),Xo=dt(new ge).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),D3=L(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class ie extends ot{static get type(){return"IndexNode"}constructor(t){super("uint"),this.scope=t,this.isIndexNode=!0}generate(t){const e=this.getNodeType(t),s=this.scope;let i;if(s===ie.VERTEX)i=t.getVertexIndex();else if(s===ie.INSTANCE)i=t.getInstanceIndex();else if(s===ie.DRAW)i=t.getDrawIndex();else if(s===ie.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(s===ie.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(s===ie.SUBGROUP)i=t.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+s);let n;return t.shaderStage==="vertex"||t.shaderStage==="compute"?n=i:n=Ss(this).build(t,e),n}}ie.VERTEX="vertex";ie.INSTANCE="instance";ie.SUBGROUP="subgroup";ie.INVOCATION_LOCAL="invocationLocal";ie.INVOCATION_SUBGROUP="invocationSubgroup";ie.DRAW="draw";const U3=K(ie,ie.VERTEX),Gn=K(ie,ie.INSTANCE),qX=K(ie,ie.SUBGROUP),HX=K(ie,ie.INVOCATION_SUBGROUP),GX=K(ie,ie.INVOCATION_LOCAL),$3=K(ie,ie.DRAW);class j3 extends ot{static get type(){return"InstanceNode"}constructor(t,e,s=null){super("void"),this.count=t,this.instanceMatrix=e,this.instanceColor=s,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=$t.FRAME,this.buffer=null,this.bufferColor=null}setup(t){const{count:e,instanceMatrix:s,instanceColor:i}=this;let{instanceMatrixNode:n,instanceColorNode:a}=this;if(n===null){if(e<=1e3)n=Rh(s.array,"mat4",Math.max(e,1)).element(Gn);else{const l=new Zq(s.array,16,1);this.buffer=l;const h=s.usage===_u?Tg:Kd,u=[h(l,"vec4",16,0),h(l,"vec4",16,4),h(l,"vec4",16,8),h(l,"vec4",16,12)];n=Fa(...u)}this.instanceMatrixNode=n}if(i&&a===null){const l=new dl(i.array,3),h=i.usage===_u?Tg:Kd;this.bufferColor=l,a=P(h(l,"vec3",3,0)),this.instanceColorNode=a}const o=n.mul(_e).xyz;if(_e.assign(o),t.hasGeometryAttribute("normal")){const l=w3(Fr,n);Fr.assign(l)}this.instanceColorNode!==null&&eh("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==_u&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==_u&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const XX=G(j3).setParameterLength(2,3);class YX extends j3{static get type(){return"InstancedMeshNode"}constructor(t){const{count:e,instanceMatrix:s,instanceColor:i}=t;super(e,s,i),this.instancedMesh=t}}const W3=G(YX).setParameterLength(1);class ZX extends ot{static get type(){return"BatchNode"}constructor(t){super("void"),this.batchMesh=t,this.batchingIdNode=null}setup(t){this.batchingIdNode===null&&(t.getDrawIndex()===null?this.batchingIdNode=Gn:this.batchingIdNode=$3);const s=L(([m])=>{const f=N(Hn(ve(this.batchMesh._indirectTexture),0).x),x=N(m).mod(f),b=N(m).div(f);return ve(this.batchMesh._indirectTexture,Ze(x,b)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(N(this.batchingIdNode)),i=this.batchMesh._matricesTexture,n=N(Hn(ve(i),0).x),a=M(s).mul(4).toInt().toVar(),o=a.mod(n),l=a.div(n),h=Fa(ve(i,Ze(o,l)),ve(i,Ze(o.add(1),l)),ve(i,Ze(o.add(2),l)),ve(i,Ze(o.add(3),l))),u=this.batchMesh._colorsTexture;if(u!==null){const f=L(([x])=>{const b=N(Hn(ve(u),0).x),w=x,S=w.mod(b),_=w.div(b);return ve(u,Ze(S,_)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(s);eh("vec3","vBatchColor").assign(f)}const c=bs(h);_e.assign(h.mul(_e));const d=Fr.div(P(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),p=c.mul(d).xyz;Fr.assign(p),t.hasGeometryAttribute("tangent")&&Fh.mulAssign(c)}}const q3=G(ZX).setParameterLength(1);class JX extends Qa{static get type(){return"StorageArrayElementNode"}constructor(t,e){super(t,e),this.isStorageArrayElementNode=!0}set storageBufferNode(t){this.node=t}get storageBufferNode(){return this.node}getMemberType(t,e){const s=this.storageBufferNode.structTypeNode;return s?s.getMemberType(t,e):"void"}setup(t){return t.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&t.setupPBO(this.node),super.setup(t)}generate(t,e){let s;const i=t.context.assign;if(t.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&i!==!0&&(this.node.value.isInstancedBufferAttribute||t.shaderStage!=="compute")?s=t.generatePBO(this):s=this.node.build(t):s=super.generate(t),i!==!0){const n=this.getNodeType(t);s=t.format(s,n,e)}return s}}const QX=G(JX).setParameterLength(2);class KX extends z0{static get type(){return"StorageBufferNode"}constructor(t,e=null,s=0){let i,n=null;e&&e.isStruct?(i="struct",n=e.layout,(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(s=t.count)):e===null&&(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)?(i=eH(t.itemSize),s=t.count):i=e,super(t,i,s),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=ai.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,t.isStorageBufferAttribute!==!0&&t.isStorageInstancedBufferAttribute!==!0&&(t.isInstancedBufferAttribute?t.isStorageInstancedBufferAttribute=!0:t.isStorageBufferAttribute=!0)}getHash(t){if(this.bufferCount===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(t){return QX(this,t)}setPBO(t){return this.isPBO=t,this}getPBO(){return this.isPBO}setAccess(t){return this.access=t,this}toReadOnly(){return this.setAccess(ai.READ_ONLY)}setAtomic(t){return this.isAtomic=t,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Vh(this.value),this._varying=Ss(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(t){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(t);if(t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.getNodeType(t);const{attribute:e}=this.getAttributeData();return e.getNodeType(t)}getMemberType(t,e){return this.structTypeNode!==null?this.structTypeNode.getMemberType(t,e):"void"}generate(t){if(this.structTypeNode!==null&&this.structTypeNode.build(t),t.isAvailable("storageBuffer")||t.isAvailable("indirectStorageBuffer"))return super.generate(t);const{attribute:e,varying:s}=this.getAttributeData(),i=s.build(t);return t.registerTransform(i,e),i}}const Ba=(r,t=null,e=0)=>q(new KX(r,t,e)),tY=(r,t,e)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Ba(r,t,e).setPBO(!0)),cv=new WeakMap;class H3 extends ot{static get type(){return"SkinningNode"}constructor(t){super("void"),this.skinnedMesh=t,this.updateType=$t.OBJECT,this.skinIndexNode=sa("skinIndex","uvec4"),this.skinWeightNode=sa("skinWeight","vec4"),this.bindMatrixNode=me("bindMatrix","mat4"),this.bindMatrixInverseNode=me("bindMatrixInverse","mat4"),this.boneMatricesNode=Ng("skeleton.boneMatrices","mat4",t.skeleton.bones.length),this.positionNode=_e,this.toPositionNode=_e,this.previousBoneMatricesNode=null}getSkinnedPosition(t=this.boneMatricesNode,e=this.positionNode){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=t.element(s.x),l=t.element(s.y),h=t.element(s.z),u=t.element(s.w),c=n.mul(e),d=Ee(o.mul(i.x).mul(c),l.mul(i.y).mul(c),h.mul(i.z).mul(c),u.mul(i.w).mul(c));return a.mul(d).xyz}getSkinnedNormal(t=this.boneMatricesNode,e=Fr){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=t.element(s.x),l=t.element(s.y),h=t.element(s.z),u=t.element(s.w);let c=Ee(i.x.mul(o),i.y.mul(l),i.z.mul(h),i.w.mul(u));return c=a.mul(c).mul(n),c.transformDirection(e).xyz}getPreviousSkinnedPosition(t){const e=t.object;return this.previousBoneMatricesNode===null&&(e.skeleton.previousBoneMatrices=new Float32Array(e.skeleton.boneMatrices),this.previousBoneMatricesNode=Ng("skeleton.previousBoneMatrices","mat4",e.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,tp)}needsPreviousBoneMatrices(t){const e=t.renderer.getMRT();return e&&e.has("velocity")||gS(t.object).useVelocity===!0}setup(t){this.needsPreviousBoneMatrices(t)&&tp.assign(this.getPreviousSkinnedPosition(t));const e=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(e),t.hasGeometryAttribute("normal")){const s=this.getSkinnedNormal();Fr.assign(s),t.hasGeometryAttribute("tangent")&&Fh.assign(s)}return e}generate(t,e){if(e!=="void")return super.generate(t,e)}update(t){const e=t.object&&t.object.skeleton?t.object.skeleton:this.skinnedMesh.skeleton;cv.get(e)!==t.frameId&&(cv.set(e,t.frameId),this.previousBoneMatricesNode!==null&&e.previousBoneMatrices.set(e.boneMatrices),e.update())}}const G3=r=>q(new H3(r)),eY=(r,t=null)=>{const e=new H3(r);return e.positionNode=Ba(new dl(r.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Gn).toVar(),e.skinIndexNode=Ba(new dl(new Uint32Array(r.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Gn).toVar(),e.skinWeightNode=Ba(new dl(r.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Gn).toVar(),e.bindMatrixNode=dt(r.bindMatrix,"mat4"),e.bindMatrixInverseNode=dt(r.bindMatrixInverse,"mat4"),e.boneMatricesNode=Rh(r.skeleton.boneMatrices,"mat4",r.skeleton.bones.length),e.toPositionNode=t,q(e)};class rY extends ot{static get type(){return"LoopNode"}constructor(t=[]){super(),this.params=t}getVarName(t){return String.fromCharCode(105+t)}getProperties(t){const e=t.getNodeProperties(this);if(e.stackNode!==void 0)return e;const s={};for(let a=0,o=this.params.length-1;a<o;a++){const l=this.params[a],h=l.isNode!==!0&&l.name||this.getVarName(a),u=l.isNode!==!0&&l.type||"int";s[h]=ln(h,u)}const i=t.addStack();e.returnsNode=this.params[this.params.length-1](s,t),e.stackNode=i;const n=this.params[0];return n.isNode!==!0&&typeof n.update=="function"&&(e.updateNode=L(this.params[0].update)(s)),t.removeStack(),e}getNodeType(t){const{returnsNode:e}=this.getProperties(t);return e?e.getNodeType(t):"void"}setup(t){this.getProperties(t)}generate(t){const e=this.getProperties(t),s=this.params,i=e.stackNode;for(let o=0,l=s.length-1;o<l;o++){const h=s[o];let u=!1,c=null,d=null,p=null,m=null,f=null,x=null;h.isNode?h.getNodeType(t)==="bool"?(u=!0,m="bool",d=h.build(t,m)):(m="int",p=this.getVarName(o),c="0",d=h.build(t,m),f="<"):(m=h.type||"int",p=h.name||this.getVarName(o),c=h.start,d=h.end,f=h.condition,x=h.update,typeof c=="number"?c=t.generateConst(m,c):c&&c.isNode&&(c=c.build(t,m)),typeof d=="number"?d=t.generateConst(m,d):d&&d.isNode&&(d=d.build(t,m)),c!==void 0&&d===void 0?(c=c+" - 1",d="0",f=">="):d!==void 0&&c===void 0&&(c="0",f="<"),f===void 0&&(Number(c)>Number(d)?f=">=":f="<"));let b;if(u)b=`while ( ${d} )`;else{const w={start:c,end:d},S=w.start,_=w.end;let V;const z=()=>f.includes("<")?"+=":"-=";if(x!=null)switch(typeof x){case"function":V=t.flowStagesNode(e.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":V=p+" "+z()+" "+t.generateConst(m,x);break;case"string":V=p+" "+x;break;default:x.isNode?V=p+" "+z()+" "+x.build(t):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),V="break /* invalid update */")}else m==="int"||m==="uint"?x=f.includes("<")?"++":"--":x=z()+" 1.",V=p+" "+x;const A=t.getVar(m,p)+" = "+S,I=p+" "+f+" "+_;b=`for ( ${A}; ${I}; ${V} )`}t.addFlowCode((o===0?`
|
|
115
|
+
`:"")+t.tab+b+` {
|
|
116
|
+
|
|
117
|
+
`).addFlowTab()}const n=i.build(t,"void"),a=e.returnsNode?e.returnsNode.build(t):"";t.removeFlowTab().addFlowCode(`
|
|
118
|
+
`+t.tab+n);for(let o=0,l=this.params.length-1;o<l;o++)t.addFlowCode((o===0?"":t.tab)+`}
|
|
119
|
+
|
|
120
|
+
`).removeFlowTab();return t.addFlowTab(),a}}const Xt=(...r)=>q(new rY(Pa(r,"int"))).toStack(),sY=()=>ln("continue").toStack(),X3=()=>ln("break").toStack(),iY=(...r)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Xt(...r)),bf=new WeakMap,jr=new Mr,dv=L(({bufferMap:r,influence:t,stride:e,width:s,depth:i,offset:n})=>{const a=N(U3).mul(e).add(n),o=a.div(s),l=a.sub(o.mul(s));return ve(r,Ze(l,o)).depth(i).xyz.mul(t)});function nY(r){const t=r.morphAttributes.position!==void 0,e=r.morphAttributes.normal!==void 0,s=r.morphAttributes.color!==void 0,i=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,n=i!==void 0?i.length:0;let a=bf.get(r);if(a===void 0||a.count!==n){let b=function(){f.dispose(),bf.delete(r),r.removeEventListener("dispose",b)};a!==void 0&&a.texture.dispose();const o=r.morphAttributes.position||[],l=r.morphAttributes.normal||[],h=r.morphAttributes.color||[];let u=0;t===!0&&(u=1),e===!0&&(u=2),s===!0&&(u=3);let c=r.attributes.position.count*u,d=1;const p=4096;c>p&&(d=Math.ceil(c/p),c=p);const m=new Float32Array(c*d*4*n),f=new Cq(m,c,d,n);f.type=rS,f.needsUpdate=!0;const x=u*4;for(let w=0;w<n;w++){const S=o[w],_=l[w],V=h[w],z=c*d*4*w;for(let A=0;A<S.count;A++){const I=A*x;t===!0&&(jr.fromBufferAttribute(S,A),m[z+I+0]=jr.x,m[z+I+1]=jr.y,m[z+I+2]=jr.z,m[z+I+3]=0),e===!0&&(jr.fromBufferAttribute(_,A),m[z+I+4]=jr.x,m[z+I+5]=jr.y,m[z+I+6]=jr.z,m[z+I+7]=0),s===!0&&(jr.fromBufferAttribute(V,A),m[z+I+8]=jr.x,m[z+I+9]=jr.y,m[z+I+10]=jr.z,m[z+I+11]=V.itemSize===4?jr.w:1)}}a={count:n,texture:f,stride:u,size:new ge(c,d)},bf.set(r,a),r.addEventListener("dispose",b)}return a}class aY extends ot{static get type(){return"MorphNode"}constructor(t){super("void"),this.mesh=t,this.morphBaseInfluence=dt(1),this.updateType=$t.OBJECT}setup(t){const{geometry:e}=t,s=e.morphAttributes.position!==void 0,i=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=n!==void 0?n.length:0,{texture:o,stride:l,size:h}=nY(e);s===!0&&_e.mulAssign(this.morphBaseInfluence),i===!0&&Fr.mulAssign(this.morphBaseInfluence);const u=N(h.width);Xt(a,({i:c})=>{const d=M(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(ve(this.mesh.morphTexture,Ze(N(c).add(1),N(Gn))).r):d.assign(me("morphTargetInfluences","float").element(c).toVar()),wt(d.notEqual(0),()=>{s===!0&&_e.addAssign(dv({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:N(0)})),i===!0&&Fr.addAssign(dv({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:N(1)}))})})}update(){const t=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?t.value=1:t.value=1-this.mesh.morphTargetInfluences.reduce((e,s)=>e+s,0)}}const Y3=G(aY).setParameterLength(1);class Z3 extends ot{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class oY extends Z3{static get type(){return"AONode"}constructor(t=null){super(),this.aoNode=t}setup(t){t.context.ambientOcclusion.mulAssign(this.aoNode)}}class lY extends U_{static get type(){return"LightingContextNode"}constructor(t,e=null,s=null,i=null){super(t),this.lightingModel=e,this.backdropNode=s,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:t,backdropAlphaNode:e}=this,s=P().toVar("directDiffuse"),i=P().toVar("directSpecular"),n=P().toVar("indirectDiffuse"),a=P().toVar("indirectSpecular"),o={directDiffuse:s,directSpecular:i,indirectDiffuse:n,indirectSpecular:a};return{radiance:P().toVar("radiance"),irradiance:P().toVar("irradiance"),iblIrradiance:P().toVar("iblIrradiance"),ambientOcclusion:M(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:t,backdropAlpha:e}}setup(t){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||t.context.lightingModel,super.setup(t)}}const J3=G(lY);class uY extends Z3{static get type(){return"IrradianceNode"}constructor(t){super(),this.node=t}setup(t){t.context.irradiance.addAssign(this.node)}}let hu,cu;class Be extends ot{static get type(){return"ScreenNode"}constructor(t){super(),this.scope=t,this.isViewportNode=!0}getNodeType(){return this.scope===Be.VIEWPORT?"vec4":"vec2"}getUpdateType(){let t=$t.NONE;return(this.scope===Be.SIZE||this.scope===Be.VIEWPORT)&&(t=$t.RENDER),this.updateType=t,t}update({renderer:t}){const e=t.getRenderTarget();this.scope===Be.VIEWPORT?e!==null?cu.copy(e.viewport):(t.getViewport(cu),cu.multiplyScalar(t.getPixelRatio())):e!==null?(hu.width=e.width,hu.height=e.height):t.getDrawingBufferSize(hu)}setup(){const t=this.scope;let e=null;return t===Be.SIZE?e=dt(hu||(hu=new ge)):t===Be.VIEWPORT?e=dt(cu||(cu=new Mr)):e=Z(kh.div(ep)),e}generate(t){if(this.scope===Be.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){const s=t.getNodeProperties(ep).outputNode.build(t);e=`${t.getType("vec2")}( ${e}.x, ${s}.y - ${e}.y )`}return e}return super.generate(t)}}Be.COORDINATE="coordinate";Be.VIEWPORT="viewport";Be.SIZE="size";Be.UV="uv";const oa=K(Be,Be.UV),ep=K(Be,Be.SIZE),kh=K(Be,Be.COORDINATE),O0=K(Be,Be.VIEWPORT),Q3=O0.zw,K3=kh.sub(O0.xy),hY=K3.div(Q3),cY=L(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),ep),"vec2").once()(),dY=L(()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),oa),"vec2").once()(),pY=L(()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),oa.flipY()),"vec2").once()(),du=new ge;class Wp extends un{static get type(){return"ViewportTextureNode"}constructor(t=oa,e=null,s=null){s===null&&(s=new uS,s.minFilter=tS),super(s,t,e),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=$t.FRAME}updateBefore(t){const e=t.renderer;e.getDrawingBufferSize(du);const s=this.value;(s.image.width!==du.width||s.image.height!==du.height)&&(s.image.width=du.width,s.image.height=du.height,s.needsUpdate=!0);const i=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,e.copyFramebufferToTexture(s),s.generateMipmaps=i}clone(){const t=new this.constructor(this.uvNode,this.levelNode,this.value);return t.generateMipmaps=this.generateMipmaps,t}}const mY=G(Wp).setParameterLength(0,3),fY=G(Wp,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let vf=null;class gY extends Wp{static get type(){return"ViewportDepthTextureNode"}constructor(t=oa,e=null){vf===null&&(vf=new Ah),super(t,e,vf)}}const B0=G(gY).setParameterLength(0,2);class Cr extends ot{static get type(){return"ViewportDepthNode"}constructor(t,e=null){super("float"),this.scope=t,this.valueNode=e,this.isViewportDepthNode=!0}generate(t){const{scope:e}=this;return e===Cr.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){const{scope:e}=this,s=this.valueNode;let i=null;if(e===Cr.DEPTH_BASE)s!==null&&(i=e5().assign(s));else if(e===Cr.DEPTH)t.isPerspectiveCamera?i=t5(or.z,Fn,On):i=fl(or.z,Fn,On);else if(e===Cr.LINEAR_DEPTH)if(s!==null)if(t.isPerspectiveCamera){const n=k0(s,Fn,On);i=fl(n,Fn,On)}else i=s;else i=fl(or.z,Fn,On);return i}}Cr.DEPTH_BASE="depthBase";Cr.DEPTH="depth";Cr.LINEAR_DEPTH="linearDepth";const fl=(r,t,e)=>r.add(t).div(t.sub(e)),yY=(r,t,e)=>t.sub(e).mul(r).sub(t),t5=(r,t,e)=>t.add(r).mul(e).div(e.sub(t).mul(r)),k0=(r,t,e)=>t.mul(e).div(e.sub(t).mul(r).sub(e)),D0=(r,t,e)=>{t=t.max(1e-6).toVar();const s=Ki(r.negate().div(t)),i=Ki(e.div(t));return s.div(i)},xY=(r,t,e)=>{const s=r.mul(m0(e.div(t)));return M(Math.E).pow(s).mul(t).negate()},e5=G(Cr,Cr.DEPTH_BASE),U0=K(Cr,Cr.DEPTH),rp=G(Cr,Cr.LINEAR_DEPTH).setParameterLength(0,1),bY=rp(B0());U0.assign=r=>e5(r);class ys extends ot{static get type(){return"ClippingNode"}constructor(t=ys.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);const e=t.clippingContext,{intersectionPlanes:s,unionPlanes:i}=e;return this.hardwareClipping=t.material.hardwareClipping,this.scope===ys.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(s,i):this.scope===ys.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(s,i)}setupAlphaToCoverage(t,e){return L(()=>{const s=M().toVar("distanceToPlane"),i=M().toVar("distanceToGradient"),n=M(1).toVar("clipOpacity"),a=e.length;if(this.hardwareClipping===!1&&a>0){const l=Hs(e);Xt(a,({i:h})=>{const u=l.element(h);s.assign(or.dot(u.xyz).negate().add(u.w)),i.assign(s.fwidth().div(2)),n.mulAssign(qa(i.negate(),i,s))})}const o=t.length;if(o>0){const l=Hs(t),h=M(1).toVar("intersectionClipOpacity");Xt(o,({i:u})=>{const c=l.element(u);s.assign(or.dot(c.xyz).negate().add(c.w)),i.assign(s.fwidth().div(2)),h.mulAssign(qa(i.negate(),i,s).oneMinus())}),n.mulAssign(h.oneMinus())}os.a.mulAssign(n),os.a.equal(0).discard()})()}setupDefault(t,e){return L(()=>{const s=e.length;if(this.hardwareClipping===!1&&s>0){const n=Hs(e);Xt(s,({i:a})=>{const o=n.element(a);or.dot(o.xyz).greaterThan(o.w).discard()})}const i=t.length;if(i>0){const n=Hs(t),a=xi(!0).toVar("clipped");Xt(i,({i:o})=>{const l=n.element(o);a.assign(or.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(t,e){const s=t.length;return e.enableHardwareClipping(s),L(()=>{const i=Hs(t),n=Dp(e.getClipDistance());Xt(s,({i:a})=>{const o=i.element(a),l=or.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}}ys.ALPHA_TO_COVERAGE="alphaToCoverage";ys.DEFAULT="default";ys.HARDWARE="hardware";const vY=()=>q(new ys),wY=()=>q(new ys(ys.ALPHA_TO_COVERAGE)),MY=()=>q(new ys(ys.HARDWARE)),TY=.05,pv=L(([r])=>pn(yt(1e4,Yr(yt(17,r.x).add(yt(.1,r.y)))).mul(Ee(.1,Qt(Yr(yt(13,r.y).add(r.x))))))),mv=L(([r])=>pv(Z(pv(r.xy),r.z))),NY=L(([r])=>{const t=Ke(Qd(y0(r.xyz)),Qd(x0(r.xyz))),e=M(1).div(M(TY).mul(t)).toVar("pixScale"),s=Z(Il(di(Ki(e))),Il(Op(Ki(e)))),i=Z(mv(di(s.x.mul(r.xyz))),mv(di(s.y.mul(r.xyz)))),n=pn(Ki(e)),a=Ee(yt(n.oneMinus(),i.x),yt(n,i.y)),o=vs(n,n.oneMinus()),l=P(a.mul(a).div(yt(2,o).mul(Ct(1,o))),a.sub(yt(.5,o)).div(Ct(1,o)),Ct(1,Ct(1,a).mul(Ct(1,a)).div(yt(2,o).mul(Ct(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return on(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class SY extends h3{static get type(){return"VertexColorNode"}constructor(t){super(null,"vec4"),this.isVertexColorNode=!0,this.index=t}getAttributeName(){const t=this.index;return"color"+(t>0?t:"")}generate(t){const e=this.getAttributeName(t),s=t.hasGeometryAttribute(e);let i;return s===!0?i=super.generate(t):i=t.generateConst(this.nodeType,new Mr(1,1,1,1)),i}serialize(t){super.serialize(t),t.index=this.index}deserialize(t){super.deserialize(t),this.index=t.index}}const r5=(r=0)=>q(new SY(r));class Pl extends yg{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(t){}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:t=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=t}})}customProgramCacheKey(){return this.type+pS(this)}build(t){this.setup(t)}setupObserver(t){return new Qq(t)}setup(t){t.context.setupNormal=()=>this.setupNormal(t),t.context.setupPositionView=()=>this.setupPositionView(t),t.context.setupModelViewProjection=()=>this.setupModelViewProjection(t);const e=t.renderer,s=e.getRenderTarget();t.addStack();const i=this.setupVertex(t),n=this.vertexNode||i;t.stack.outputNode=n,this.setupHardwareClipping(t),this.geometryNode!==null&&(t.stack.outputNode=t.stack.outputNode.bypass(this.geometryNode)),t.addFlow("vertex",t.removeStack()),t.addStack();let a;const o=this.setupClipping(t);if((this.depthWrite===!0||this.depthTest===!0)&&(s!==null?s.depthBuffer===!0&&this.setupDepth(t):e.depth===!0&&this.setupDepth(t)),this.fragmentNode===null){this.setupDiffuseColor(t),this.setupVariants(t);const l=this.setupLighting(t);o!==null&&t.stack.add(o);const h=pt(l,os.a).max(0);a=this.setupOutput(t,h),ml.assign(a);const u=this.outputNode!==null;if(u&&(a=this.outputNode),s!==null){const c=e.getMRT(),d=this.mrtNode;c!==null?(u&&ml.assign(a),a=c,d!==null&&(a=c.merge(d))):d!==null&&(a=d)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=pt(l)),a=this.setupOutput(t,l)}t.stack.outputNode=a,t.addFlow("fragment",t.removeStack()),t.observer=this.setupObserver(t)}setupClipping(t){if(t.clippingContext===null)return null;const{unionPlanes:e,intersectionPlanes:s}=t.clippingContext;let i=null;if(e.length>0||s.length>0){const n=t.renderer.samples;this.alphaToCoverage&&n>1?i=wY():t.stack.add(vY())}return i}setupHardwareClipping(t){if(this.hardwareClipping=!1,t.clippingContext===null)return;const e=t.clippingContext.unionPlanes.length;e>0&&e<=8&&t.isAvailable("clipDistance")&&(t.stack.add(MY()),this.hardwareClipping=!0)}setupDepth(t){const{renderer:e,camera:s}=t;let i=this.depthNode;if(i===null){const n=e.getMRT();n&&n.has("depth")?i=n.get("depth"):e.logarithmicDepthBuffer===!0&&(s.isPerspectiveCamera?i=D0(or.z,Fn,On):i=fl(or.z,Fn,On))}i!==null&&U0.assign(i).toStack()}setupPositionView(){return Ih.mul(_e).xyz}setupModelViewProjection(){return Lh.mul(or)}setupVertex(t){return t.addStack(),this.setupPosition(t),t.context.vertex=t.removeStack(),D3}setupPosition(t){const{object:e,geometry:s}=t;if((s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Y3(e).toStack(),e.isSkinnedMesh===!0&&G3(e).toStack(),this.displacementMap){const i=Aa("displacementMap","texture"),n=Aa("displacementScale","float"),a=Aa("displacementBias","float");_e.addAssign(Fr.normalize().mul(i.x.mul(n).add(a)))}return e.isBatchedMesh&&q3(e).toStack(),e.isInstancedMesh&&e.instanceMatrix&&e.instanceMatrix.isInstancedBufferAttribute===!0&&W3(e).toStack(),this.positionNode!==null&&_e.assign(r3(this.positionNode,"POSITION")),_e}setupDiffuseColor({object:t,geometry:e}){this.maskNode!==null&&xi(this.maskNode).not().discard();let s=this.colorNode?pt(this.colorNode):I3;this.vertexColors===!0&&e.hasAttribute("color")&&(s=s.mul(r5())),t.instanceColor&&(s=eh("vec3","vInstanceColor").mul(s)),t.isBatchedMesh&&t._colorsTexture&&(s=eh("vec3","vBatchColor").mul(s)),os.assign(s);const i=this.opacityNode?M(this.opacityNode):F3;os.a.assign(os.a.mul(i));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode!==null?M(this.alphaTestNode):L3,os.a.lessThanEqual(n).discard()),this.alphaHash===!0&&os.a.lessThan(NY(_e)).discard(),this.transparent===!1&&this.blending===mg&&this.alphaToCoverage===!1?os.a.assign(1):n===null&&os.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?P(0):os.rgb}setupNormal(){return this.normalNode?P(this.normalNode):O3}setupEnvironment(){let t=null;return this.envNode?t=this.envNode:this.envMap&&(t=this.envMap.isCubeTexture?Aa("envMap","cubeTexture"):Aa("envMap","texture")),t}setupLightMap(t){let e=null;return t.material.lightMap&&(e=new uY(B3)),e}setupLights(t){const e=[],s=this.setupEnvironment(t);s&&s.isLightingNode&&e.push(s);const i=this.setupLightMap(t);if(i&&i.isLightingNode&&e.push(i),this.aoNode!==null||t.material.aoMap){const a=this.aoNode!==null?this.aoNode:k3;e.push(new oY(a))}let n=this.lightsNode||t.lightsNode;return e.length>0&&(n=t.renderer.lighting.createNode([...n.getLights(),...e])),n}setupLightingModel(){}setupLighting(t){const{material:e}=t,{backdropNode:s,backdropAlphaNode:i,emissiveNode:n}=this,o=this.lights===!0||this.lightsNode!==null?this.setupLights(t):null;let l=this.setupOutgoingLight(t);if(o&&o.getScope().hasLights){const h=this.setupLightingModel(t)||null;l=J3(o,h,s,i)}else s!==null&&(l=P(i!==null?Ne(l,s,i):s));return(n&&n.isNode===!0||e.emissive&&e.emissive.isColor===!0)&&(wg.assign(P(n||P3)),l=l.add(wg)),l}setupFog(t,e){const s=t.fogNode;return s&&(ml.assign(e),e=pt(s)),e}setupOutput(t,e){return this.fog===!0&&(e=this.setupFog(t,e)),e}setDefaultValues(t){for(const s in t){const i=t[s];this[s]===void 0&&(this[s]=i,i&&i.clone&&(this[s]=i.clone()))}const e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(const s in e)Object.getOwnPropertyDescriptor(this.constructor.prototype,s)===void 0&&e[s].get!==void 0&&Object.defineProperty(this.constructor.prototype,s,e[s])}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{},nodes:{}});const s=yg.prototype.toJSON.call(this,t),i=Yd(this);s.inputNodes={};for(const{property:a,childNode:o}of i)s.inputNodes[a]=o.toJSON(t).uuid;function n(a){const o=[];for(const l in a){const h=a[l];delete h.metadata,o.push(h)}return o}if(e){const a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(s.textures=a),o.length>0&&(s.images=o),l.length>0&&(s.nodes=l)}return s}copy(t){return this.lightsNode=t.lightsNode,this.envNode=t.envNode,this.colorNode=t.colorNode,this.normalNode=t.normalNode,this.opacityNode=t.opacityNode,this.backdropNode=t.backdropNode,this.backdropAlphaNode=t.backdropAlphaNode,this.alphaTestNode=t.alphaTestNode,this.maskNode=t.maskNode,this.positionNode=t.positionNode,this.geometryNode=t.geometryNode,this.depthNode=t.depthNode,this.receivedShadowPositionNode=t.receivedShadowPositionNode,this.castShadowPositionNode=t.castShadowPositionNode,this.receivedShadowNode=t.receivedShadowNode,this.castShadowNode=t.castShadowNode,this.outputNode=t.outputNode,this.mrtNode=t.mrtNode,this.fragmentNode=t.fragmentNode,this.vertexNode=t.vertexNode,super.copy(t)}}let wf=null;class _Y extends Wp{static get type(){return"ViewportSharedTextureNode"}constructor(t=oa,e=null){wf===null&&(wf=new uS),super(t,e,wf)}updateReference(){return this}}const AY=G(_Y).setParameterLength(0,2),zY=r=>q(r).mul(.5).add(.5),CY=r=>q(r).mul(2).sub(1);class EY extends Re{static get type(){return"EquirectUVNode"}constructor(t=g3){super("vec2"),this.dirNode=t}setup(){const t=this.dirNode,e=t.z.atan(t.x).mul(1/(Math.PI*2)).add(.5),s=t.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Z(e,s)}}const s5=G(EY).setParameterLength(0,1),i5=L(({f0:r,f90:t,dotVH:e})=>{const s=e.mul(-5.55473).sub(6.98316).mul(e).exp2();return r.mul(s.oneMinus()).add(t.mul(s))}),VY=L(r=>r.diffuseColor.mul(1/Math.PI)),n5=L(r=>{if(r.geometry.hasAttribute("normal")===!1)return M(0);const t=vi.dFdx().abs().max(vi.dFdy().abs());return t.x.max(t.y).max(t.z)}),RY=L(r=>{const{roughness:t}=r,e=n5();let s=t.max(.0525);return s=s.add(e),s=s.min(1),s}),a5=L(({alpha:r,dotNL:t,dotNV:e})=>{const s=r.pow2(),i=t.mul(s.add(s.oneMinus().mul(e.pow2())).sqrt()),n=e.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return bi(.5,i.add(n).max(h_))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),LY=L(({alphaT:r,alphaB:t,dotTV:e,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const l=o.mul(P(r.mul(e),t.mul(s),a).length()),h=a.mul(P(r.mul(i),t.mul(n),o).length());return bi(.5,l.add(h)).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"}]}),o5=L(({alpha:r,dotNH:t})=>{const e=r.pow2(),s=t.pow2().mul(e.oneMinus()).oneMinus();return e.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),IY=M(1/Math.PI),PY=L(({alphaT:r,alphaB:t,dotNH:e,dotTH:s,dotBH:i})=>{const n=r.mul(t),a=P(t.mul(s),r.mul(i),n.mul(e)),o=a.dot(a),l=n.div(o);return IY.mul(n.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),FY=L(r=>{const{lightDirection:t,f0:e,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=r,l=r.normalView||hn,h=i.pow2(),u=t.add(Zr).normalize(),c=l.dot(t).clamp(),d=l.dot(Zr).clamp(),p=l.dot(u).clamp(),m=Zr.dot(u).clamp();let f=i5({f0:e,f90:s,dotVH:m}),x,b;if(th(a)&&(f=FS.mix(f,n)),th(o)){const w=vd.dot(t),S=vd.dot(Zr),_=vd.dot(u),V=pl.dot(t),z=pl.dot(Zr),A=pl.dot(u);x=LY({alphaT:Mg,alphaB:h,dotTV:S,dotBV:z,dotTL:w,dotBL:V,dotNV:d,dotNL:c}),b=PY({alphaT:Mg,alphaB:h,dotNH:p,dotTH:_,dotBH:A})}else x=a5({alpha:h,dotNL:c,dotNV:d}),b=o5({alpha:h,dotNH:p});return f.mul(x).mul(b)}),OY=L(({roughness:r,dotNV:t})=>{const e=pt(-1,-.0275,-.572,.022),s=pt(1,.0425,1.04,-.04),i=r.mul(e).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Z(-1.04,1.04).mul(n).add(i.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),BY=L(({f:r,f90:t,dotVH:e})=>{const s=e.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return r.sub(P(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),qp=1/6,l5=r=>yt(qp,yt(r,yt(r,r.negate().add(3)).sub(3)).add(1)),_g=r=>yt(qp,yt(r,yt(r,yt(3,r).sub(6))).add(4)),u5=r=>yt(qp,yt(r,yt(r,yt(-3,r).add(3)).add(3)).add(1)),Ag=r=>yt(qp,Ys(r,3)),fv=r=>l5(r).add(_g(r)),gv=r=>u5(r).add(Ag(r)),yv=r=>Ee(-1,_g(r).div(l5(r).add(_g(r)))),xv=r=>Ee(1,Ag(r).div(u5(r).add(Ag(r)))),bv=(r,t,e)=>{const s=r.uvNode,i=yt(s,t.zw).add(.5),n=di(i),a=pn(i),o=fv(a.x),l=gv(a.x),h=yv(a.x),u=xv(a.x),c=yv(a.y),d=xv(a.y),p=Z(n.x.add(h),n.y.add(c)).sub(.5).mul(t.xy),m=Z(n.x.add(u),n.y.add(c)).sub(.5).mul(t.xy),f=Z(n.x.add(h),n.y.add(d)).sub(.5).mul(t.xy),x=Z(n.x.add(u),n.y.add(d)).sub(.5).mul(t.xy),b=fv(a.y).mul(Ee(o.mul(r.sample(p).level(e)),l.mul(r.sample(m).level(e)))),w=gv(a.y).mul(Ee(o.mul(r.sample(f).level(e)),l.mul(r.sample(x).level(e))));return b.add(w)},kY=L(([r,t=M(3)])=>{const e=Z(r.size(N(t))),s=Z(r.size(N(t.add(1)))),i=bi(1,e),n=bi(1,s),a=bv(r,pt(i,e),di(t)),o=bv(r,pt(n,s),Op(t));return pn(t).mix(a,o)});P(.04);M(1);const vv=M(1),zg=M(-2),Yc=M(.8),Mf=M(-1),Zc=M(.4),Tf=M(2),Jc=M(.305),Nf=M(3),wv=M(.21),DY=M(4),Mv=M(4),UY=M(16),$Y=L(([r])=>{const t=P(Qt(r)).toVar(),e=M(-1).toVar();return wt(t.x.greaterThan(t.z),()=>{wt(t.x.greaterThan(t.y),()=>{e.assign(xr(r.x.greaterThan(0),0,3))}).Else(()=>{e.assign(xr(r.y.greaterThan(0),1,4))})}).Else(()=>{wt(t.z.greaterThan(t.y),()=>{e.assign(xr(r.z.greaterThan(0),2,5))}).Else(()=>{e.assign(xr(r.y.greaterThan(0),1,4))})}),e}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),jY=L(([r,t])=>{const e=Z().toVar();return wt(t.equal(0),()=>{e.assign(Z(r.z,r.y).div(Qt(r.x)))}).ElseIf(t.equal(1),()=>{e.assign(Z(r.x.negate(),r.z.negate()).div(Qt(r.y)))}).ElseIf(t.equal(2),()=>{e.assign(Z(r.x.negate(),r.y).div(Qt(r.z)))}).ElseIf(t.equal(3),()=>{e.assign(Z(r.z.negate(),r.y).div(Qt(r.x)))}).ElseIf(t.equal(4),()=>{e.assign(Z(r.x.negate(),r.z).div(Qt(r.y)))}).Else(()=>{e.assign(Z(r.x,r.y).div(Qt(r.z)))}),yt(.5,e.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),WY=L(([r])=>{const t=M(0).toVar();return wt(r.greaterThanEqual(Yc),()=>{t.assign(vv.sub(r).mul(Mf.sub(zg)).div(vv.sub(Yc)).add(zg))}).ElseIf(r.greaterThanEqual(Zc),()=>{t.assign(Yc.sub(r).mul(Tf.sub(Mf)).div(Yc.sub(Zc)).add(Mf))}).ElseIf(r.greaterThanEqual(Jc),()=>{t.assign(Zc.sub(r).mul(Nf.sub(Tf)).div(Zc.sub(Jc)).add(Tf))}).ElseIf(r.greaterThanEqual(wv),()=>{t.assign(Jc.sub(r).mul(DY.sub(Nf)).div(Jc.sub(wv)).add(Nf))}).Else(()=>{t.assign(M(-2).mul(Ki(yt(1.16,r))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),h5=L(([r,t])=>{const e=r.toVar();e.assign(yt(2,e).sub(1));const s=P(e,1).toVar();return wt(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),c5=L(([r,t,e,s,i,n])=>{const a=M(e),o=P(t),l=on(WY(a),zg,n),h=pn(l),u=di(l),c=P(Cg(r,o,u,s,i,n)).toVar();return wt(h.notEqual(0),()=>{const d=P(Cg(r,o,u.add(1),s,i,n)).toVar();c.assign(Ne(c,d,h))}),c}),Cg=L(([r,t,e,s,i,n])=>{const a=M(e).toVar(),o=P(t),l=M($Y(o)).toVar(),h=M(Ke(Mv.sub(a),0)).toVar();a.assign(Ke(a,Mv));const u=M(Il(a)).toVar(),c=Z(jY(o,l).mul(u.sub(2)).add(1)).toVar();return wt(l.greaterThan(2),()=>{c.y.addAssign(u),l.subAssign(3)}),c.x.addAssign(l.mul(u)),c.x.addAssign(h.mul(yt(3,UY))),c.y.addAssign(yt(4,Il(n).sub(u))),c.x.mulAssign(s),c.y.mulAssign(i),r.sample(c).grad(Z(),Z())}),Sf=L(({envMap:r,mipInt:t,outputDirection:e,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Ui(s),h=e.mul(l).add(i.cross(e).mul(Yr(s))).add(i.mul(i.dot(e).mul(l.oneMinus())));return Cg(r,h,t,n,a,o)}),d5=L(({n:r,latitudinal:t,poleAxis:e,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{const d=P(xr(t,e,kp(e,s))).toVar();wt(d.equal(P(0)),()=>{d.assign(P(s.z,0,s.x.negate()))}),d.assign(Ka(d));const p=P().toVar();return p.addAssign(i.element(0).mul(Sf({theta:0,axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Xt({start:N(1),end:r},({i:m})=>{wt(m.greaterThanEqual(n),()=>{X3()});const f=M(a.mul(M(m))).toVar();p.addAssign(i.element(m).mul(Sf({theta:f.mul(-1),axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(m).mul(Sf({theta:f,axis:d,outputDirection:s,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))}),pt(p,1)}),el=4,Tv=[.125,.215,.35,.446,.526,.582],za=20,_f=new hS(-1,1,1,-1,0,1),qY=new qq(90,1),Nv=new dn;let Af=null,zf=0,Cf=0;const Na=(1+Math.sqrt(5))/2,Bo=1/Na,Sv=[new k(-Na,Bo,0),new k(Na,Bo,0),new k(-Bo,0,Na),new k(Bo,0,Na),new k(0,Na,-Bo),new k(0,Na,Bo),new k(-1,1,-1),new k(1,1,-1),new k(-1,1,1),new k(1,1,1)],HY=new k,p5=new WeakMap,GY=[3,1,5,0,4,2],Ef=h5(le(),sa("faceIndex")).normalize(),$0=P(Ef.x,Ef.y,Ef.z);class XY{constructor(t){this._renderer=t,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(t,e=0,s=.1,i=100,n={}){const{size:a=256,position:o=HY,renderTarget:l=null}=n;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const u=l||this._allocateTarget();return n.renderTarget=u,this.fromSceneAsync(t,e,s,i,n),u}Af=this._renderer.getRenderTarget(),zf=this._renderer.getActiveCubeFace(),Cf=this._renderer.getActiveMipmapLevel();const h=l||this._allocateTarget();return h.depthBuffer=!0,this._init(h),this._sceneToCubeUV(t,s,i,h,o),e>0&&this._blur(h,0,0,e),this._applyPMREM(h),this._cleanup(h),h}async fromSceneAsync(t,e=0,s=.1,i=100,n={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(t,e,s,i,n)}fromEquirectangular(t,e=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(t);const s=e||this._allocateTarget();return this.fromEquirectangularAsync(t,s),s}return this._fromTexture(t,e)}async fromEquirectangularAsync(t,e=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(t,e)}fromCubemap(t,e=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(t);const s=e||this._allocateTarget();return this.fromCubemapAsync(t,e),s}return this._fromTexture(t,e)}async fromCubemapAsync(t,e=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(t,e)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Av(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zv(),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(t){t.mapping===jd||t.mapping===gg?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4)}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Af,zf,Cf),t.scissorTest=!1,Qc(t,0,0,t.width,t.height)}_fromTexture(t,e){this._setSizeFromTexture(t),Af=this._renderer.getRenderTarget(),zf=this._renderer.getActiveCubeFace(),Cf=this._renderer.getActiveMipmapLevel();const s=e||this._allocateTarget();return this._init(s),this._textureToCubeUV(t,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTarget(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize;return _v(t,e)}_init(t){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t.width||this._pingPongRenderTarget.height!==t.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_v(t.width,t.height);const{_lodMax:e}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=YY(e)),this._blurMaterial=ZY(e,t.width,t.height)}}async _compileMaterial(t){const e=new Xd(this._lodPlanes[0],t);await this._renderer.compile(e,_f)}_sceneToCubeUV(t,e,s,i,n){const a=qY;a.near=e,a.far=s;const o=[1,1,1,1,-1,1],l=[1,-1,1,-1,1,-1],h=this._renderer,u=h.autoClear;h.getClearColor(Nv),h.autoClear=!1;let c=this._backgroundBox;if(c===null){const m=new aS({name:"PMREM.Background",side:Vp,depthWrite:!1,depthTest:!1});c=new Xd(new i0,m)}let d=!1;const p=t.background;p?p.isColor&&(c.material.color.copy(p),t.background=null,d=!0):(c.material.color.copy(Nv),d=!0),h.setRenderTarget(i),h.clear(),d&&h.render(c,a);for(let m=0;m<6;m++){const f=m%3;f===0?(a.up.set(0,o[m],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[m],n.y,n.z)):f===1?(a.up.set(0,0,o[m]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[m],n.z)):(a.up.set(0,o[m],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[m]));const x=this._cubeSize;Qc(i,f*x,m>2?x:0,x,x),h.render(t,a)}h.autoClear=u,t.background=p}_textureToCubeUV(t,e){const s=this._renderer,i=t.mapping===jd||t.mapping===gg;i?this._cubemapMaterial===null&&(this._cubemapMaterial=Av(t)):this._equirectMaterial===null&&(this._equirectMaterial=zv(t));const n=i?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=t;const a=this._lodMeshes[0];a.material=n;const o=this._cubeSize;Qc(e,0,0,3*o,2*o),s.setRenderTarget(e),s.render(a,_f)}_applyPMREM(t){const e=this._renderer,s=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let n=1;n<i;n++){const a=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=Sv[(i-n-1)%Sv.length];this._blur(t,n-1,n,a,o)}e.autoClear=s}_blur(t,e,s,i,n){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,s,i,"latitudinal",n),this._halfBlur(a,t,s,s,i,"longitudinal",n)}_halfBlur(t,e,s,i,n,a,o){const l=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,c=this._lodMeshes[i];c.material=h;const d=p5.get(h),p=this._sizeLods[s]-1,m=isFinite(n)?Math.PI/(2*p):2*Math.PI/(2*za-1),f=n/m,x=isFinite(n)?1+Math.floor(u*f):za;x>za&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${za}`);const b=[];let w=0;for(let A=0;A<za;++A){const I=A/f,et=Math.exp(-I*I/2);b.push(et),A===0?w+=et:A<x&&(w+=2*et)}for(let A=0;A<b.length;A++)b[A]=b[A]/w;t.texture.frame=(t.texture.frame||0)+1,d.envMap.value=t.texture,d.samples.value=x,d.weights.array=b,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:S}=this;d.dTheta.value=m,d.mipInt.value=S-s;const _=this._sizeLods[i],V=3*_*(i>S-el?i-S+el:0),z=4*(this._cubeSize-_);Qc(e,V,z,3*_,2*_),l.setRenderTarget(e),l.render(c,_f)}}function YY(r){const t=[],e=[],s=[],i=[];let n=r;const a=r-el+1+Tv.length;for(let o=0;o<a;o++){const l=Math.pow(2,n);e.push(l);let h=1/l;o>r-el?h=Tv[o-r+el-1]:o===0&&(h=0),s.push(h);const u=1/(l-2),c=-u,d=1+u,p=[c,c,d,c,d,d,c,c,d,d,c,d],m=6,f=6,x=3,b=2,w=1,S=new Float32Array(x*f*m),_=new Float32Array(b*f*m),V=new Float32Array(w*f*m);for(let A=0;A<m;A++){const I=A%3*2/3-1,et=A>2?0:-1,nt=[I,et,0,I+2/3,et,0,I+2/3,et+1,0,I,et,0,I+2/3,et+1,0,I,et+1,0],it=GY[A];S.set(nt,x*f*it),_.set(p,b*f*it);const vt=[it,it,it,it,it,it];V.set(vt,w*f*it)}const z=new $l;z.setAttribute("position",new gs(S,x)),z.setAttribute("uv",new gs(_,b)),z.setAttribute("faceIndex",new gs(V,w)),t.push(z),i.push(new Xd(z,null)),n>el&&n--}return{lodPlanes:t,sizeLods:e,sigmas:s,lodMeshes:i}}function _v(r,t){const e={magFilter:Qu,minFilter:Qu,generateMipmaps:!1,type:Dn,format:sS,colorSpace:qd},s=new Sh(r,t,e);return s.texture.mapping=eq,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Qc(r,t,e,s,i){r.viewport.set(t,e,s,i),r.scissor.set(t,e,s,i)}function j0(r){const t=new Pl;return t.depthTest=!1,t.depthWrite=!1,t.blending=KW,t.name=`PMREM_${r}`,t}function ZY(r,t,e){const s=Hs(new Array(za).fill(0)),i=dt(new k(0,1,0)),n=dt(0),a=M(za),o=dt(0),l=dt(1),h=Gt(null),u=dt(0),c=M(1/t),d=M(1/e),p=M(r),m={n:a,latitudinal:o,weights:s,poleAxis:i,outputDirection:$0,dTheta:n,samples:l,envMap:h,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},f=j0("blur");return f.fragmentNode=d5({...m,latitudinal:o.equal(1)}),p5.set(f,m),f}function Av(r){const t=j0("cubemap");return t.fragmentNode=I0(r,$0),t}function zv(r){const t=j0("equirect");return t.fragmentNode=Gt(r,s5($0),0),t}const Cv=new WeakMap;function JY(r){const t=Math.log2(r)-2,e=1/r;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:e,maxMip:t}}function QY(r,t,e){const s=KY(t);let i=s.get(r);if((i!==void 0?i.pmremVersion:-1)!==r.pmremVersion){const a=r.image;if(r.isCubeTexture)if(eZ(a))i=e.fromCubemap(r,i);else return null;else if(rZ(a))i=e.fromEquirectangular(r,i);else return null;i.pmremVersion=r.pmremVersion,s.set(r,i)}return i.texture}function KY(r){let t=Cv.get(r);return t===void 0&&(t=new WeakMap,Cv.set(r,t)),t}class tZ extends Re{static get type(){return"PMREMNode"}constructor(t,e=null,s=null){super("vec3"),this._value=t,this._pmrem=null,this.uvNode=e,this.levelNode=s,this._generator=null;const i=new Rr;i.isRenderTargetTexture=!0,this._texture=Gt(i),this._width=dt(0),this._height=dt(0),this._maxMip=dt(0),this.updateBeforeType=$t.RENDER}set value(t){this._value=t,this._pmrem=null}get value(){return this._value}updateFromTexture(t){const e=JY(t.image.height);this._texture.value=t,this._width.value=e.texelWidth,this._height.value=e.texelHeight,this._maxMip.value=e.maxMip}updateBefore(t){let e=this._pmrem;const s=e?e.pmremVersion:-1,i=this._value;s!==i.pmremVersion&&(i.isPMREMTexture===!0?e=i:e=QY(i,t.renderer,this._generator),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(t){this._generator===null&&(this._generator=new XY(t.renderer)),this.updateBefore(t);let e=this.uvNode;e===null&&t.context.getUV&&(e=t.context.getUV(this)),e=R0.mul(P(e.x,e.y.negate(),e.z));let s=this.levelNode;return s===null&&t.context.getTextureLevel&&(s=t.context.getTextureLevel(this)),c5(this._texture,e,s,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function eZ(r){if(r==null)return!1;let t=0;const e=6;for(let s=0;s<e;s++)r[s]!==void 0&&t++;return t===e}function rZ(r){return r==null?!1:r.height>0}const sZ=G(tZ).setParameterLength(1,3);class iZ extends Re{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const t=P(Zr.z,0,Zr.x.negate()).normalize(),e=Zr.cross(t);return Z(t.dot(hn),e.dot(hn)).mul(.495).add(.5)}}const nZ=K(iZ);class aZ extends Re{static get type(){return"RotateNode"}constructor(t,e){super(),this.positionNode=t,this.rotationNode=e}getNodeType(t){return this.positionNode.getNodeType(t)}setup(t){const{rotationNode:e,positionNode:s}=this;if(this.getNodeType(t)==="vec2"){const n=e.cos(),a=e.sin();return Pp(n,a,a.negate(),n).mul(s)}else{const n=e,a=Fa(pt(1,0,0,0),pt(0,Ui(n.x),Yr(n.x).negate(),0),pt(0,Yr(n.x),Ui(n.x),0),pt(0,0,0,1)),o=Fa(pt(Ui(n.y),0,Yr(n.y),0),pt(0,1,0,0),pt(Yr(n.y).negate(),0,Ui(n.y),0),pt(0,0,0,1)),l=Fa(pt(Ui(n.z),Yr(n.z).negate(),0,0),pt(Yr(n.z),Ui(n.z),0,0),pt(0,0,1,0),pt(0,0,0,1));return a.mul(o).mul(l).mul(pt(s,1)).xyz}}}const m5=G(aZ).setParameterLength(2);ql("vec3");ql("vec3");ql("vec3");class oZ{constructor(){this.weakMap=new WeakMap}get(t){let e=this.weakMap;for(let s=0;s<t.length-1;s++)if(e=e.get(t[s]),e===void 0)return;return e.get(t[t.length-1])}set(t,e){let s=this.weakMap;for(let i=0;i<t.length-1;i++){const n=t[i];s.has(n)===!1&&s.set(n,new WeakMap),s=s.get(n)}return s.set(t[t.length-1],e),this}delete(t){let e=this.weakMap;for(let s=0;s<t.length-1;s++)if(e=e.get(t[s]),e===void 0)return!1;return e.delete(t[t.length-1])}}class lZ extends Ot{static get type(){return"ParameterNode"}constructor(t,e=null){super(t,e),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const uZ=(r,t)=>q(new lZ(r,t));class hZ extends ot{static get type(){return"StackNode"}constructor(t=null){super(),this.nodes=[],this.outputNode=null,this.parent=t,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(t){return this.outputNode?this.outputNode.getNodeType(t):"void"}getMemberType(t,e){return this.outputNode?this.outputNode.getMemberType(t,e):"void"}add(t){return this.nodes.push(t),this}If(t,e){const s=new tl(e);return this._currentCond=xr(t,s),this.add(this._currentCond)}ElseIf(t,e){const s=new tl(e),i=xr(t,s);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(t){return this._currentCond.elseNode=new tl(t),this}Switch(t){return this._expressionNode=q(t),this}Case(...t){const e=[];if(t.length>=2)for(let o=0;o<t.length-1;o++)e.push(this._expressionNode.equal(q(t[o])));else throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");const s=t[t.length-1],i=new tl(s);let n=e[0];for(let o=1;o<e.length;o++)n=n.or(e[o]);const a=xr(n,i);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(t){return this.Else(t),this}build(t,...e){const s=SS();vg(this);const i=t.buildStage;for(const n of this.nodes)if(i==="setup")n.build(t);else if(i==="analyze")n.build(t,this);else if(i==="generate"){const a=t.getDataFromNode(n,"any").stages,o=a&&a[t.shaderStage];if(n.isVarNode&&o&&o.length===1&&o[0]&&o[0].isStackNode)continue;n.build(t,"void")}return vg(s),this.outputNode?this.outputNode.build(t,...e):super.build(t,...e)}else(...t){return console.warn("THREE.TSL: .else() has been renamed to .Else()."),this.Else(...t)}elseif(...t){return console.warn("THREE.TSL: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...t)}}const cZ=G(hZ).setParameterLength(0,1);function dZ(r){return Object.entries(r).map(([t,e])=>typeof e=="string"?{name:t,type:e,atomic:!1}:{name:t,type:e.type,atomic:e.atomic||!1})}class pZ extends ot{static get type(){return"StructTypeNode"}constructor(t,e=null){super("struct"),this.membersLayout=dZ(t),this.name=e,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let s=0;for(const i of this.membersLayout){const n=i.type,a=rH(n)*e,o=sH(n),l=s%8,h=l%o,u=l+h;s+=h,u!==0&&8-u<a&&(s+=8-u),s+=a}return Math.ceil(s/8)*8/e}getMemberType(t,e){const s=this.membersLayout.find(i=>i.name===e);return s?s.type:"void"}getNodeType(t){return t.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(t){t.addInclude(this)}generate(t){return this.getNodeType(t)}}class mZ extends ot{static get type(){return"StructNode"}constructor(t,e){super("vec3"),this.structLayoutNode=t,this.values=e,this.isStructNode=!0}getNodeType(t){return this.structLayoutNode.getNodeType(t)}getMemberType(t,e){return this.structLayoutNode.getMemberType(t,e)}generate(t){const e=t.getVarFromNode(this),s=e.type,i=t.getPropertyName(e);return t.addLineFlowCode(`${i} = ${t.generateStruct(s,this.structLayoutNode.membersLayout,this.values)}`,this),e.name}}const fZ=(r,t=null)=>{const e=new pZ(r,t),s=(...i)=>{let n=null;if(i.length>0)if(i[0].isNode){n={};const a=Object.keys(r);for(let o=0;o<i.length;o++)n[a[o]]=i[o]}else n=i[0];return q(new mZ(e,n))};return s.layout=e,s.isStruct=!0,s};class f5 extends ot{static get type(){return"OutputStructNode"}constructor(...t){super(),this.members=t,this.isOutputStructNode=!0}getNodeType(t){const e=t.getNodeProperties(this);if(e.membersLayout===void 0){const s=this.members,i=[];for(let n=0;n<s.length;n++){const a="m"+n,o=s[n].getNodeType(t);i.push({name:a,type:o,index:n})}e.membersLayout=i,e.structType=t.getOutputStructTypeFromNode(this,e.membersLayout)}return e.structType.name}generate(t){const e=t.getOutputStructName(),s=this.members,i=e!==""?e+".":"";for(let n=0;n<s.length;n++){const a=s[n].build(t);t.addLineFlowCode(`${i}m${n} = ${a}`,this)}return e}}const gZ=G(f5);function g5(r,t){for(let e=0;e<r.length;e++)if(r[e].name===t)return e;return-1}class yZ extends f5{static get type(){return"MRTNode"}constructor(t){super(),this.outputNodes=t,this.isMRTNode=!0}has(t){return this.outputNodes[t]!==void 0}get(t){return this.outputNodes[t]}merge(t){const e={...this.outputNodes,...t.outputNodes};return y5(e)}setup(t){const e=this.outputNodes,s=t.renderer.getRenderTarget(),i=[],n=s.textures;for(const a in e){const o=g5(n,a);i[o]=pt(e[a])}return this.members=i,super.setup(t)}}const y5=G(yZ),xZ=L(([r])=>{const t=r.toUint().mul(747796405).add(2891336453),e=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return e.shiftRight(22).bitXor(e).toFloat().mul(1/2**32)}),Eg=(r,t)=>Ys(yt(4,r.mul(Ct(1,r))),t),bZ=(r,t)=>r.lessThan(.5)?Eg(r.mul(2),t).div(2):Ct(1,Eg(yt(Ct(1,r),2),t).div(2)),vZ=(r,t,e)=>Ys(bi(Ys(r,t),Ee(Ys(r,t),Ys(Ct(1,r),e))),1/t),wZ=(r,t)=>Yr(Jd.mul(t.mul(r).sub(1))).div(Jd.mul(t.mul(r).sub(1))),$i=L(([r])=>r.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),MZ=L(([r])=>P($i(r.z.add($i(r.y.mul(1)))),$i(r.z.add($i(r.x.mul(1)))),$i(r.y.add($i(r.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),TZ=L(([r,t,e])=>{const s=P(r).toVar(),i=M(1.4).toVar(),n=M(0).toVar(),a=P(s).toVar();return Xt({start:M(0),end:M(3),type:"float",condition:"<="},()=>{const o=P(MZ(a.mul(2))).toVar();s.addAssign(o.add(e.mul(M(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const l=M($i(s.z.add($i(s.x.add($i(s.y)))))).toVar();n.addAssign(l.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class NZ extends ot{static get type(){return"FunctionOverloadingNode"}constructor(t=[],...e){super(),this.functionNodes=t,this.parametersNodes=e,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(t){const e=this.parametersNodes;let s=this._candidateFnCall;if(s===null){let i=null,n=-1;for(const a of this.functionNodes){const l=a.shaderNode.layout;if(l===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=l.inputs;if(e.length===h.length){let u=0;for(let c=0;c<e.length;c++){const d=e[c],p=h[c];d.getNodeType(t)===p.type?u++:u=0}u>n&&(i=a,n=u)}}this._candidateFnCall=s=i(...e)}return s}}const SZ=G(NZ),cr=r=>(...t)=>SZ(r,...t),to=dt(0).setGroup(Nt).onRenderUpdate(r=>r.time),x5=dt(0).setGroup(Nt).onRenderUpdate(r=>r.deltaTime),_Z=dt(0,"uint").setGroup(Nt).onRenderUpdate(r=>r.frameId),AZ=(r=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),to.mul(r)),zZ=(r=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),to.mul(r)),CZ=(r=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),x5.mul(r)),EZ=(r=to)=>r.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),VZ=(r=to)=>r.fract().round(),RZ=(r=to)=>r.add(.5).fract().mul(2).sub(1).abs(),LZ=(r=to)=>r.fract(),IZ=L(([r,t,e=Z(.5)])=>m5(r.sub(e),t).add(e)),PZ=L(([r,t,e=Z(.5)])=>{const s=r.sub(e),i=s.dot(s),a=i.mul(i).mul(t);return r.add(s.mul(a))}),FZ=L(({position:r=null,horizontal:t=!0,vertical:e=!1})=>{let s;r!==null?(s=qi.toVar(),s[3][0]=r.x,s[3][1]=r.y,s[3][2]=r.z):s=qi;const i=_s.mul(s);return th(t)&&(i[0][0]=qi[0].length(),i[0][1]=0,i[0][2]=0),th(e)&&(i[1][0]=0,i[1][1]=qi[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Lh.mul(i).mul(_e)}),OZ=L(([r=null])=>{const t=rp();return rp(B0(r)).sub(t).lessThan(0).select(oa,r)});class BZ extends ot{static get type(){return"SpriteSheetUVNode"}constructor(t,e=le(),s=M(0)){super("vec2"),this.countNode=t,this.uvNode=e,this.frameNode=s}setup(){const{frameNode:t,uvNode:e,countNode:s}=this,{width:i,height:n}=s,a=t.mod(i.mul(n)).floor(),o=a.mod(i),l=n.sub(a.add(1).div(i).ceil()),h=s.reciprocal(),u=Z(o,l);return e.add(u).mul(h)}}const kZ=G(BZ).setParameterLength(3);class DZ extends ot{static get type(){return"TriplanarTexturesNode"}constructor(t,e=null,s=null,i=M(1),n=_e,a=Fr){super("vec4"),this.textureXNode=t,this.textureYNode=e,this.textureZNode=s,this.scaleNode=i,this.positionNode=n,this.normalNode=a}setup(){const{textureXNode:t,textureYNode:e,textureZNode:s,scaleNode:i,positionNode:n,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(P(1)));const l=n.yz.mul(i),h=n.zx.mul(i),u=n.xy.mul(i),c=t.value,d=e!==null?e.value:c,p=s!==null?s.value:c,m=Gt(c,l).mul(o.x),f=Gt(d,h).mul(o.y),x=Gt(p,u).mul(o.z);return Ee(m,f,x)}}const b5=G(DZ).setParameterLength(1,6),UZ=(...r)=>b5(...r),ko=new Yq,ya=new k,Do=new k,Vf=new k,pu=new Zt,Kc=new k(0,0,-1),si=new Mr,mu=new k,td=new k,fu=new Mr,ed=new ge,sp=new Sh,$Z=oa.flipX();sp.depthTexture=new Ah(1,1);let rd=!1;class W0 extends un{static get type(){return"ReflectorNode"}constructor(t={}){super(t.defaultTexture||sp.texture,$Z),this._reflectorBaseNode=t.reflector||new jZ(this,t),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 new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=q(new W0({defaultTexture:sp.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(t){return t.object.isQuadMesh||this._reflectorBaseNode.build(t),super.setup(t)}clone(){const t=new this.constructor(this.reflectorNode);return t._reflectorBaseNode=this._reflectorBaseNode,t}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class jZ extends ot{static get type(){return"ReflectorBaseNode"}constructor(t,e={}){super();const{target:s=new Zs,resolution:i=1,generateMipmaps:n=!1,bounces:a=!0,depth:o=!1}=e;this.textureNode=t,this.target=s,this.resolution=i,this.generateMipmaps=n,this.bounces=a,this.depth=o,this.updateBeforeType=a?$t.RENDER:$t.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(t,e){const s=this.resolution;e.getDrawingBufferSize(ed),t.setSize(Math.round(ed.width*s),Math.round(ed.height*s))}setup(t){return this._updateResolution(sp,t.renderer),super.setup(t)}dispose(){super.dispose();for(const t of this.renderTargets.values())t.dispose()}getVirtualCamera(t){let e=this.virtualCameras.get(t);return e===void 0&&(e=t.clone(),this.virtualCameras.set(t,e)),e}getRenderTarget(t){let e=this.renderTargets.get(t);return e===void 0&&(e=new Sh(0,0,{type:Dn}),this.generateMipmaps===!0&&(e.texture.minFilter=rq,e.texture.generateMipmaps=!0),this.depth===!0&&(e.depthTexture=new Ah),this.renderTargets.set(t,e)),e}updateBefore(t){if(this.bounces===!1&&rd)return!1;rd=!0;const{scene:e,camera:s,renderer:i,material:n}=t,{target:a}=this,o=this.getVirtualCamera(s),l=this.getRenderTarget(o);i.getDrawingBufferSize(ed),this._updateResolution(l,i),Do.setFromMatrixPosition(a.matrixWorld),Vf.setFromMatrixPosition(s.matrixWorld),pu.extractRotation(a.matrixWorld),ya.set(0,0,1),ya.applyMatrix4(pu),mu.subVectors(Do,Vf);const h=mu.dot(ya)>0;let u=!1;if(h===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){rd=!1;return}u=!0}mu.reflect(ya).negate(),mu.add(Do),pu.extractRotation(s.matrixWorld),Kc.set(0,0,-1),Kc.applyMatrix4(pu),Kc.add(Vf),td.subVectors(Do,Kc),td.reflect(ya).negate(),td.add(Do),o.coordinateSystem=s.coordinateSystem,o.position.copy(mu),o.up.set(0,1,0),o.up.applyMatrix4(pu),o.up.reflect(ya),o.lookAt(td),o.near=s.near,o.far=s.far,o.updateMatrixWorld(),o.projectionMatrix.copy(s.projectionMatrix),ko.setFromNormalAndCoplanarPoint(ya,Do),ko.applyMatrix4(o.matrixWorldInverse),si.set(ko.normal.x,ko.normal.y,ko.normal.z,ko.constant);const c=o.projectionMatrix;fu.x=(Math.sign(si.x)+c.elements[8])/c.elements[0],fu.y=(Math.sign(si.y)+c.elements[9])/c.elements[5],fu.z=-1,fu.w=(1+c.elements[10])/c.elements[14],si.multiplyScalar(1/si.dot(fu));const d=0;c.elements[2]=si.x,c.elements[6]=si.y,c.elements[10]=i.coordinateSystem===ja?si.z-d:si.z+1-d,c.elements[14]=si.w,this.textureNode.value=l.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=l.depthTexture),n.visible=!1;const p=i.getRenderTarget(),m=i.getMRT(),f=i.autoClear;i.setMRT(null),i.setRenderTarget(l),i.autoClear=!0,u?(i.clear(),this.hasOutput=!1):(i.render(e,o),this.hasOutput=!0),i.setMRT(m),i.setRenderTarget(p),i.autoClear=f,n.visible=!0,rd=!1,this.forceUpdate=!1}}const WZ=r=>q(new W0(r)),Rf=new hS(-1,1,1,-1,0,1);class qZ extends $l{constructor(t=!1){super();const e=t===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new cl([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new cl(e,2))}}const HZ=new qZ;class v5 extends Xd{constructor(t=null){super(HZ,t),this.camera=Rf,this.isQuadMesh=!0}async renderAsync(t){return t.renderAsync(this,Rf)}render(t){t.render(this,Rf)}}const GZ=new ge;class XZ extends un{static get type(){return"RTTNode"}constructor(t,e=null,s=null,i={type:Dn}){const n=new Sh(e,s,i);super(n.texture,le()),this.node=t,this.width=e,this.height=s,this.pixelRatio=1,this.renderTarget=n,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new v5(new Pl),this.updateBeforeType=$t.RENDER}get autoSize(){return this.width===null}setup(t){return this._rttNode=this.node.context(t.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(t)}setSize(t,e){this.width=t,this.height=e;const s=t*this.pixelRatio,i=e*this.pixelRatio;this.renderTarget.setSize(s,i),this.textureNeedsUpdate=!0}setPixelRatio(t){this.pixelRatio=t,this.setSize(this.width,this.height)}updateBefore({renderer:t}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=t.getPixelRatio();const s=t.getSize(GZ);this.setSize(s.width,s.height)}this._quadMesh.material.fragmentNode=this._rttNode;const e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),this._quadMesh.render(t),t.setRenderTarget(e)}clone(){const t=new un(this.value,this.uvNode,this.levelNode);return t.sampler=this.sampler,t.referenceNode=this,t}}const w5=(r,...t)=>q(new XZ(q(r),...t)),YZ=(r,...t)=>r.isTextureNode?r:r.isPassNode?r.getTextureNode():w5(r,...t),Yo=L(([r,t,e],s)=>{let i;s.renderer.coordinateSystem===ja?(r=Z(r.x,r.y.oneMinus()).mul(2).sub(1),i=pt(P(r,t),1)):i=pt(P(r.x,r.y.oneMinus(),t).mul(2).sub(1),1);const n=pt(e.mul(i));return n.xyz.div(n.w)}),ZZ=L(([r,t])=>{const e=t.mul(pt(r,1)),s=e.xy.div(e.w).mul(.5).add(.5).toVar();return Z(s.x,s.y.oneMinus())}),JZ=L(([r,t,e])=>{const s=Hn(ve(t)),i=Ze(r.mul(s)).toVar(),n=ve(t,i).toVar(),a=ve(t,i.sub(Ze(2,0))).toVar(),o=ve(t,i.sub(Ze(1,0))).toVar(),l=ve(t,i.add(Ze(1,0))).toVar(),h=ve(t,i.add(Ze(2,0))).toVar(),u=ve(t,i.add(Ze(0,2))).toVar(),c=ve(t,i.add(Ze(0,1))).toVar(),d=ve(t,i.sub(Ze(0,1))).toVar(),p=ve(t,i.sub(Ze(0,2))).toVar(),m=Qt(Ct(M(2).mul(o).sub(a),n)).toVar(),f=Qt(Ct(M(2).mul(l).sub(h),n)).toVar(),x=Qt(Ct(M(2).mul(c).sub(u),n)).toVar(),b=Qt(Ct(M(2).mul(d).sub(p),n)).toVar(),w=Yo(r,n,e).toVar(),S=m.lessThan(f).select(w.sub(Yo(r.sub(Z(M(1).div(s.x),0)),o,e)),w.negate().add(Yo(r.add(Z(M(1).div(s.x),0)),l,e))),_=x.lessThan(b).select(w.sub(Yo(r.add(Z(0,M(1).div(s.y))),c,e)),w.negate().add(Yo(r.sub(Z(0,M(1).div(s.y))),d,e)));return Ka(kp(S,_))});class QZ extends dl{constructor(t,e,s=Float32Array){const i=ArrayBuffer.isView(t)?t:new s(t*e);super(i,e),this.isStorageInstancedBufferAttribute=!0}}class KZ extends gs{constructor(t,e,s=Float32Array){const i=ArrayBuffer.isView(t)?t:new s(t*e);super(i,e),this.isStorageBufferAttribute=!0}}const tJ=(r,t="float")=>{let e,s;t.isStruct===!0?(e=t.layout.getLength(),s=Zd("float")):(e=mS(t),s=Zd(t));const i=new KZ(r,e,s);return Ba(i,t,r)},eJ=(r,t="float")=>{let e,s;t.isStruct===!0?(e=t.layout.getLength(),s=Zd("float")):(e=mS(t),s=Zd(t));const i=new QZ(r,e,s);return Ba(i,t,r)};class rJ extends ot{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const sJ=K(rJ),gu=new Ja,Lf=new Zt;class Er extends ot{static get type(){return"SceneNode"}constructor(t=Er.BACKGROUND_BLURRINESS,e=null){super(),this.scope=t,this.scene=e}setup(t){const e=this.scope,s=this.scene!==null?this.scene:t.scene;let i;return e===Er.BACKGROUND_BLURRINESS?i=me("backgroundBlurriness","float",s):e===Er.BACKGROUND_INTENSITY?i=me("backgroundIntensity","float",s):e===Er.BACKGROUND_ROTATION?i=dt("mat4").label("backgroundRotation").setGroup(Nt).onRenderUpdate(()=>{const n=s.background;return n!==null&&n.isTexture&&n.mapping!==t0?(gu.copy(s.backgroundRotation),gu.x*=-1,gu.y*=-1,gu.z*=-1,Lf.makeRotationFromEuler(gu)):Lf.identity(),Lf}):console.error("THREE.SceneNode: Unknown scope:",e),i}}Er.BACKGROUND_BLURRINESS="backgroundBlurriness";Er.BACKGROUND_INTENSITY="backgroundIntensity";Er.BACKGROUND_ROTATION="backgroundRotation";const iJ=K(Er,Er.BACKGROUND_BLURRINESS),nJ=K(Er,Er.BACKGROUND_INTENSITY),aJ=K(Er,Er.BACKGROUND_ROTATION);class oJ extends un{static get type(){return"StorageTextureNode"}constructor(t,e,s=null){super(t,e),this.storeNode=s,this.isStorageTextureNode=!0,this.access=ai.WRITE_ONLY}getInputType(){return"storageTexture"}setup(t){super.setup(t);const e=t.getNodeProperties(this);return e.storeNode=this.storeNode,e}setAccess(t){return this.access=t,this}generate(t,e){let s;return this.storeNode!==null?s=this.generateStore(t):s=super.generate(t,e),s}toReadWrite(){return this.setAccess(ai.READ_WRITE)}toReadOnly(){return this.setAccess(ai.READ_ONLY)}toWriteOnly(){return this.setAccess(ai.WRITE_ONLY)}generateStore(t){const e=t.getNodeProperties(this),{uvNode:s,storeNode:i,depthNode:n}=e,a=super.generate(t,"property"),o=s.build(t,"uvec2"),l=i.build(t,"vec4"),h=n?n.build(t,"int"):null,u=t.generateTextureStore(t,a,o,h,l);t.addLineFlowCode(u,this)}clone(){const t=super.clone();return t.storeNode=this.storeNode,t}}const M5=G(oJ).setParameterLength(1,3),lJ=(r,t,e)=>{const s=M5(r,t,e);return e!==null&&s.toStack(),s},uJ=L(({texture:r,uv:t})=>{const s=P().toVar();return wt(t.x.lessThan(1e-4),()=>{s.assign(P(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{s.assign(P(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{s.assign(P(0,0,1))}).ElseIf(t.x.greaterThan(1-1e-4),()=>{s.assign(P(-1,0,0))}).ElseIf(t.y.greaterThan(1-1e-4),()=>{s.assign(P(0,-1,0))}).ElseIf(t.z.greaterThan(1-1e-4),()=>{s.assign(P(0,0,-1))}).Else(()=>{const n=r.sample(t.add(P(-.01,0,0))).r.sub(r.sample(t.add(P(.01,0,0))).r),a=r.sample(t.add(P(0,-.01,0))).r.sub(r.sample(t.add(P(0,.01,0))).r),o=r.sample(t.add(P(0,0,-.01))).r.sub(r.sample(t.add(P(0,0,.01))).r);s.assign(P(n,a,o))}),s.normalize()});class hJ extends un{static get type(){return"Texture3DNode"}constructor(t,e=null,s=null){super(t,e,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return P(.5,.5,.5)}setUpdateMatrix(){}setupUV(t,e){const s=this.value;return t.isFlipY()&&(s.isRenderTargetTexture===!0||s.isFramebufferTexture===!0)&&(this.sampler?e=e.flipY():e=e.setY(N(Hn(this,this.levelNode).y).sub(e.y).sub(1))),e}generateUV(t,e){return e.build(t,"vec3")}normal(t){return uJ({texture:this,uv:t})}}const cJ=G(hJ).setParameterLength(1,3);class dJ extends $p{static get type(){return"UserDataNode"}constructor(t,e,s=null){super(t,e,s),this.userData=s}updateReference(t){return this.reference=this.userData!==null?this.userData:t.object.userData,this.reference}}const pJ=(r,t,e)=>q(new dJ(r,t,e)),Ev=new WeakMap;class mJ extends Re{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=$t.OBJECT,this.updateAfterType=$t.OBJECT,this.previousModelWorldMatrix=dt(new Zt),this.previousProjectionMatrix=dt(new Zt).setGroup(Nt),this.previousCameraViewMatrix=dt(new Zt)}setProjectionMatrix(t){this.projectionMatrix=t}update({frameId:t,camera:e,object:s}){const i=Vv(s);this.previousModelWorldMatrix.value.copy(i);const n=T5(e);n.frameId!==t&&(n.frameId=t,n.previousProjectionMatrix===void 0?(n.previousProjectionMatrix=new Zt,n.previousCameraViewMatrix=new Zt,n.currentProjectionMatrix=new Zt,n.currentCameraViewMatrix=new Zt,n.previousProjectionMatrix.copy(this.projectionMatrix||e.projectionMatrix),n.previousCameraViewMatrix.copy(e.matrixWorldInverse)):(n.previousProjectionMatrix.copy(n.currentProjectionMatrix),n.previousCameraViewMatrix.copy(n.currentCameraViewMatrix)),n.currentProjectionMatrix.copy(this.projectionMatrix||e.projectionMatrix),n.currentCameraViewMatrix.copy(e.matrixWorldInverse),this.previousProjectionMatrix.value.copy(n.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(n.previousCameraViewMatrix))}updateAfter({object:t}){Vv(t).copy(t.matrixWorld)}setup(){const t=this.projectionMatrix===null?Lh:dt(this.projectionMatrix),e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),s=t.mul(Ih).mul(_e),i=this.previousProjectionMatrix.mul(e).mul(tp),n=s.xy.div(s.w),a=i.xy.div(i.w);return Ct(n,a)}}function T5(r){let t=Ev.get(r);return t===void 0&&(t={},Ev.set(r,t)),t}function Vv(r,t=0){const e=T5(r);let s=e[t];return s===void 0&&(e[t]=s=new Zt,e[t].copy(r.matrixWorld)),s}const fJ=K(mJ),N5=L(([r,t])=>vs(1,r.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),S5=L(([r,t])=>vs(r.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_5=L(([r,t])=>r.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),A5=L(([r,t])=>Ne(r.mul(2).mul(t),r.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),Bp(.5,r))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gJ=L(([r,t])=>{const e=t.a.add(r.a.mul(t.a.oneMinus()));return pt(t.rgb.mul(t.a).add(r.rgb.mul(r.a).mul(t.a.oneMinus())).div(e),e)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),yJ=L(([r])=>pt(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"}),xJ=L(([r])=>(wt(r.a.equal(0),()=>pt(0)),pt(r.rgb.div(r.a),r.a)),{color:"vec4",return:"vec4"}),bJ=(...r)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),N5(r)),vJ=(...r)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),S5(r)),wJ=(...r)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),_5(r)),MJ=(...r)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),A5(r)),TJ=L(([r])=>q0(r.rgb)),NJ=L(([r,t=M(1)])=>t.mix(q0(r.rgb),r.rgb)),SJ=L(([r,t=M(1)])=>{const e=Ee(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),i=s.sub(e).mul(t).mul(-3);return Ne(r.rgb,s,i)}),_J=L(([r,t=M(1)])=>{const e=P(.57735,.57735,.57735),s=t.cos();return P(r.rgb.mul(s).add(e.cross(r.rgb).mul(t.sin()).add(e.mul(aa(e,r.rgb).mul(s.oneMinus())))))}),q0=(r,t=P(Te.getLuminanceCoefficients(new k)))=>aa(r,t),AJ=L(([r,t=P(1),e=P(0),s=P(1),i=M(1),n=P(Te.getLuminanceCoefficients(new k,qd))])=>{const a=r.rgb.dot(P(n)),o=Ke(r.rgb.mul(t).add(e),0).toVar(),l=o.pow(s).toVar();return wt(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),wt(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),wt(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(i))),pt(o.rgb,r.a)});class zJ extends Re{static get type(){return"PosterizeNode"}constructor(t,e){super(),this.sourceNode=t,this.stepsNode=e}setup(){const{sourceNode:t,stepsNode:e}=this;return t.mul(e).floor().div(e)}}const CJ=G(zJ).setParameterLength(2),sd=new ge;class z5 extends un{static get type(){return"PassTextureNode"}constructor(t,e){super(e),this.passNode=t,this.setUpdateMatrix(!1)}setup(t){return t.object.isQuadMesh&&this.passNode.build(t),super.setup(t)}clone(){return new this.constructor(this.passNode,this.value)}}class Rv extends z5{static get type(){return"PassMultipleTextureNode"}constructor(t,e,s=!1){super(t,null),this.textureName=e,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(t){return this.updateTexture(),super.setup(t)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class wi extends Re{static get type(){return"PassNode"}constructor(t,e,s,i={}){super("vec4"),this.scope=t,this.scene=e,this.camera=s,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const n=new Ah;n.isRenderTargetTexture=!0,n.name="depth";const a=new Sh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Dn,...i});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=dt(0),this._cameraFar=dt(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=$t.FRAME,this.global=!0}setResolution(t){return this._resolution=t,this}getResolution(){return this._resolution}setLayers(t){return this._layers=t,this}getLayers(){return this._layers}setMRT(t){return this._mrt=t,this}getMRT(){return this._mrt}getTexture(t){let e=this._textures[t];return e===void 0&&(e=this.renderTarget.texture.clone(),e.name=t,this._textures[t]=e,this.renderTarget.textures.push(e)),e}getPreviousTexture(t){let e=this._previousTextures[t];return e===void 0&&(e=this.getTexture(t).clone(),this._previousTextures[t]=e),e}toggleTexture(t){const e=this._previousTextures[t];if(e!==void 0){const s=this._textures[t],i=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[i]=e,this._textures[t]=e,this._previousTextures[t]=s,this._textureNodes[t].updateTexture(),this._previousTextureNodes[t].updateTexture()}}getTextureNode(t="output"){let e=this._textureNodes[t];return e===void 0&&(e=q(new Rv(this,t)),e.updateTexture(),this._textureNodes[t]=e),e}getPreviousTextureNode(t="output"){let e=this._previousTextureNodes[t];return e===void 0&&(this._textureNodes[t]===void 0&&this.getTextureNode(t),e=q(new Rv(this,t,!0)),e.updateTexture(),this._previousTextureNodes[t]=e),e}getViewZNode(t="depth"){let e=this._viewZNodes[t];if(e===void 0){const s=this._cameraNear,i=this._cameraFar;this._viewZNodes[t]=e=k0(this.getTextureNode(t),s,i)}return e}getLinearDepthNode(t="depth"){let e=this._linearDepthNodes[t];if(e===void 0){const s=this._cameraNear,i=this._cameraFar,n=this.getViewZNode(t);this._linearDepthNodes[t]=e=fl(n,s,i)}return e}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===wi.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(t){const{renderer:e}=t,{scene:s}=this;let i,n;const a=e.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,i=e.xr.getCamera(),e.xr.updateCamera(i),sd.set(a.width,a.height)):(i=this.camera,n=e.getPixelRatio(),e.getSize(sd)),this._pixelRatio=n,this.setSize(sd.width,sd.height);const o=e.getRenderTarget(),l=e.getMRT(),h=i.layers.mask;this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask);for(const u in this._previousTextures)this.toggleTexture(u);e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),e.render(s,i),e.setRenderTarget(o),e.setMRT(l),i.layers.mask=h}setSize(t,e){this._width=t,this._height=e;const s=this._width*this._pixelRatio*this._resolution,i=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(s,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}wi.COLOR="color";wi.DEPTH="depth";const EJ=(r,t,e)=>q(new wi(wi.COLOR,r,t,e)),VJ=(r,t)=>q(new z5(r,t)),RJ=(r,t,e)=>q(new wi(wi.DEPTH,r,t,e));class LJ extends wi{static get type(){return"ToonOutlinePassNode"}constructor(t,e,s,i,n){super(wi.COLOR,t,e),this.colorNode=s,this.thicknessNode=i,this.alphaNode=n,this._materialCache=new WeakMap}updateBefore(t){const{renderer:e}=t,s=e.getRenderObjectFunction();e.setRenderObjectFunction((i,n,a,o,l,h,u,c)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const d=this._getOutlineMaterial(l);e.renderObject(i,n,a,o,d,h,u,c)}e.renderObject(i,n,a,o,l,h,u,c)}),super.updateBefore(t),e.setRenderObjectFunction(s)}_createMaterial(){const t=new Pl;t.isMeshToonOutlineMaterial=!0,t.name="Toon_Outline",t.side=Vp;const e=Fr.negate(),s=Lh.mul(Ih),i=M(1),n=s.mul(pt(_e,1)),a=s.mul(pt(_e.add(e),1)),o=Ka(n.sub(a));return t.vertexNode=n.add(o.mul(this.thicknessNode).mul(n.w).mul(i)),t.colorNode=pt(this.colorNode,this.alphaNode),t}_getOutlineMaterial(t){let e=this._materialCache.get(t);return e===void 0&&(e=this._createMaterial(),this._materialCache.set(t,e)),e}}const IJ=(r,t,e=new dn(0,0,0),s=.003,i=1)=>q(new LJ(r,t,q(e),q(s),q(i))),PJ=L(([r,t])=>r.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),FJ=L(([r,t])=>(r=r.mul(t),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),OJ=L(([r,t])=>{r=r.mul(t),r=r.sub(.004).max(0);const e=r.mul(r.mul(6.2).add(.5)),s=r.mul(r.mul(6.2).add(1.7)).add(.06);return e.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),BJ=L(([r])=>{const t=r.mul(r.add(.0245786)).sub(90537e-9),e=r.mul(r.add(.432951).mul(.983729)).add(.238081);return t.div(e)}),kJ=L(([r,t])=>{const e=bs(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=bs(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(t).div(.6),r=e.mul(r),r=BJ(r),r=s.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),DJ=bs(P(1.6605,-.1246,-.0182),P(-.5876,1.1329,-.1006),P(-.0728,-.0083,1.1187)),UJ=bs(P(.6274,.0691,.0164),P(.3293,.9195,.088),P(.0433,.0113,.8956)),$J=L(([r])=>{const t=P(r).toVar(),e=P(t.mul(t)).toVar(),s=P(e.mul(e)).toVar();return M(15.5).mul(s.mul(e)).sub(yt(40.14,s.mul(t))).add(yt(31.96,s).sub(yt(6.868,e.mul(t))).add(yt(.4298,e).add(yt(.1191,t).sub(.00232))))}),jJ=L(([r,t])=>{const e=P(r).toVar(),s=bs(P(.856627153315983,.137318972929847,.11189821299995),P(.0951212405381588,.761241990602591,.0767994186031903),P(.0482516061458583,.101439036467562,.811302368396859)),i=bs(P(1.1271005818144368,-.1413297634984383,-.14132976349843826),P(-.11060664309660323,1.157823702216272,-.11060664309660294),P(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=M(-12.47393),a=M(4.026069);return e.mulAssign(t),e.assign(UJ.mul(e)),e.assign(s.mul(e)),e.assign(Ke(e,1e-10)),e.assign(Ki(e)),e.assign(e.sub(n).div(a.sub(n))),e.assign(on(e,0,1)),e.assign($J(e)),e.assign(i.mul(e)),e.assign(Ys(Ke(P(0),e),P(2.2))),e.assign(DJ.mul(e)),e.assign(on(e,0,1)),e}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WJ=L(([r,t])=>{const e=M(.76),s=M(.15);r=r.mul(t);const i=vs(r.r,vs(r.g,r.b)),n=xr(i.lessThan(.08),i.sub(yt(6.25,i.mul(i))),.04);r.subAssign(n);const a=Ke(r.r,Ke(r.g,r.b));wt(a.lessThan(e),()=>r);const o=Ct(1,e),l=Ct(1,o.mul(o).div(a.add(o.sub(e))));r.mulAssign(l.div(a));const h=Ct(1,bi(1,s.mul(a.sub(l)).add(1)));return Ne(r,P(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class He extends ot{static get type(){return"CodeNode"}constructor(t="",e=[],s=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=t,this.includes=e,this.language=s}setIncludes(t){return this.includes=t,this}getIncludes(){return this.includes}generate(t){const e=this.getIncludes(t);for(const i of e)i.build(t);const s=t.getCodeFromNode(this,this.getNodeType(t));return s.code=this.code,s.code}serialize(t){super.serialize(t),t.code=this.code,t.language=this.language}deserialize(t){super.deserialize(t),this.code=t.code,this.language=t.language}}const Hp=G(He).setParameterLength(1,3),qJ=(r,t)=>Hp(r,t,"js"),HJ=(r,t)=>Hp(r,t,"wgsl"),GJ=(r,t)=>Hp(r,t,"glsl");class XJ extends He{static get type(){return"FunctionNode"}constructor(t="",e=[],s=""){super(t,e,s)}getNodeType(t){return this.getNodeFunction(t).type}getInputs(t){return this.getNodeFunction(t).inputs}getNodeFunction(t){const e=t.getDataFromNode(this);let s=e.nodeFunction;return s===void 0&&(s=t.parser.parseFunction(this.code),e.nodeFunction=s),s}generate(t,e){super.generate(t);const s=this.getNodeFunction(t),i=s.name,n=s.type,a=t.getCodeFromNode(this,n);i!==""&&(a.name=i);const o=t.getPropertyName(a),l=this.getNodeFunction(t).getCode(o);return a.code=l+`
|
|
121
|
+
`,e==="property"?o:t.format(`${o}()`,n,e)}}const C5=(r,t=[],e="")=>{for(let n=0;n<t.length;n++){const a=t[n];typeof a=="function"&&(t[n]=a.functionNode)}const s=q(new XJ(r,t,e)),i=(...n)=>s.call(...n);return i.functionNode=s,i},YJ=(r,t)=>C5(r,t,"glsl"),ZJ=(r,t)=>C5(r,t,"wgsl");class JJ extends ot{static get type(){return"ScriptableValueNode"}constructor(t=null){super(),this._value=t,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Za,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(t){this._value!==t&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=t,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const t=this.value;if(t&&this._cache===null&&this.inputType==="URL"&&t.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([t.value]));else if(t&&t.value!==null&&t.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof t.value=="string"||this.inputType==="Number"&&typeof t.value=="number"||this.inputType==="Vector2"&&t.value.isVector2||this.inputType==="Vector3"&&t.value.isVector3||this.inputType==="Vector4"&&t.value.isVector4||this.inputType==="Color"&&t.value.isColor||this.inputType==="Matrix3"&&t.value.isMatrix3||this.inputType==="Matrix4"&&t.value.isMatrix4))return t.value;return this._cache||t}getNodeType(t){return this.value&&this.value.isNode?this.value.getNodeType(t):"float"}setup(){return this.value&&this.value.isNode?this.value:M()}serialize(t){super.serialize(t),this.value!==null?this.inputType==="ArrayBuffer"?t.value=yS(this.value):t.value=this.value?this.value.toJSON(t.meta).uuid:null:t.value=null,t.inputType=this.inputType,t.outputType=this.outputType}deserialize(t){super.deserialize(t);let e=null;t.value!==null&&(t.inputType==="ArrayBuffer"?e=xS(t.value):t.inputType==="Texture"?e=t.meta.textures[t.value]:e=t.meta.nodes[t.value]||null),this.value=e,this.inputType=t.inputType,this.outputType=t.outputType}}const wd=G(JJ).setParameterLength(1);class E5 extends Map{get(t,e=null,...s){if(this.has(t))return super.get(t);if(e!==null){const i=e(...s);return this.set(t,i),i}}}class QJ{constructor(t){this.scriptableNode=t}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(t){return this.scriptableNode.getInputLayout(t)}get(t){const e=this.parameters[t];return e?e.getValue():null}}const Md=new E5;class KJ extends ot{static get type(){return"ScriptableNode"}constructor(t=null,e={}){super(),this.codeNode=t,this.parameters=e,this._local=new E5,this._output=wd(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(t,e){return this._local.set(t,e)}getLocal(t){return this._local.get(t)}onRefresh(){this._refresh()}getInputLayout(t){for(const e of this.getLayout())if(e.inputType&&(e.id===t||e.name===t))return e}getOutputLayout(t){for(const e of this.getLayout())if(e.outputType&&(e.id===t||e.name===t))return e}setOutput(t,e){const s=this._outputs;return s[t]===void 0?s[t]=wd(e):s[t].value=e,this}getOutput(t){return this._outputs[t]}getParameter(t){return this.parameters[t]}setParameter(t,e){const s=this.parameters;return e&&e.isScriptableNode?(this.deleteParameter(t),s[t]=e,s[t].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):e&&e.isScriptableValueNode?(this.deleteParameter(t),s[t]=e,s[t].events.addEventListener("refresh",this.onRefresh)):s[t]===void 0?(s[t]=wd(e),s[t].events.addEventListener("refresh",this.onRefresh)):s[t].value=e,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(t){let e=this.parameters[t];return e&&(e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const t of Object.keys(this.parameters))this.deleteParameter(t);return this.needsUpdate=!0,this}call(t,...e){const i=this.getObject()[t];if(typeof i=="function")return i(...e)}async callAsync(t,...e){const i=this.getObject()[t];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...e):i(...e)}getNodeType(t){return this.getDefaultOutputNode().getNodeType(t)}refresh(t=null){t!==null?this.getOutput(t).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const t=()=>this.refresh(),e=(h,u)=>this.setOutput(h,u),s=new QJ(this),i=Md.get("THREE"),n=Md.get("TSL"),a=this.getMethod(),o=[s,this._local,Md,t,e,i,n];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const h of l.elements){const u=h.id||h.name;h.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=h.inputType),h.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=h.outputType)}return this._object}deserialize(t){super.deserialize(t);for(const e in this.parameters){let s=this.parameters[e];s.isScriptableNode&&(s=s.getDefaultOutput()),s.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const t=this.getDefaultOutput().value;return t&&t.isNode?t:M()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const t=["parameters","local","global","refresh","setOutput","THREE","TSL"],s=["layout","init","main","dispose"].join(", "),i="var "+s+`; var output = {};
|
|
122
|
+
`,n=`
|
|
123
|
+
return { ...output, `+s+" };",a=i+this.codeNode.code+n;return this._method=new Function(...t,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(t){const e=[Kq(this.source),this.getDefaultOutputNode().getCacheKey(t)];for(const s in this.parameters)e.push(this.parameters[s].getCacheKey(t));return cS(e)}set needsUpdate(t){t===!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 tQ=G(KJ).setParameterLength(1,2);function V5(r){let t;const e=r.context.getViewZ;return e!==void 0&&(t=e(this)),(t||or.z).negate()}const R5=L(([r,t],e)=>{const s=V5(e);return qa(r,t,s)}),L5=L(([r],t)=>{const e=V5(t);return r.mul(r,e,e).negate().exp().oneMinus()}),H0=L(([r,t])=>pt(t.toFloat().mix(ml.rgb,r.toVec3()),ml.a));function eQ(r,t,e){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),H0(r,R5(t,e))}function rQ(r,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),H0(r,L5(t))}let xa=null,ba=null;class sQ extends ot{static get type(){return"RangeNode"}constructor(t=M(),e=M()){super(),this.minNode=t,this.maxNode=e}getVectorLength(t){const e=t.getTypeLength(Un(this.minNode.value)),s=t.getTypeLength(Un(this.maxNode.value));return e>s?e:s}getNodeType(t){return t.object.count>1?t.getTypeFromLength(this.getVectorLength(t)):"float"}setup(t){const e=t.object;let s=null;if(e.count>1){const i=this.minNode.value,n=this.maxNode.value,a=t.getTypeLength(Un(i)),o=t.getTypeLength(Un(n));xa=xa||new Mr,ba=ba||new Mr,xa.setScalar(0),ba.setScalar(0),a===1?xa.setScalar(i):i.isColor?xa.set(i.r,i.g,i.b,1):xa.set(i.x,i.y,i.z||0,i.w||0),o===1?ba.setScalar(n):n.isColor?ba.set(n.r,n.g,n.b,1):ba.set(n.x,n.y,n.z||0,n.w||0);const l=4,h=l*e.count,u=new Float32Array(h);for(let d=0;d<h;d++){const p=d%l,m=xa.getComponent(p),f=ba.getComponent(p);u[d]=iS.lerp(m,f,Math.random())}const c=this.getNodeType(t);if(e.count<=4096)s=Rh(u,"vec4",e.count).element(Gn).convert(c);else{const d=new dl(u,4);t.geometry.setAttribute("__range"+this.id,d),s=Kd(d).convert(c)}}else s=M(0);return s}}const iQ=G(sQ).setParameterLength(2);class nQ extends ot{static get type(){return"ComputeBuiltinNode"}constructor(t,e){super(e),this._builtinName=t}getHash(t){return this.getBuiltinName(t)}getNodeType(){return this.nodeType}setBuiltinName(t){return this._builtinName=t,this}getBuiltinName(){return this._builtinName}hasBuiltin(t){return t.hasBuiltin(this._builtinName)}generate(t,e){const s=this.getBuiltinName(t),i=this.getNodeType(t);return t.shaderStage==="compute"?t.format(s,i,e):(console.warn(`ComputeBuiltinNode: Compute built-in value ${s} can not be accessed in the ${t.shaderStage} stage`),t.generateConst(i))}serialize(t){super.serialize(t),t.global=this.global,t._builtinName=this._builtinName}deserialize(t){super.deserialize(t),this.global=t.global,this._builtinName=t._builtinName}}const Dh=(r,t)=>q(new nQ(r,t)),aQ=Dh("numWorkgroups","uvec3"),oQ=Dh("workgroupId","uvec3"),lQ=Dh("globalId","uvec3"),uQ=Dh("localId","uvec3"),hQ=Dh("subgroupSize","uint");class cQ extends ot{constructor(t){super(),this.scope=t}generate(t){const{scope:e}=this,{renderer:s}=t;s.backend.isWebGLBackend===!0?t.addFlowCode(` // ${e}Barrier
|
|
124
|
+
`):t.addLineFlowCode(`${e}Barrier()`,this)}}const G0=G(cQ),dQ=()=>G0("workgroup").toStack(),pQ=()=>G0("storage").toStack(),mQ=()=>G0("texture").toStack();class fQ extends Qa{constructor(t,e){super(t,e),this.isWorkgroupInfoElementNode=!0}generate(t,e){let s;const i=t.context.assign;if(s=super.generate(t),i!==!0){const n=this.getNodeType(t);s=t.format(s,n,e)}return s}}class gQ extends ot{constructor(t,e,s=0){super(e),this.bufferType=e,this.bufferCount=s,this.isWorkgroupInfoNode=!0,this.elementType=e,this.scope=t}label(t){return this.name=t,this}setScope(t){return this.scope=t,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(t){return q(new fQ(this,t))}generate(t){return t.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const yQ=(r,t)=>q(new gQ("Workgroup",r,t));class tr extends ot{static get type(){return"AtomicFunctionNode"}constructor(t,e,s){super("uint"),this.method=t,this.pointerNode=e,this.valueNode=s,this.parents=!0}getInputType(t){return this.pointerNode.getNodeType(t)}getNodeType(t){return this.getInputType(t)}generate(t){const e=t.getNodeProperties(this),s=e.parents,i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.pointerNode,l=this.valueNode,h=[];h.push(`&${o.build(t,a)}`),l!==null&&h.push(l.build(t,a));const u=`${t.getMethod(i,n)}( ${h.join(", ")} )`;if(s.length===1&&s[0].isStackNode===!0)t.addLineFlowCode(u,this);else return e.constNode===void 0&&(e.constNode=ln(u,n).toConst()),e.constNode.build(t)}}tr.ATOMIC_LOAD="atomicLoad";tr.ATOMIC_STORE="atomicStore";tr.ATOMIC_ADD="atomicAdd";tr.ATOMIC_SUB="atomicSub";tr.ATOMIC_MAX="atomicMax";tr.ATOMIC_MIN="atomicMin";tr.ATOMIC_AND="atomicAnd";tr.ATOMIC_OR="atomicOr";tr.ATOMIC_XOR="atomicXor";const xQ=G(tr),zi=(r,t,e)=>xQ(r,t,e).toStack(),bQ=r=>zi(tr.ATOMIC_LOAD,r,null),vQ=(r,t)=>zi(tr.ATOMIC_STORE,r,t),wQ=(r,t)=>zi(tr.ATOMIC_ADD,r,t),MQ=(r,t)=>zi(tr.ATOMIC_SUB,r,t),TQ=(r,t)=>zi(tr.ATOMIC_MAX,r,t),NQ=(r,t)=>zi(tr.ATOMIC_MIN,r,t),SQ=(r,t)=>zi(tr.ATOMIC_AND,r,t),_Q=(r,t)=>zi(tr.ATOMIC_OR,r,t),AQ=(r,t)=>zi(tr.ATOMIC_XOR,r,t);let id;function Gp(r){id=id||new WeakMap;let t=id.get(r);return t===void 0&&id.set(r,t={}),t}function X0(r){const t=Gp(r);return t.shadowMatrix||(t.shadowMatrix=dt("mat4").setGroup(Nt).onRenderUpdate(e=>((r.castShadow!==!0||e.renderer.shadowMap.enabled===!1)&&r.shadow.updateMatrices(r),r.shadow.matrix)))}function zQ(r,t=Oa){const e=X0(r).mul(t);return e.xyz.div(e.w)}function I5(r){const t=Gp(r);return t.position||(t.position=dt(new k).setGroup(Nt).onRenderUpdate((e,s)=>s.value.setFromMatrixPosition(r.matrixWorld)))}function P5(r){const t=Gp(r);return t.targetPosition||(t.targetPosition=dt(new k).setGroup(Nt).onRenderUpdate((e,s)=>s.value.setFromMatrixPosition(r.target.matrixWorld)))}function CQ(r){const t=Gp(r);return t.viewPosition||(t.viewPosition=dt(new k).setGroup(Nt).onRenderUpdate(({camera:e},s)=>{s.value=s.value||new k,s.value.setFromMatrixPosition(r.matrixWorld),s.value.applyMatrix4(e.matrixWorldInverse)}))}const EQ=r=>_s.transformDirection(I5(r).sub(P5(r))),VQ=r=>r.sort((t,e)=>t.id-e.id),RQ=(r,t)=>{for(const e of t)if(e.isAnalyticLightNode&&e.light.id===r)return e;return null},If=new WeakMap,yu=[];class LQ extends ot{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=P().toVar(),this.totalSpecularNode=P().toVar(),this.outgoingLightNode=P().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const t=this._lights;for(let s=0;s<t.length;s++){const i=t[s];if(yu.push(i.id),yu.push(i.castShadow?1:0),i.isSpotLight===!0){const n=i.map!==null?i.map.id:-1,a=i.colorNode?i.colorNode.getCacheKey():-1;yu.push(n,a)}}const e=cS(yu);return yu.length=0,e}getHash(t){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(t);const e=[];for(const s of this._lightNodes)e.push(s.getSelf().getHash());this._lightNodesHash="lights-"+e.join(",")}return this._lightNodesHash}analyze(t){const e=t.getNodeProperties(this);for(const s of e.nodes)s.build(t);e.outputNode.build(t)}setupLightsNode(t){const e=[],s=this._lightNodes,i=VQ(this._lights),n=t.renderer.library;for(const a of i)if(a.isNode)e.push(q(a));else{let o=null;if(s!==null&&(o=RQ(a.id,s)),o===null){const l=n.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let h=null;If.has(a)?h=If.get(a):(h=q(new l(a)),If.set(a,h)),e.push(h)}}this._lightNodes=e}setupDirectLight(t,e,s){const{lightingModel:i,reflectedLight:n}=t.context;i.direct({...s,lightNode:e,reflectedLight:n},t)}setupDirectRectAreaLight(t,e,s){const{lightingModel:i,reflectedLight:n}=t.context;i.directRectArea({...s,lightNode:e,reflectedLight:n},t)}setupLights(t,e){for(const s of e)s.build(t)}getLightNodes(t){return this._lightNodes===null&&this.setupLightsNode(t),this._lightNodes}setup(t){const e=t.lightsNode;t.lightsNode=this;let s=this.outgoingLightNode;const i=t.context,n=i.lightingModel,a=t.getNodeProperties(this);if(n){const{totalDiffuseNode:o,totalSpecularNode:l}=this;i.outgoingLight=s;const h=t.addStack();a.nodes=h.nodes,n.start(t);const{backdrop:u,backdropAlpha:c}=i,{directDiffuse:d,directSpecular:p,indirectDiffuse:m,indirectSpecular:f}=i.reflectedLight;let x=d.add(m);u!==null&&(c!==null?x=P(c.mix(x,u)):x=P(u),i.material.transparent=!0),o.assign(x),l.assign(p.add(f)),s.assign(o.add(l)),n.finish(t),s=s.bypass(t.removeStack())}else a.nodes=[];return t.lightsNode=e,s}setLights(t){return this._lights=t,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const IQ=(r=[])=>q(new LQ).setLights(r);class PQ extends ot{static get type(){return"ShadowBaseNode"}constructor(t){super(),this.light=t,this.updateBeforeType=$t.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:t,material:e}){Y0.assign(e.receivedShadowPositionNode||t.shadowPositionWorld||Oa)}}const Y0=ql("vec3","shadowPositionWorld");function FQ(r,t={}){return t.toneMapping=r.toneMapping,t.toneMappingExposure=r.toneMappingExposure,t.outputColorSpace=r.outputColorSpace,t.renderTarget=r.getRenderTarget(),t.activeCubeFace=r.getActiveCubeFace(),t.activeMipmapLevel=r.getActiveMipmapLevel(),t.renderObjectFunction=r.getRenderObjectFunction(),t.pixelRatio=r.getPixelRatio(),t.mrt=r.getMRT(),t.clearColor=r.getClearColor(t.clearColor||new dn),t.clearAlpha=r.getClearAlpha(),t.autoClear=r.autoClear,t.scissorTest=r.getScissorTest(),t}function OQ(r,t){return t=FQ(r,t),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,t}function BQ(r,t){r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),r.setRenderObjectFunction(t.renderObjectFunction),r.setPixelRatio(t.pixelRatio),r.setMRT(t.mrt),r.setClearColor(t.clearColor,t.clearAlpha),r.autoClear=t.autoClear,r.setScissorTest(t.scissorTest)}function kQ(r,t={}){return t.background=r.background,t.backgroundNode=r.backgroundNode,t.overrideMaterial=r.overrideMaterial,t}function DQ(r,t){return t=kQ(r,t),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,t}function UQ(r,t){r.background=t.background,r.backgroundNode=t.backgroundNode,r.overrideMaterial=t.overrideMaterial}function $Q(r,t,e){return e=OQ(r,e),e=DQ(t,e),e}function jQ(r,t,e){BQ(r,e),UQ(t,e)}const Lv=new WeakMap,F5=L(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{let s=Gt(r,t.xy).label("t_basic");return r.isArrayTexture&&(s=s.depth(e)),s.compare(t.z)}),O5=L(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:s})=>{const i=(x,b)=>{let w=Gt(r,x);return r.isArrayTexture&&(w=w.depth(s)),w.compare(b)},n=me("mapSize","vec2",e).setGroup(Nt),a=me("radius","float",e).setGroup(Nt),o=Z(1).div(n),l=o.x.negate().mul(a),h=o.y.negate().mul(a),u=o.x.mul(a),c=o.y.mul(a),d=l.div(2),p=h.div(2),m=u.div(2),f=c.div(2);return Ee(i(t.xy.add(Z(l,h)),t.z),i(t.xy.add(Z(0,h)),t.z),i(t.xy.add(Z(u,h)),t.z),i(t.xy.add(Z(d,p)),t.z),i(t.xy.add(Z(0,p)),t.z),i(t.xy.add(Z(m,p)),t.z),i(t.xy.add(Z(l,0)),t.z),i(t.xy.add(Z(d,0)),t.z),i(t.xy,t.z),i(t.xy.add(Z(m,0)),t.z),i(t.xy.add(Z(u,0)),t.z),i(t.xy.add(Z(d,f)),t.z),i(t.xy.add(Z(0,f)),t.z),i(t.xy.add(Z(m,f)),t.z),i(t.xy.add(Z(l,c)),t.z),i(t.xy.add(Z(0,c)),t.z),i(t.xy.add(Z(u,c)),t.z)).mul(1/17)}),B5=L(({depthTexture:r,shadowCoord:t,shadow:e,depthLayer:s})=>{const i=(c,d)=>{let p=Gt(r,c);return r.isArrayTexture&&(p=p.depth(s)),p.compare(d)},n=me("mapSize","vec2",e).setGroup(Nt),a=Z(1).div(n),o=a.x,l=a.y,h=t.xy,u=pn(h.mul(n).add(.5));return h.subAssign(u.mul(a)),Ee(i(h,t.z),i(h.add(Z(o,0)),t.z),i(h.add(Z(0,l)),t.z),i(h.add(a),t.z),Ne(i(h.add(Z(o.negate(),0)),t.z),i(h.add(Z(o.mul(2),0)),t.z),u.x),Ne(i(h.add(Z(o.negate(),l)),t.z),i(h.add(Z(o.mul(2),l)),t.z),u.x),Ne(i(h.add(Z(0,l.negate())),t.z),i(h.add(Z(0,l.mul(2))),t.z),u.y),Ne(i(h.add(Z(o,l.negate())),t.z),i(h.add(Z(o,l.mul(2))),t.z),u.y),Ne(Ne(i(h.add(Z(o.negate(),l.negate())),t.z),i(h.add(Z(o.mul(2),l.negate())),t.z),u.x),Ne(i(h.add(Z(o.negate(),l.mul(2))),t.z),i(h.add(Z(o.mul(2),l.mul(2))),t.z),u.x),u.y)).mul(1/9)}),k5=L(({depthTexture:r,shadowCoord:t,depthLayer:e})=>{const s=M(1).toVar();let i=Gt(r).sample(t.xy);r.isArrayTexture&&(i=i.depth(e)),i=i.rg;const n=Bp(t.z,i.x);return wt(n.notEqual(M(1)),()=>{const a=t.z.sub(i.x),o=Ke(0,i.y.mul(i.y));let l=o.div(o.add(a.mul(a)));l=on(Ct(l,.3).div(.95-.3)),s.assign(on(Ke(n,l)))}),s}),WQ=L(([r,t,e])=>{let s=Oa.sub(r).length();return s=s.sub(t).div(e.sub(t)),s=s.saturate(),s}),qQ=r=>{const t=r.shadow.camera,e=me("near","float",t).setGroup(Nt),s=me("far","float",t).setGroup(Nt),i=p3(r);return WQ(i,e,s)},D5=r=>{let t=Lv.get(r);if(t===void 0){const e=r.isPointLight?qQ(r):null;t=new Pl,t.colorNode=pt(0,0,0,1),t.depthNode=e,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Lv.set(r,t)}return t},Iv=new oZ,Uo=[],U5=(r,t,e,s)=>{Uo[0]=r,Uo[1]=t;let i=Iv.get(Uo);return(i===void 0||i.shadowType!==e||i.useVelocity!==s)&&(i=(n,a,o,l,h,u,...c)=>{(n.castShadow===!0||n.receiveShadow&&e===bd)&&(s&&(gS(n).useVelocity=!0),n.onBeforeShadow(r,n,o,t.camera,l,a.overrideMaterial,u),r.renderObject(n,a,o,l,h,u,...c),n.onAfterShadow(r,n,o,t.camera,l,a.overrideMaterial,u))},i.shadowType=e,i.useVelocity=s,Iv.set(Uo,i)),Uo[0]=null,Uo[1]=null,i},HQ=L(({samples:r,radius:t,size:e,shadowPass:s,depthLayer:i})=>{const n=M(0).toVar("meanVertical"),a=M(0).toVar("squareMeanVertical"),o=r.lessThanEqual(M(1)).select(M(0),M(2).div(r.sub(1))),l=r.lessThanEqual(M(1)).select(M(0),M(-1));Xt({start:N(0),end:N(r),type:"int",condition:"<"},({i:u})=>{const c=l.add(M(u).mul(o));let d=s.sample(Ee(kh.xy,Z(0,c).mul(t)).div(e));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(r),a.divAssign(r);const h=Ai(a.sub(n.mul(n)));return Z(n,h)}),GQ=L(({samples:r,radius:t,size:e,shadowPass:s,depthLayer:i})=>{const n=M(0).toVar("meanHorizontal"),a=M(0).toVar("squareMeanHorizontal"),o=r.lessThanEqual(M(1)).select(M(0),M(2).div(r.sub(1))),l=r.lessThanEqual(M(1)).select(M(0),M(-1));Xt({start:N(0),end:N(r),type:"int",condition:"<"},({i:u})=>{const c=l.add(M(u).mul(o));let d=s.sample(Ee(kh.xy,Z(c,0).mul(t)).div(e));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Ee(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(r),a.divAssign(r);const h=Ai(a.sub(n.mul(n)));return Z(n,h)}),XQ=[F5,O5,B5,k5];let Pf;const nd=new v5;class $5 extends PQ{static get type(){return"ShadowNode"}constructor(t,e=null){super(t),this.shadow=e||t.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(t,{filterFn:e,depthTexture:s,shadowCoord:i,shadow:n,depthLayer:a}){const o=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),l=e({depthTexture:s,shadowCoord:i,shadow:n,depthLayer:a});return o.select(l,M(1))}setupShadowCoord(t,e){const{shadow:s}=this,{renderer:i}=t,n=me("bias","float",s).setGroup(Nt);let a=e,o;if(s.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,i.coordinateSystem===ja&&(o=o.mul(2).sub(1));else{const l=a.w;a=a.xy.div(l);const h=me("near","float",s.camera).setGroup(Nt),u=me("far","float",s.camera).setGroup(Nt);o=D0(l.negate(),h,u)}return a=P(a.x,a.y.oneMinus(),o.add(n)),a}getShadowFilterFn(t){return XQ[t]}setupRenderTarget(t,e){const s=new Ah(t.mapSize.width,t.mapSize.height);s.name="ShadowDepthTexture",s.compareFunction=oq;const i=e.createRenderTarget(t.mapSize.width,t.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=t.mapType,i.depthTexture=s,{shadowMap:i,depthTexture:s}}setupShadow(t){const{renderer:e}=t,{light:s,shadow:i}=this,n=e.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(i,t);if(i.camera.updateProjectionMatrix(),n===bd&&i.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=t.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Rc,type:Dn,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=t.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Rc,type:Dn,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=t.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Rc,type:Dn,depthBuffer:!1}),this.vsmShadowMapHorizontal=t.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:Rc,type:Dn,depthBuffer:!1}));let b=Gt(a);a.isArrayTexture&&(b=b.depth(this.depthLayer));let w=Gt(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(w=w.depth(this.depthLayer));const S=me("blurSamples","float",i).setGroup(Nt),_=me("radius","float",i).setGroup(Nt),V=me("mapSize","vec2",i).setGroup(Nt);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Pl);z.fragmentNode=HQ({samples:S,radius:_,size:V,shadowPass:b,depthLayer:this.depthLayer}).context(t.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Pl),z.fragmentNode=GQ({samples:S,radius:_,size:V,shadowPass:w,depthLayer:this.depthLayer}).context(t.getSharedContext()),z.name="VSMHorizontal"}const l=me("intensity","float",i).setGroup(Nt),h=me("normalBias","float",i).setGroup(Nt),u=X0(s).mul(Y0.add(v3.mul(h))),c=this.setupShadowCoord(t,u),d=i.filterNode||this.getShadowFilterFn(e.shadowMap.type)||null;if(d===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const p=n===bd&&i.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,m=this.setupShadowFilter(t,{filterFn:d,shadowTexture:o.texture,depthTexture:p,shadowCoord:c,shadow:i,depthLayer:this.depthLayer});let f=Gt(o.texture,c);a.isArrayTexture&&(f=f.depth(this.depthLayer));const x=Ne(1,m.rgb.mix(f,1),l.mul(f.a)).toVar();return this.shadowMap=o,this.shadow.map=o,x}setup(t){if(t.renderer.shadowMap.enabled!==!1)return L(()=>{let e=this._node;return this.setupShadowPosition(t),e===null&&(this._node=e=this.setupShadow(t)),t.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),t.material.receivedShadowNode&&(e=t.material.receivedShadowNode(e)),e})()}renderShadow(t){const{shadow:e,shadowMap:s,light:i}=this,{renderer:n,scene:a}=t;e.updateMatrices(i),s.setSize(e.mapSize.width,e.mapSize.height,s.depth),n.render(a,e.camera)}updateShadow(t){const{shadowMap:e,light:s,shadow:i}=this,{renderer:n,scene:a,camera:o}=t,l=n.shadowMap.type,h=e.depthTexture.version;this._depthVersionCached=h;const u=i.camera.layers.mask;(i.camera.layers.mask&4294967294)===0&&(i.camera.layers.mask=o.layers.mask);const c=n.getRenderObjectFunction(),d=n.getMRT(),p=d?d.has("velocity"):!1;Pf=$Q(n,a,Pf),a.overrideMaterial=D5(s),n.setRenderObjectFunction(U5(n,i,l,p)),n.setClearColor(0,0),n.setRenderTarget(e),this.renderShadow(t),n.setRenderObjectFunction(c),l===bd&&i.isPointLightShadow!==!0&&this.vsmPass(n),i.camera.layers.mask=u,jQ(n,a,Pf)}vsmPass(t){const{shadow:e}=this,s=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(e.mapSize.width,e.mapSize.height,s),this.vsmShadowMapHorizontal.setSize(e.mapSize.width,e.mapSize.height,s),t.setRenderTarget(this.vsmShadowMapVertical),nd.material=this.vsmMaterialVertical,nd.render(t),t.setRenderTarget(this.vsmShadowMapHorizontal),nd.material=this.vsmMaterialHorizontal,nd.render(t)}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(t){const{shadow:e}=this;let s=e.needsUpdate||e.autoUpdate;s&&(this._cameraFrameId[t.camera]===t.frameId&&(s=!1),this._cameraFrameId[t.camera]=t.frameId),s&&(this.updateShadow(t),this.shadowMap.depthTexture.version===this._depthVersionCached&&(e.needsUpdate=!1))}}const YQ=(r,t)=>q(new $5(r,t)),ZQ=new dn,Bs=L(([r,t])=>{const e=r.toVar(),s=Qt(e),i=bi(1,Ke(s.x,Ke(s.y,s.z)));s.mulAssign(i),e.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Z(e.xy).toVar(),o=t.mul(1.5).oneMinus();return wt(s.z.greaterThanEqual(o),()=>{wt(e.z.greaterThan(0),()=>{n.x.assign(Ct(4,e.x))})}).ElseIf(s.x.greaterThanEqual(o),()=>{const l=rh(e.x);n.x.assign(e.z.mul(l).add(l.mul(2)))}).ElseIf(s.y.greaterThanEqual(o),()=>{const l=rh(e.y);n.x.assign(e.x.add(l.mul(2)).add(2)),n.y.assign(e.z.mul(l).sub(2))}),Z(.125,.25).mul(n).add(Z(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),j5=L(({depthTexture:r,bd3D:t,dp:e,texelSize:s})=>Gt(r,Bs(t,s.y)).compare(e)),W5=L(({depthTexture:r,bd3D:t,dp:e,texelSize:s,shadow:i})=>{const n=me("radius","float",i).setGroup(Nt),a=Z(-1,1).mul(n).mul(s.y);return Gt(r,Bs(t.add(a.xyy),s.y)).compare(e).add(Gt(r,Bs(t.add(a.yyy),s.y)).compare(e)).add(Gt(r,Bs(t.add(a.xyx),s.y)).compare(e)).add(Gt(r,Bs(t.add(a.yyx),s.y)).compare(e)).add(Gt(r,Bs(t,s.y)).compare(e)).add(Gt(r,Bs(t.add(a.xxy),s.y)).compare(e)).add(Gt(r,Bs(t.add(a.yxy),s.y)).compare(e)).add(Gt(r,Bs(t.add(a.xxx),s.y)).compare(e)).add(Gt(r,Bs(t.add(a.yxx),s.y)).compare(e)).mul(1/9)}),JQ=L(({filterFn:r,depthTexture:t,shadowCoord:e,shadow:s})=>{const i=e.xyz.toVar(),n=i.length(),a=dt("float").setGroup(Nt).onRenderUpdate(()=>s.camera.near),o=dt("float").setGroup(Nt).onRenderUpdate(()=>s.camera.far),l=me("bias","float",s).setGroup(Nt),h=dt(s.mapSize).setGroup(Nt),u=M(1).toVar();return wt(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),()=>{const c=n.sub(a).div(o.sub(a)).toVar();c.addAssign(l);const d=i.normalize(),p=Z(1).div(h.mul(Z(4,2)));u.assign(r({depthTexture:t,bd3D:d,dp:c,texelSize:p,shadow:s}))}),u}),Pv=new Mr,$o=new ge,xu=new ge;class QQ extends $5{static get type(){return"PointShadowNode"}constructor(t,e=null){super(t,e)}getShadowFilterFn(t){return t===QW?j5:W5}setupShadowCoord(t,e){return e}setupShadowFilter(t,{filterFn:e,shadowTexture:s,depthTexture:i,shadowCoord:n,shadow:a}){return JQ({filterFn:e,shadowTexture:s,depthTexture:i,shadowCoord:n,shadow:a})}renderShadow(t){const{shadow:e,shadowMap:s,light:i}=this,{renderer:n,scene:a}=t,o=e.getFrameExtents();xu.copy(e.mapSize),xu.multiply(o),s.setSize(xu.width,xu.height),$o.copy(e.mapSize);const l=n.autoClear,h=n.getClearColor(ZQ),u=n.getClearAlpha();n.autoClear=!1,n.setClearColor(e.clearColor,e.clearAlpha),n.clear();const c=e.getViewportCount();for(let d=0;d<c;d++){const p=e.getViewport(d),m=$o.x*p.x,f=xu.y-$o.y-$o.y*p.y;Pv.set(m,f,$o.x*p.z,$o.y*p.w),s.viewport.copy(Pv),e.updateMatrices(i,d),n.render(a,e.camera)}n.autoClear=l,n.setClearColor(h,u)}}const KQ=(r,t)=>q(new QQ(r,t)),q5=L(({lightDistance:r,cutoffDistance:t,decayExponent:e})=>{const s=r.pow(e).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(r.div(t).pow4().oneMinus().clamp().pow2()),s)}),tK=({color:r,lightVector:t,cutoffDistance:e,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=q5({lightDistance:n,cutoffDistance:e,decayExponent:s}),o=r.mul(a);return{lightDirection:i,lightColor:o}},eK=L(([r=le()])=>{const t=r.mul(2),e=t.x.floor(),s=t.y.floor();return e.add(s).mod(2).sign()}),rK=L(([r=le()],{renderer:t,material:e})=>{const s=v0(r.mul(2).sub(1));let i;if(e.alphaToCoverage&&t.samples>1){const n=M(s.fwidth()).toVar();i=qa(n.oneMinus(),n.add(1),s).oneMinus()}else i=xr(s.greaterThan(1),0,1);return i}),Ou=L(([r,t,e])=>{const s=M(e).toVar(),i=M(t).toVar(),n=xi(r).toVar();return xr(n,i,s)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ip=L(([r,t])=>{const e=xi(t).toVar(),s=M(r).toVar();return xr(e,s.negate(),s)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ze=L(([r])=>{const t=M(r).toVar();return N(di(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ae=L(([r,t])=>{const e=M(r).toVar();return t.assign(ze(e)),e.sub(M(t))}),sK=L(([r,t,e,s,i,n])=>{const a=M(n).toVar(),o=M(i).toVar(),l=M(s).toVar(),h=M(e).toVar(),u=M(t).toVar(),c=M(r).toVar(),d=M(Ct(1,o)).toVar();return Ct(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),iK=L(([r,t,e,s,i,n])=>{const a=M(n).toVar(),o=M(i).toVar(),l=P(s).toVar(),h=P(e).toVar(),u=P(t).toVar(),c=P(r).toVar(),d=M(Ct(1,o)).toVar();return Ct(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),H5=cr([sK,iK]),nK=L(([r,t,e,s,i,n,a,o,l,h,u])=>{const c=M(u).toVar(),d=M(h).toVar(),p=M(l).toVar(),m=M(o).toVar(),f=M(a).toVar(),x=M(n).toVar(),b=M(i).toVar(),w=M(s).toVar(),S=M(e).toVar(),_=M(t).toVar(),V=M(r).toVar(),z=M(Ct(1,p)).toVar(),A=M(Ct(1,d)).toVar();return M(Ct(1,c)).toVar().mul(A.mul(V.mul(z).add(_.mul(p))).add(d.mul(S.mul(z).add(w.mul(p))))).add(c.mul(A.mul(b.mul(z).add(x.mul(p))).add(d.mul(f.mul(z).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"}]}),aK=L(([r,t,e,s,i,n,a,o,l,h,u])=>{const c=M(u).toVar(),d=M(h).toVar(),p=M(l).toVar(),m=P(o).toVar(),f=P(a).toVar(),x=P(n).toVar(),b=P(i).toVar(),w=P(s).toVar(),S=P(e).toVar(),_=P(t).toVar(),V=P(r).toVar(),z=M(Ct(1,p)).toVar(),A=M(Ct(1,d)).toVar();return M(Ct(1,c)).toVar().mul(A.mul(V.mul(z).add(_.mul(p))).add(d.mul(S.mul(z).add(w.mul(p))))).add(c.mul(A.mul(b.mul(z).add(x.mul(p))).add(d.mul(f.mul(z).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"}]}),G5=cr([nK,aK]),oK=L(([r,t,e])=>{const s=M(e).toVar(),i=M(t).toVar(),n=st(r).toVar(),a=st(n.bitAnd(st(7))).toVar(),o=M(Ou(a.lessThan(st(4)),i,s)).toVar(),l=M(yt(2,Ou(a.lessThan(st(4)),s,i))).toVar();return ip(o,xi(a.bitAnd(st(1)))).add(ip(l,xi(a.bitAnd(st(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),lK=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=M(t).toVar(),o=st(r).toVar(),l=st(o.bitAnd(st(15))).toVar(),h=M(Ou(l.lessThan(st(8)),a,n)).toVar(),u=M(Ou(l.lessThan(st(4)),n,Ou(l.equal(st(12)).or(l.equal(st(14))),a,i))).toVar();return ip(h,xi(l.bitAnd(st(1)))).add(ip(u,xi(l.bitAnd(st(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"}]}),ir=cr([oK,lK]),uK=L(([r,t,e])=>{const s=M(e).toVar(),i=M(t).toVar(),n=Wl(r).toVar();return P(ir(n.x,i,s),ir(n.y,i,s),ir(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),hK=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=M(t).toVar(),o=Wl(r).toVar();return P(ir(o.x,a,n,i),ir(o.y,a,n,i),ir(o.z,a,n,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"}]}),hs=cr([uK,hK]),cK=L(([r])=>{const t=M(r).toVar();return yt(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),dK=L(([r])=>{const t=M(r).toVar();return yt(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),pK=L(([r])=>{const t=P(r).toVar();return yt(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),X5=cr([cK,pK]),mK=L(([r])=>{const t=P(r).toVar();return yt(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),Y5=cr([dK,mK]),Gr=L(([r,t])=>{const e=N(t).toVar(),s=st(r).toVar();return s.shiftLeft(e).bitOr(s.shiftRight(N(32).sub(e)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Z5=L(([r,t,e])=>{r.subAssign(e),r.bitXorAssign(Gr(e,N(4))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(Gr(r,N(6))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(Gr(t,N(8))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(Gr(e,N(16))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(Gr(r,N(19))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(Gr(t,N(4))),t.addAssign(r)}),Uh=L(([r,t,e])=>{const s=st(e).toVar(),i=st(t).toVar(),n=st(r).toVar();return s.bitXorAssign(i),s.subAssign(Gr(i,N(14))),n.bitXorAssign(s),n.subAssign(Gr(s,N(11))),i.bitXorAssign(n),i.subAssign(Gr(n,N(25))),s.bitXorAssign(i),s.subAssign(Gr(i,N(16))),n.bitXorAssign(s),n.subAssign(Gr(s,N(4))),i.bitXorAssign(n),i.subAssign(Gr(n,N(14))),s.bitXorAssign(i),s.subAssign(Gr(i,N(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),vr=L(([r])=>{const t=st(r).toVar();return M(t).div(M(st(N(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),pi=L(([r])=>{const t=M(r).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"}]}),fK=L(([r])=>{const t=N(r).toVar(),e=st(st(1)).toVar(),s=st(st(N(3735928559)).add(e.shiftLeft(st(2))).add(st(13))).toVar();return Uh(s.add(st(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gK=L(([r,t])=>{const e=N(t).toVar(),s=N(r).toVar(),i=st(st(2)).toVar(),n=st().toVar(),a=st().toVar(),o=st().toVar();return n.assign(a.assign(o.assign(st(N(3735928559)).add(i.shiftLeft(st(2))).add(st(13))))),n.addAssign(st(s)),a.addAssign(st(e)),Uh(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),yK=L(([r,t,e])=>{const s=N(e).toVar(),i=N(t).toVar(),n=N(r).toVar(),a=st(st(3)).toVar(),o=st().toVar(),l=st().toVar(),h=st().toVar();return o.assign(l.assign(h.assign(st(N(3735928559)).add(a.shiftLeft(st(2))).add(st(13))))),o.addAssign(st(n)),l.addAssign(st(i)),h.addAssign(st(s)),Uh(o,l,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),xK=L(([r,t,e,s])=>{const i=N(s).toVar(),n=N(e).toVar(),a=N(t).toVar(),o=N(r).toVar(),l=st(st(4)).toVar(),h=st().toVar(),u=st().toVar(),c=st().toVar();return h.assign(u.assign(c.assign(st(N(3735928559)).add(l.shiftLeft(st(2))).add(st(13))))),h.addAssign(st(o)),u.addAssign(st(a)),c.addAssign(st(n)),Z5(h,u,c),h.addAssign(st(i)),Uh(h,u,c)}).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"}]}),bK=L(([r,t,e,s,i])=>{const n=N(i).toVar(),a=N(s).toVar(),o=N(e).toVar(),l=N(t).toVar(),h=N(r).toVar(),u=st(st(5)).toVar(),c=st().toVar(),d=st().toVar(),p=st().toVar();return c.assign(d.assign(p.assign(st(N(3735928559)).add(u.shiftLeft(st(2))).add(st(13))))),c.addAssign(st(h)),d.addAssign(st(l)),p.addAssign(st(o)),Z5(c,d,p),c.addAssign(st(a)),d.addAssign(st(n)),Uh(c,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Ut=cr([fK,gK,yK,xK,bK]),vK=L(([r,t])=>{const e=N(t).toVar(),s=N(r).toVar(),i=st(Ut(s,e)).toVar(),n=Wl().toVar();return n.x.assign(i.bitAnd(N(255))),n.y.assign(i.shiftRight(N(8)).bitAnd(N(255))),n.z.assign(i.shiftRight(N(16)).bitAnd(N(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),wK=L(([r,t,e])=>{const s=N(e).toVar(),i=N(t).toVar(),n=N(r).toVar(),a=st(Ut(n,i,s)).toVar(),o=Wl().toVar();return o.x.assign(a.bitAnd(N(255))),o.y.assign(a.shiftRight(N(8)).bitAnd(N(255))),o.z.assign(a.shiftRight(N(16)).bitAnd(N(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),cs=cr([vK,wK]),MK=L(([r])=>{const t=Z(r).toVar(),e=N().toVar(),s=N().toVar(),i=M(ae(t.x,e)).toVar(),n=M(ae(t.y,s)).toVar(),a=M(pi(i)).toVar(),o=M(pi(n)).toVar(),l=M(H5(ir(Ut(e,s),i,n),ir(Ut(e.add(N(1)),s),i.sub(1),n),ir(Ut(e,s.add(N(1))),i,n.sub(1)),ir(Ut(e.add(N(1)),s.add(N(1))),i.sub(1),n.sub(1)),a,o)).toVar();return X5(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),TK=L(([r])=>{const t=P(r).toVar(),e=N().toVar(),s=N().toVar(),i=N().toVar(),n=M(ae(t.x,e)).toVar(),a=M(ae(t.y,s)).toVar(),o=M(ae(t.z,i)).toVar(),l=M(pi(n)).toVar(),h=M(pi(a)).toVar(),u=M(pi(o)).toVar(),c=M(G5(ir(Ut(e,s,i),n,a,o),ir(Ut(e.add(N(1)),s,i),n.sub(1),a,o),ir(Ut(e,s.add(N(1)),i),n,a.sub(1),o),ir(Ut(e.add(N(1)),s.add(N(1)),i),n.sub(1),a.sub(1),o),ir(Ut(e,s,i.add(N(1))),n,a,o.sub(1)),ir(Ut(e.add(N(1)),s,i.add(N(1))),n.sub(1),a,o.sub(1)),ir(Ut(e,s.add(N(1)),i.add(N(1))),n,a.sub(1),o.sub(1)),ir(Ut(e.add(N(1)),s.add(N(1)),i.add(N(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return Y5(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),Z0=cr([MK,TK]),NK=L(([r])=>{const t=Z(r).toVar(),e=N().toVar(),s=N().toVar(),i=M(ae(t.x,e)).toVar(),n=M(ae(t.y,s)).toVar(),a=M(pi(i)).toVar(),o=M(pi(n)).toVar(),l=P(H5(hs(cs(e,s),i,n),hs(cs(e.add(N(1)),s),i.sub(1),n),hs(cs(e,s.add(N(1))),i,n.sub(1)),hs(cs(e.add(N(1)),s.add(N(1))),i.sub(1),n.sub(1)),a,o)).toVar();return X5(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),SK=L(([r])=>{const t=P(r).toVar(),e=N().toVar(),s=N().toVar(),i=N().toVar(),n=M(ae(t.x,e)).toVar(),a=M(ae(t.y,s)).toVar(),o=M(ae(t.z,i)).toVar(),l=M(pi(n)).toVar(),h=M(pi(a)).toVar(),u=M(pi(o)).toVar(),c=P(G5(hs(cs(e,s,i),n,a,o),hs(cs(e.add(N(1)),s,i),n.sub(1),a,o),hs(cs(e,s.add(N(1)),i),n,a.sub(1),o),hs(cs(e.add(N(1)),s.add(N(1)),i),n.sub(1),a.sub(1),o),hs(cs(e,s,i.add(N(1))),n,a,o.sub(1)),hs(cs(e.add(N(1)),s,i.add(N(1))),n.sub(1),a,o.sub(1)),hs(cs(e,s.add(N(1)),i.add(N(1))),n,a.sub(1),o.sub(1)),hs(cs(e.add(N(1)),s.add(N(1)),i.add(N(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return Y5(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),J0=cr([NK,SK]),_K=L(([r])=>{const t=M(r).toVar(),e=N(ze(t)).toVar();return vr(Ut(e))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),AK=L(([r])=>{const t=Z(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar();return vr(Ut(e,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),zK=L(([r])=>{const t=P(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar(),i=N(ze(t.z)).toVar();return vr(Ut(e,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),CK=L(([r])=>{const t=pt(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar(),i=N(ze(t.z)).toVar(),n=N(ze(t.w)).toVar();return vr(Ut(e,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),EK=cr([_K,AK,zK,CK]),VK=L(([r])=>{const t=M(r).toVar(),e=N(ze(t)).toVar();return P(vr(Ut(e,N(0))),vr(Ut(e,N(1))),vr(Ut(e,N(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),RK=L(([r])=>{const t=Z(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar();return P(vr(Ut(e,s,N(0))),vr(Ut(e,s,N(1))),vr(Ut(e,s,N(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),LK=L(([r])=>{const t=P(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar(),i=N(ze(t.z)).toVar();return P(vr(Ut(e,s,i,N(0))),vr(Ut(e,s,i,N(1))),vr(Ut(e,s,i,N(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),IK=L(([r])=>{const t=pt(r).toVar(),e=N(ze(t.x)).toVar(),s=N(ze(t.y)).toVar(),i=N(ze(t.z)).toVar(),n=N(ze(t.w)).toVar();return P(vr(Ut(e,s,i,n,N(0))),vr(Ut(e,s,i,n,N(1))),vr(Ut(e,s,i,n,N(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),J5=cr([VK,RK,LK,IK]),np=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=N(t).toVar(),o=P(r).toVar(),l=M(0).toVar(),h=M(1).toVar();return Xt(a,()=>{l.addAssign(h.mul(Z0(o))),h.mulAssign(i),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Q5=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=N(t).toVar(),o=P(r).toVar(),l=P(0).toVar(),h=M(1).toVar();return Xt(a,()=>{l.addAssign(h.mul(J0(o))),h.mulAssign(i),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),PK=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=N(t).toVar(),o=P(r).toVar();return Z(np(o,a,n,i),np(o.add(P(N(19),N(193),N(17))),a,n,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"}]}),FK=L(([r,t,e,s])=>{const i=M(s).toVar(),n=M(e).toVar(),a=N(t).toVar(),o=P(r).toVar(),l=P(Q5(o,a,n,i)).toVar(),h=M(np(o.add(P(N(19),N(193),N(17))),a,n,i)).toVar();return pt(l,h)}).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"}]}),OK=L(([r,t,e,s,i,n,a])=>{const o=N(a).toVar(),l=M(n).toVar(),h=N(i).toVar(),u=N(s).toVar(),c=N(e).toVar(),d=N(t).toVar(),p=Z(r).toVar(),m=P(J5(Z(d.add(u),c.add(h)))).toVar(),f=Z(m.x,m.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const x=Z(Z(M(d),M(c)).add(f)).toVar(),b=Z(x.sub(p)).toVar();return wt(o.equal(N(2)),()=>Qt(b.x).add(Qt(b.y))),wt(o.equal(N(3)),()=>Ke(Qt(b.x),Qt(b.y))),aa(b,b)}).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"}]}),BK=L(([r,t,e,s,i,n,a,o,l])=>{const h=N(l).toVar(),u=M(o).toVar(),c=N(a).toVar(),d=N(n).toVar(),p=N(i).toVar(),m=N(s).toVar(),f=N(e).toVar(),x=N(t).toVar(),b=P(r).toVar(),w=P(J5(P(x.add(p),f.add(d),m.add(c)))).toVar();w.subAssign(.5),w.mulAssign(u),w.addAssign(.5);const S=P(P(M(x),M(f),M(m)).add(w)).toVar(),_=P(S.sub(b)).toVar();return wt(h.equal(N(2)),()=>Qt(_.x).add(Qt(_.y)).add(Qt(_.z))),wt(h.equal(N(3)),()=>Ke(Qt(_.x),Qt(_.y),Qt(_.z))),aa(_,_)}).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"}]}),Hl=cr([OK,BK]),kK=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=Z(r).toVar(),a=N().toVar(),o=N().toVar(),l=Z(ae(n.x,a),ae(n.y,o)).toVar(),h=M(1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:u})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:c})=>{const d=M(Hl(l,u,c,a,o,i,s)).toVar();h.assign(vs(h,d))})}),wt(s.equal(N(0)),()=>{h.assign(Ai(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DK=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=Z(r).toVar(),a=N().toVar(),o=N().toVar(),l=Z(ae(n.x,a),ae(n.y,o)).toVar(),h=Z(1e6,1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:u})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:c})=>{const d=M(Hl(l,u,c,a,o,i,s)).toVar();wt(d.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.y.assign(d)})})}),wt(s.equal(N(0)),()=>{h.assign(Ai(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),UK=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=Z(r).toVar(),a=N().toVar(),o=N().toVar(),l=Z(ae(n.x,a),ae(n.y,o)).toVar(),h=P(1e6,1e6,1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:u})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:c})=>{const d=M(Hl(l,u,c,a,o,i,s)).toVar();wt(d.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(d)}).ElseIf(d.lessThan(h.z),()=>{h.z.assign(d)})})}),wt(s.equal(N(0)),()=>{h.assign(Ai(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$K=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=P(r).toVar(),a=N().toVar(),o=N().toVar(),l=N().toVar(),h=P(ae(n.x,a),ae(n.y,o),ae(n.z,l)).toVar(),u=M(1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:c})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:d})=>{Xt({start:-1,end:N(1),name:"z",condition:"<="},({z:p})=>{const m=M(Hl(h,c,d,p,a,o,l,i,s)).toVar();u.assign(vs(u,m))})})}),wt(s.equal(N(0)),()=>{u.assign(Ai(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),jK=cr([kK,$K]),WK=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=P(r).toVar(),a=N().toVar(),o=N().toVar(),l=N().toVar(),h=P(ae(n.x,a),ae(n.y,o),ae(n.z,l)).toVar(),u=Z(1e6,1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:c})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:d})=>{Xt({start:-1,end:N(1),name:"z",condition:"<="},({z:p})=>{const m=M(Hl(h,c,d,p,a,o,l,i,s)).toVar();wt(m.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.y.assign(m)})})})}),wt(s.equal(N(0)),()=>{u.assign(Ai(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),qK=cr([DK,WK]),HK=L(([r,t,e])=>{const s=N(e).toVar(),i=M(t).toVar(),n=P(r).toVar(),a=N().toVar(),o=N().toVar(),l=N().toVar(),h=P(ae(n.x,a),ae(n.y,o),ae(n.z,l)).toVar(),u=P(1e6,1e6,1e6).toVar();return Xt({start:-1,end:N(1),name:"x",condition:"<="},({x:c})=>{Xt({start:-1,end:N(1),name:"y",condition:"<="},({y:d})=>{Xt({start:-1,end:N(1),name:"z",condition:"<="},({z:p})=>{const m=M(Hl(h,c,d,p,a,o,l,i,s)).toVar();wt(m.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(m)}).ElseIf(m.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(m)}).ElseIf(m.lessThan(u.z),()=>{u.z.assign(m)})})})}),wt(s.equal(N(0)),()=>{u.assign(Ai(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GK=cr([UK,HK]),XK=L(([r])=>{const t=r.y,e=r.z,s=P().toVar();return wt(t.lessThan(1e-4),()=>{s.assign(P(e,e,e))}).Else(()=>{let i=r.x;i=i.sub(di(i)).mul(6).toVar();const n=N(b0(i)),a=i.sub(M(n)),o=e.mul(t.oneMinus()),l=e.mul(t.mul(a).oneMinus()),h=e.mul(t.mul(a.oneMinus()).oneMinus());wt(n.equal(N(0)),()=>{s.assign(P(e,h,o))}).ElseIf(n.equal(N(1)),()=>{s.assign(P(l,e,o))}).ElseIf(n.equal(N(2)),()=>{s.assign(P(o,e,h))}).ElseIf(n.equal(N(3)),()=>{s.assign(P(o,l,e))}).ElseIf(n.equal(N(4)),()=>{s.assign(P(h,o,e))}).Else(()=>{s.assign(P(e,o,l))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),YK=L(([r])=>{const t=P(r).toVar(),e=M(t.x).toVar(),s=M(t.y).toVar(),i=M(t.z).toVar(),n=M(vs(e,vs(s,i))).toVar(),a=M(Ke(e,Ke(s,i))).toVar(),o=M(a.sub(n)).toVar(),l=M().toVar(),h=M().toVar(),u=M().toVar();return u.assign(a),wt(a.greaterThan(0),()=>{h.assign(o.div(a))}).Else(()=>{h.assign(0)}),wt(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{wt(e.greaterThanEqual(a),()=>{l.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{l.assign(Ee(2,i.sub(e).div(o)))}).Else(()=>{l.assign(Ee(4,e.sub(s).div(o)))}),l.mulAssign(1/6),wt(l.lessThan(0),()=>{l.addAssign(1)})}),P(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),ZK=L(([r])=>{const t=P(r).toVar(),e=c0(p0(t,P(.04045))).toVar(),s=P(t.div(12.92)).toVar(),i=P(Ys(Ke(t.add(P(.055)),P(0)).div(1.055),P(2.4))).toVar();return Ne(s,i,e)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),K5=(r,t)=>{r=M(r),t=M(t);const e=Z(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return qa(r.sub(e),r.add(e),t)},tA=(r,t,e,s)=>Ne(r,t,e[s].clamp()),JK=(r,t,e=le())=>tA(r,t,e,"x"),QK=(r,t,e=le())=>tA(r,t,e,"y"),eA=(r,t,e,s,i)=>Ne(r,t,K5(e,s[i])),KK=(r,t,e,s=le())=>eA(r,t,e,s,"x"),ttt=(r,t,e,s=le())=>eA(r,t,e,s,"y"),ett=(r=1,t=0,e=le())=>e.mul(r).add(t),rtt=(r,t=1)=>(r=M(r),r.abs().pow(t).mul(r.sign())),stt=(r,t=1,e=.5)=>M(r).sub(e).mul(t).add(e),itt=(r=le(),t=1,e=0)=>Z0(r.convert("vec2|vec3")).mul(t).add(e),ntt=(r=le(),t=1,e=0)=>J0(r.convert("vec2|vec3")).mul(t).add(e),att=(r=le(),t=1,e=0)=>(r=r.convert("vec2|vec3"),pt(J0(r),Z0(r.add(Z(19,73)))).mul(t).add(e)),ott=(r=le(),t=1)=>jK(r.convert("vec2|vec3"),t,N(1)),ltt=(r=le(),t=1)=>qK(r.convert("vec2|vec3"),t,N(1)),utt=(r=le(),t=1)=>GK(r.convert("vec2|vec3"),t,N(1)),htt=(r=le())=>EK(r.convert("vec2|vec3")),ctt=(r=le(),t=3,e=2,s=.5,i=1)=>np(r,N(t),e,s).mul(i),dtt=(r=le(),t=3,e=2,s=.5,i=1)=>PK(r,N(t),e,s).mul(i),ptt=(r=le(),t=3,e=2,s=.5,i=1)=>Q5(r,N(t),e,s).mul(i),mtt=(r=le(),t=3,e=2,s=.5,i=1)=>FK(r,N(t),e,s).mul(i),ftt=L(([r,t,e])=>{const s=Ka(r).toVar(),i=Ct(M(.5).mul(t.sub(e)),Oa).div(s).toVar(),n=Ct(M(-.5).mul(t.sub(e)),Oa).div(s).toVar(),a=P().toVar();a.x=s.x.greaterThan(M(0)).select(i.x,n.x),a.y=s.y.greaterThan(M(0)).select(i.y,n.y),a.z=s.z.greaterThan(M(0)).select(i.z,n.z);const o=vs(a.x,a.y,a.z).toVar();return Oa.add(s.mul(o)).toVar().sub(e)}),gtt=L(([r,t])=>{const e=r.x,s=r.y,i=r.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(2*.511664).mul(s)),n=n.add(t.element(2).mul(2*.511664).mul(i)),n=n.add(t.element(3).mul(2*.511664).mul(e)),n=n.add(t.element(4).mul(2*.429043).mul(e).mul(s)),n=n.add(t.element(5).mul(2*.429043).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(2*.429043).mul(e).mul(i)),n=n.add(t.element(8).mul(.429043).mul(yt(e,e).sub(yt(s,s)))),n});var y=Object.freeze({__proto__:null,BRDF_GGX:FY,BRDF_Lambert:VY,BasicPointShadowFilter:j5,BasicShadowFilter:F5,Break:X3,Const:W_,Continue:sY,DFGApprox:OY,D_GGX:o5,Discard:o3,EPSILON:h_,F_Schlick:i5,Fn:L,INFINITY:eG,If:wt,Loop:Xt,NodeAccess:ai,NodeShaderStage:Au,NodeType:iH,NodeUpdateType:$t,PCFShadowFilter:O5,PCFSoftShadowFilter:B5,PI:Jd,PI2:rG,PointShadowFilter:W5,Return:vG,Schlick_to_F0:BY,ScriptableNodeResources:Md,ShaderNode:tl,Stack:Ip,Switch:_H,TBNViewMatrix:F0,VSMShadowFilter:k5,V_GGX_SmithCorrelated:a5,Var:j_,abs:Qt,acesFilmicToneMapping:kJ,acos:x_,add:Ee,addMethodChaining:$,addNodeElement:TG,agxToneMapping:jJ,all:c_,alphaT:Mg,and:XS,anisotropy:OS,anisotropyB:pl,anisotropyT:vd,any:d_,append:EH,array:US,arrayBuffer:zH,asin:y_,assign:$S,atan:g0,atan2:k_,atomicAdd:wQ,atomicAnd:SQ,atomicFunc:zi,atomicLoad:bQ,atomicMax:TQ,atomicMin:NQ,atomicOr:_Q,atomicStore:vQ,atomicSub:MQ,atomicXor:AQ,attenuationColor:YH,attenuationDistance:XH,attribute:sa,attributeArray:tJ,backgroundBlurriness:iJ,backgroundIntensity:nJ,backgroundRotation:aJ,batch:q3,billboarding:FZ,bitAnd:QS,bitNot:KS,bitOr:t_,bitXor:e_,bitangentGeometry:iX,bitangentLocal:nX,bitangentView:C3,bitangentWorld:aX,bitcast:sG,blendBurn:N5,blendColor:gJ,blendDodge:S5,blendOverlay:A5,blendScreen:_5,blur:d5,bool:xi,buffer:Rh,bufferAttribute:Vh,bumpMap:R3,burn:bJ,bvec2:zS,bvec3:c0,bvec4:RS,bypass:s3,cache:e3,call:jS,cameraFar:On,cameraIndex:Up,cameraNear:Fn,cameraNormalMatrix:PG,cameraPosition:FG,cameraProjectionMatrix:Lh,cameraProjectionMatrixInverse:LG,cameraViewMatrix:_s,cameraWorldMatrix:IG,cbrt:L_,cdl:AJ,ceil:Op,checker:eK,cineonToneMapping:OJ,clamp:on,clearcoat:LH,clearcoatRoughness:IH,code:Hp,color:_S,colorSpaceToWorking:_0,colorToDirection:CY,compute:t3,computeSkinning:eY,cond:D_,context:M0,convert:IS,convertColorSpace:hG,convertToTexture:YZ,cos:Ui,cross:kp,cubeTexture:I0,cubeTextureBase:L0,cubeToUV:Bs,dFdx:y0,dFdy:x0,dashSize:$H,debug:u3,decrement:o_,decrementBefore:n_,defaultBuildStages:nH,defaultShaderStages:bS,defined:th,degrees:m_,deltaTime:x5,densityFog:rQ,densityFogFactor:L5,depth:U0,depthPass:RJ,difference:z_,diffuseColor:os,directPointLight:tK,directionToColor:zY,dispersion:ZH,distance:A_,div:bi,dodge:vJ,dot:aa,drawIndex:$3,dynamicBufferAttribute:K_,element:LS,emissive:wg,equal:d0,equals:S_,equirectUV:s5,exp:f_,exp2:Il,expression:ln,faceDirection:Ph,faceForward:w0,faceforward:iG,float:M,floor:di,fog:H0,fract:pn,frameGroup:JH,frameId:_Z,frontFacing:y3,fwidth:T_,gain:bZ,gapSize:jH,getConstNodeType:NS,getCurrentStack:SS,getDirection:h5,getDistanceAttenuation:q5,getGeometryRoughness:n5,getNormalFromDepth:JZ,getParallaxCorrectNormal:ftt,getRoughness:RY,getScreenPosition:ZZ,getShIrradianceAt:gtt,getShadowMaterial:D5,getShadowRenderObjectFunction:U5,getTextureIndex:g5,getViewPosition:Yo,globalId:lQ,glsl:GJ,glslFn:YJ,grayscale:TJ,greaterThan:p0,greaterThanEqual:GS,hash:xZ,highpModelNormalViewMatrix:YG,highpModelViewMatrix:XG,hue:_J,increment:a_,incrementBefore:i_,instance:XX,instanceIndex:Gn,instancedArray:eJ,instancedBufferAttribute:Kd,instancedDynamicBufferAttribute:Tg,instancedMesh:W3,int:N,inverseSqrt:f0,inversesqrt:nG,invocationLocalIndex:GX,invocationSubgroupIndex:HX,ior:qH,iridescence:FS,iridescenceIOR:OH,iridescenceThickness:BH,ivec2:Ze,ivec3:CS,ivec4:ES,js:qJ,label:$_,length:Qd,lengthSq:v0,lessThan:qS,lessThanEqual:HS,lightPosition:I5,lightProjectionUV:zQ,lightShadowMatrix:X0,lightTargetDirection:EQ,lightTargetPosition:P5,lightViewPosition:CQ,lightingContext:J3,lights:IQ,linearDepth:rp,linearToneMapping:PJ,localId:uQ,log:m0,log2:Ki,logarithmicDepthToViewZ:xY,loop:iY,luminance:q0,mat2:Pp,mat3:bs,mat4:Fa,matcapUV:nZ,materialAO:k3,materialAlphaTest:L3,materialAnisotropy:CX,materialAnisotropyVector:Xo,materialAttenuationColor:OX,materialAttenuationDistance:FX,materialClearcoat:TX,materialClearcoatNormal:SX,materialClearcoatRoughness:NX,materialColor:I3,materialDispersion:WX,materialEmissive:P3,materialEnvIntensity:QG,materialEnvRotation:R0,materialIOR:PX,materialIridescence:EX,materialIridescenceIOR:VX,materialIridescenceThickness:RX,materialLightMap:B3,materialLineDashOffset:$X,materialLineDashSize:kX,materialLineGapSize:DX,materialLineScale:BX,materialLineWidth:UX,materialMetalness:MX,materialNormal:O3,materialOpacity:F3,materialPointSize:jX,materialReference:Aa,materialReflectivity:vX,materialRefractionRatio:M3,materialRotation:_X,materialRoughness:wX,materialSheen:AX,materialSheenRoughness:zX,materialShininess:fX,materialSpecular:gX,materialSpecularColor:xX,materialSpecularIntensity:yX,materialSpecularStrength:bX,materialThickness:IX,materialTransmission:LX,max:Ke,maxMipLevel:c3,mediumpModelViewMatrix:f3,metalness:RH,min:vs,mix:Ne,mixElement:O_,mod:Eh,modInt:u_,modelDirection:$G,modelNormalMatrix:m3,modelPosition:jG,modelRadius:HG,modelScale:WG,modelViewMatrix:Ih,modelViewPosition:qG,modelViewProjection:D3,modelWorldMatrix:qi,modelWorldMatrixInverse:GG,morphReference:Y3,mrt:y5,mul:yt,mx_aastep:K5,mx_cell_noise_float:htt,mx_contrast:stt,mx_fractal_noise_float:ctt,mx_fractal_noise_vec2:dtt,mx_fractal_noise_vec3:ptt,mx_fractal_noise_vec4:mtt,mx_hsvtorgb:XK,mx_noise_float:itt,mx_noise_vec3:ntt,mx_noise_vec4:att,mx_ramplr:JK,mx_ramptb:QK,mx_rgbtohsv:YK,mx_safepower:rtt,mx_splitlr:KK,mx_splittb:ttt,mx_srgb_texture_to_lin_rec709:ZK,mx_transform_uv:ett,mx_worley_noise_float:ott,mx_worley_noise_vec2:ltt,mx_worley_noise_vec3:utt,namespace:r3,negate:b_,neutralToneMapping:WJ,nodeArray:Pa,nodeImmutable:K,nodeObject:q,nodeObjects:zh,nodeProxy:G,normalFlat:x3,normalGeometry:E0,normalLocal:Fr,normalMap:Sg,normalView:vi,normalWorld:b3,normalize:Ka,not:ZS,notEqual:WS,numWorkgroups:aQ,objectDirection:OG,objectGroup:DS,objectPosition:p3,objectRadius:UG,objectScale:kG,objectViewPosition:DG,objectWorldMatrix:BG,oneMinus:v_,or:YS,orthographicDepthToViewZ:yY,oscSawtooth:LZ,oscSine:EZ,oscSquare:VZ,oscTriangle:RZ,output:ml,outputStruct:gZ,overlay:MJ,overloadingFn:cr,parabola:Eg,parallaxDirection:V3,parallaxUV:lX,parameter:uZ,pass:EJ,passTexture:VJ,pcurve:vZ,perspectiveDepthToViewZ:k0,pmremTexture:sZ,pointShadow:KQ,pointUV:sJ,pointWidth:WH,positionGeometry:C0,positionLocal:_e,positionPrevious:tp,positionView:or,positionViewDirection:Zr,positionWorld:Oa,positionWorldDirection:g3,posterize:CJ,pow:Ys,pow2:C_,pow3:E_,pow4:V_,premult:yJ,property:ql,radians:p_,rand:F_,range:iQ,rangeFog:eQ,rangeFogFactor:R5,reciprocal:M_,reference:me,referenceBuffer:Ng,reflect:__,reflectVector:S3,reflectView:T3,reflector:WZ,refract:P_,refractVector:_3,refractView:N3,reinhardToneMapping:FJ,remainder:l_,remap:n3,remapClamp:a3,renderGroup:Nt,renderOutput:l3,rendererReference:Z_,rotate:m5,rotateUV:IZ,roughness:PS,round:w_,rtt:w5,sRGBTransferEOTF:G_,sRGBTransferOETF:X_,sampler:zG,samplerComparison:CG,saturate:I_,saturation:NJ,screen:wJ,screenCoordinate:kh,screenSize:ep,screenUV:oa,scriptable:tQ,scriptableValue:wd,select:xr,setCurrentStack:vg,shaderStages:aH,shadow:YQ,shadowPositionWorld:Y0,shapeCircle:rK,sharedUniformGroup:Fp,sheen:PH,sheenRoughness:FH,shiftLeft:r_,shiftRight:s_,shininess:UH,sign:rh,sin:Yr,sinc:wZ,skinning:G3,smoothstep:qa,smoothstepElement:B_,specularColor:kH,specularF90:DH,spherizeUV:PZ,split:CH,spritesheetUV:kZ,sqrt:Ai,stack:cZ,step:Bp,storage:Ba,storageBarrier:pQ,storageObject:tY,storageTexture:M5,string:AH,struct:fZ,sub:Ct,subgroupIndex:qX,subgroupSize:hQ,tan:g_,tangentGeometry:jp,tangentLocal:Fh,tangentView:Oh,tangentWorld:z3,temp:q_,texture:Gt,texture3D:cJ,textureBarrier:mQ,textureBicubic:kY,textureCubeUV:c5,textureLoad:ve,textureSize:Hn,textureStore:lJ,thickness:GH,time:to,timerDelta:CZ,timerGlobal:zZ,timerLocal:AZ,toneMapping:J_,toneMappingExposure:Q_,toonOutlinePass:IJ,transformDirection:R_,transformNormal:w3,transformNormalToView:V0,transformedBentNormalView:uX,transformedBitangentView:E3,transformedBitangentWorld:oX,transformedClearcoatNormalView:JG,transformedNormalView:hn,transformedNormalWorld:v3,transformedTangentView:P0,transformedTangentWorld:sX,transmission:HH,transpose:N_,triNoise3D:TZ,triplanarTexture:UZ,triplanarTextures:b5,trunc:b0,tslFn:VH,uint:st,uniform:dt,uniformArray:Hs,uniformCubeTexture:tX,uniformGroup:kS,uniformTexture:AG,uniforms:VG,unpremult:xJ,userData:pJ,uv:le,uvec2:AS,uvec3:Wl,uvec4:VS,varying:Ss,varyingProperty:eh,vec2:Z,vec3:P,vec4:pt,vectorComponents:jl,velocity:fJ,vertexColor:r5,vertexIndex:U3,vertexStage:H_,vibrance:SJ,viewZToLogarithmicDepth:D0,viewZToOrthographicDepth:fl,viewZToPerspectiveDepth:t5,viewport:O0,viewportBottomLeft:pY,viewportCoordinate:K3,viewportDepthTexture:B0,viewportLinearDepth:bY,viewportMipTexture:fY,viewportResolution:cY,viewportSafeUV:OZ,viewportSharedTexture:AY,viewportSize:Q3,viewportTexture:mY,viewportTopLeft:dY,viewportUV:hY,wgsl:HJ,wgslFn:ZJ,workgroupArray:yQ,workgroupBarrier:dQ,workgroupId:oQ,workingToColorSpace:Y_,xor:JS});const jo=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};ai.READ_ONLY+"",ai.WRITE_ONLY+"",ai.READ_WRITE+"";jo&&jo.VERTEX,jo&&jo.FRAGMENT,jo&&jo.COMPUTE;const va={tsl_xor:new He("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new He("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new He("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new He("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new He("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new He("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new He("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new He("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 He("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 He("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new He("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 He("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new He(`
|
|
125
|
+
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
126
|
+
|
|
127
|
+
let res = vec2f( iRes );
|
|
128
|
+
|
|
129
|
+
let uvScaled = coord * res;
|
|
130
|
+
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
131
|
+
|
|
132
|
+
// https://www.shadertoy.com/view/WtyXRy
|
|
133
|
+
|
|
134
|
+
let uv = uvWrapping - 0.5;
|
|
135
|
+
let iuv = floor( uv );
|
|
136
|
+
let f = fract( uv );
|
|
137
|
+
|
|
138
|
+
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
139
|
+
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
140
|
+
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
141
|
+
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
142
|
+
|
|
143
|
+
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
`)};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(va.pow_float=new He("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),va.pow_vec2=new He("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 ) ); }",[va.pow_float]),va.pow_vec3=new He("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 ) ); }",[va.pow_float]),va.pow_vec4=new He("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 ) ); }",[va.pow_float]));/**
|
|
147
|
+
* @license
|
|
148
|
+
* Copyright 2010-2025 Three.js Authors
|
|
149
|
+
* SPDX-License-Identifier: MIT
|
|
150
|
+
*/y.BRDF_GGX;y.BRDF_Lambert;y.BasicShadowFilter;y.Break;y.Continue;y.DFGApprox;y.D_GGX;y.Discard;y.EPSILON;y.F_Schlick;y.Fn;y.INFINITY;y.If;y.Switch;y.Loop;y.NodeShaderStage;y.NodeType;y.NodeUpdateType;y.NodeAccess;y.PCFShadowFilter;y.PCFSoftShadowFilter;y.PI;y.PI2;y.Return;y.Schlick_to_F0;y.ScriptableNodeResources;y.ShaderNode;y.TBNViewMatrix;y.VSMShadowFilter;y.V_GGX_SmithCorrelated;y.abs;y.acesFilmicToneMapping;y.acos;y.add;y.addNodeElement;y.agxToneMapping;y.all;y.alphaT;y.and;y.anisotropy;y.anisotropyB;y.anisotropyT;y.any;y.append;y.array;y.arrayBuffer;y.asin;y.assign;y.atan;y.atan2;y.atomicAdd;y.atomicAnd;y.atomicFunc;y.atomicMax;y.atomicMin;y.atomicOr;y.atomicStore;y.atomicSub;y.atomicXor;y.atomicLoad;y.attenuationColor;y.attenuationDistance;y.attribute;y.attributeArray;y.backgroundBlurriness;y.backgroundIntensity;y.backgroundRotation;y.batch;y.billboarding;y.bitAnd;y.bitNot;y.bitOr;y.bitXor;y.bitangentGeometry;y.bitangentLocal;y.bitangentView;y.bitangentWorld;y.bitcast;y.blendBurn;y.blendColor;y.blendDodge;y.blendOverlay;y.blendScreen;y.blur;y.bool;y.buffer;y.bufferAttribute;y.bumpMap;y.burn;y.bvec2;y.bvec3;y.bvec4;y.bypass;y.cache;y.call;y.cameraFar;y.cameraIndex;y.cameraNear;y.cameraNormalMatrix;y.cameraPosition;y.cameraProjectionMatrix;y.cameraProjectionMatrixInverse;y.cameraViewMatrix;y.cameraWorldMatrix;y.cbrt;y.cdl;y.ceil;y.checker;y.cineonToneMapping;y.clamp;y.clearcoat;y.clearcoatRoughness;y.code;y.color;y.colorSpaceToWorking;y.colorToDirection;y.compute;y.computeSkinning;y.cond;y.Const;y.context;y.convert;y.convertColorSpace;y.convertToTexture;y.cos;y.cross;y.cubeTexture;y.dFdx;y.dFdy;y.dashSize;y.debug;y.decrement;y.decrementBefore;y.defaultBuildStages;y.defaultShaderStages;y.defined;y.degrees;y.deltaTime;y.densityFog;y.densityFogFactor;y.depth;y.depthPass;y.difference;y.diffuseColor;y.directPointLight;y.directionToColor;y.dispersion;y.distance;y.div;y.dodge;y.dot;y.drawIndex;y.dynamicBufferAttribute;y.element;y.emissive;y.equal;y.equals;y.equirectUV;y.exp;y.exp2;y.expression;y.faceDirection;y.faceForward;y.faceforward;y.float;y.floor;y.fog;y.fract;y.frameGroup;y.frameId;y.frontFacing;y.fwidth;y.gain;y.gapSize;y.getConstNodeType;y.getCurrentStack;y.getDirection;y.getDistanceAttenuation;y.getGeometryRoughness;y.getNormalFromDepth;y.getParallaxCorrectNormal;y.getRoughness;y.getScreenPosition;y.getShIrradianceAt;y.getTextureIndex;y.getViewPosition;y.getShadowMaterial;y.getShadowRenderObjectFunction;y.glsl;y.glslFn;y.grayscale;y.greaterThan;y.greaterThanEqual;y.hash;y.highpModelNormalViewMatrix;y.highpModelViewMatrix;y.hue;y.increment;y.incrementBefore;y.instance;y.instanceIndex;y.instancedArray;y.instancedBufferAttribute;y.instancedDynamicBufferAttribute;y.instancedMesh;y.int;y.inverseSqrt;y.inversesqrt;y.invocationLocalIndex;y.invocationSubgroupIndex;y.ior;y.iridescence;y.iridescenceIOR;y.iridescenceThickness;y.ivec2;y.ivec3;y.ivec4;y.js;y.label;y.length;y.lengthSq;y.lessThan;y.lessThanEqual;y.lightPosition;y.lightShadowMatrix;y.lightTargetDirection;y.lightTargetPosition;y.lightViewPosition;y.lightingContext;y.lights;y.linearDepth;y.linearToneMapping;y.localId;y.globalId;y.log;y.log2;y.logarithmicDepthToViewZ;y.loop;y.luminance;y.mediumpModelViewMatrix;y.mat2;y.mat3;y.mat4;y.matcapUV;y.materialAO;y.materialAlphaTest;y.materialAnisotropy;y.materialAnisotropyVector;y.materialAttenuationColor;y.materialAttenuationDistance;y.materialClearcoat;y.materialClearcoatNormal;y.materialClearcoatRoughness;y.materialColor;y.materialDispersion;y.materialEmissive;y.materialIOR;y.materialIridescence;y.materialIridescenceIOR;y.materialIridescenceThickness;y.materialLightMap;y.materialLineDashOffset;y.materialLineDashSize;y.materialLineGapSize;y.materialLineScale;y.materialLineWidth;y.materialMetalness;y.materialNormal;y.materialOpacity;y.materialPointSize;y.materialReference;y.materialReflectivity;y.materialRefractionRatio;y.materialRotation;y.materialRoughness;y.materialSheen;y.materialSheenRoughness;y.materialShininess;y.materialSpecular;y.materialSpecularColor;y.materialSpecularIntensity;y.materialSpecularStrength;y.materialThickness;y.materialTransmission;y.max;y.maxMipLevel;y.metalness;y.min;y.mix;y.mixElement;y.mod;y.modInt;y.modelDirection;y.modelNormalMatrix;y.modelPosition;y.modelRadius;y.modelScale;y.modelViewMatrix;y.modelViewPosition;y.modelViewProjection;y.modelWorldMatrix;y.modelWorldMatrixInverse;y.morphReference;y.mrt;y.mul;y.mx_aastep;y.mx_cell_noise_float;y.mx_contrast;y.mx_fractal_noise_float;y.mx_fractal_noise_vec2;y.mx_fractal_noise_vec3;y.mx_fractal_noise_vec4;y.mx_hsvtorgb;y.mx_noise_float;y.mx_noise_vec3;y.mx_noise_vec4;y.mx_ramplr;y.mx_ramptb;y.mx_rgbtohsv;y.mx_safepower;y.mx_splitlr;y.mx_splittb;y.mx_srgb_texture_to_lin_rec709;y.mx_transform_uv;y.mx_worley_noise_float;y.mx_worley_noise_vec2;y.mx_worley_noise_vec3;y.namespace;y.negate;y.neutralToneMapping;y.nodeArray;y.nodeImmutable;y.nodeObject;y.nodeObjects;y.nodeProxy;y.normalFlat;y.normalGeometry;y.normalLocal;y.normalMap;y.normalView;y.normalWorld;y.normalize;y.not;y.notEqual;y.numWorkgroups;y.objectDirection;y.objectGroup;y.objectPosition;y.objectRadius;y.objectScale;y.objectViewPosition;y.objectWorldMatrix;y.oneMinus;y.or;y.orthographicDepthToViewZ;y.oscSawtooth;y.oscSine;y.oscSquare;y.oscTriangle;y.output;y.outputStruct;y.overlay;y.overloadingFn;y.parabola;y.parallaxDirection;y.parallaxUV;y.parameter;y.pass;y.passTexture;y.pcurve;y.perspectiveDepthToViewZ;y.pmremTexture;y.pointUV;y.pointWidth;y.positionGeometry;y.positionLocal;y.positionPrevious;y.positionView;y.positionViewDirection;y.positionWorld;y.positionWorldDirection;y.posterize;y.pow;y.pow2;y.pow3;y.pow4;y.premult;y.property;y.radians;y.rand;y.range;y.rangeFog;y.rangeFogFactor;y.reciprocal;y.lightProjectionUV;y.reference;y.referenceBuffer;y.reflect;y.reflectVector;y.reflectView;y.reflector;y.refract;y.refractVector;y.refractView;y.reinhardToneMapping;y.remainder;y.remap;y.remapClamp;y.renderGroup;y.renderOutput;y.rendererReference;y.rotate;y.rotateUV;y.roughness;y.round;y.rtt;y.sRGBTransferEOTF;y.sRGBTransferOETF;y.sampler;y.samplerComparison;y.saturate;y.saturation;y.screen;y.screenCoordinate;y.screenSize;y.screenUV;y.scriptable;y.scriptableValue;y.select;y.setCurrentStack;y.shaderStages;y.shadow;y.pointShadow;y.shadowPositionWorld;y.sharedUniformGroup;y.shapeCircle;y.sheen;y.sheenRoughness;y.shiftLeft;y.shiftRight;y.shininess;y.sign;y.sin;y.sinc;y.skinning;y.smoothstep;y.smoothstepElement;y.specularColor;y.specularF90;y.spherizeUV;y.split;y.spritesheetUV;y.sqrt;y.stack;y.step;y.storage;y.storageBarrier;y.storageObject;y.storageTexture;y.string;y.struct;y.sub;y.subgroupIndex;y.subgroupSize;y.tan;y.tangentGeometry;y.tangentLocal;y.tangentView;y.tangentWorld;y.temp;y.texture;y.texture3D;y.textureBarrier;y.textureBicubic;y.textureCubeUV;y.textureLoad;y.textureSize;y.textureStore;y.thickness;y.time;y.timerDelta;y.timerGlobal;y.timerLocal;y.toneMapping;y.toneMappingExposure;y.toonOutlinePass;y.transformDirection;y.transformNormal;y.transformNormalToView;y.transformedBentNormalView;y.transformedBitangentView;y.transformedBitangentWorld;y.transformedClearcoatNormalView;y.transformedNormalView;y.transformedNormalWorld;y.transformedTangentView;y.transformedTangentWorld;y.transmission;y.transpose;y.triNoise3D;y.triplanarTexture;y.triplanarTextures;y.trunc;y.tslFn;y.uint;y.uniform;y.uniformCubeTexture;y.uniformArray;y.uniformGroup;y.uniformTexture;y.uniforms;y.unpremult;y.userData;y.uv;y.uvec2;y.uvec3;y.uvec4;y.Var;y.varying;y.varyingProperty;y.vec2;y.vec3;const ytt=y.vec4;y.vectorComponents;y.velocity;y.vertexColor;y.vertexIndex;y.vibrance;y.viewZToLogarithmicDepth;y.viewZToOrthographicDepth;y.viewZToPerspectiveDepth;y.viewport;y.viewportBottomLeft;y.viewportCoordinate;y.viewportDepthTexture;y.viewportLinearDepth;y.viewportMipTexture;y.viewportResolution;y.viewportSafeUV;y.viewportSharedTexture;y.viewportSize;y.viewportTexture;y.viewportTopLeft;y.viewportUV;y.wgsl;y.wgslFn;y.workgroupArray;y.workgroupBarrier;y.workgroupId;y.workingToColorSpace;y.xor;const xe=J.createContext(null),xtt=({children:r,hideNotice:t=!1,style:e={},className:s="",...i})=>{const n=J.useRef(null),a=J.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=J.useRef(null);o.current===null&&(o.current=Ms.shaderRenderer());const l=J.useMemo(()=>(f,x,b,w,S=null)=>{if(x===null){try{o.current.removeNode(f)}catch(_){console.warn("Error removing node:",_)}return}try{o.current.registerNode(f,x,b,w,S)}catch(_){console.error("Error registering node:",_,{id:f,parentId:b,metadata:w})}},[]),h=J.useMemo(()=>(f,x,b)=>{try{o.current.updateUniformValue(f,x,b)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=J.useMemo(()=>(f,x)=>{try{o.current.updateNodeMetadata(f,x)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=J.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=J.useRef(!1),p=J.useRef(!1);J.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const x=o.current;return x.initialize({canvas:f}).then(()=>{x.registerNode(a,({childNode:b})=>b||ytt(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,t||x.showLicenseWarning()}).catch(b=>{console.error("[Ombre] Initialization failed:",b),p.current=!1}),()=>{try{x.cleanup(),d.current=!1,p.current=!1,console.log("[Ombre] Renderer cleaned up successfully")}catch(b){console.warn("[Ombre] Error during cleanup:",b)}}},[a,t]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof e=="object"?e:{}};return Vr.jsx(xe.Provider,{value:c,children:Vr.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof e=="object"?e:{}},className:s,...i,children:[Vr.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),r]})})};function btt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const rA={blendMode:"normal",opacity:1};try{ul&&ul.props&&Object.entries(ul.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(rA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const vtt=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${ul.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>btt(r,rA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(ul,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,ul.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},ad=new WeakMap,gl={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:r,childNode:t,onCleanup:e,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,uv:d,uniform:p}=rs;if(!t)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(t),f=p(1),x=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};x();let b=ad.get(s);b||(b=new ResizeObserver(Vt=>{let Yt=Vt[0];if(!Yt)return;let{width:se,height:te}=Yt.contentRect,ft=window.devicePixelRatio||1;m.setSize(se*ft,te*ft),x()}),b.observe(s),ad.set(s,b)),e(()=>{let Vt=ad.get(s);Vt&&(Vt.disconnect(),ad.delete(s))});let w=d(),S=r.intensity.uniform,_=r.tileCount.uniform,V=i(f.greaterThanEqual(1).select(o(_,f),_),f.lessThan(1).select(l(_,f),_)),z=l(a(o(w,V)),V),A=h(w,z),I=i(.5,.5),et=o(S,.025),nt=l(A,l(i(1),V)),it=h(nt,I),vt=o(it,et),mt=u(A,vt),Rt=u(mt,z);return n(m.sample(Rt))}};function wtt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const sA={blendMode:"normal",opacity:1};try{gl&&gl.props&&Object.entries(gl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(sA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Mtt=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${gl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>wtt(r,sA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(gl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,gl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},od={VERTEX:"vertex"},Rn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$h=["x","y","z","w"],gr="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 Fv=1234567;const iA=Math.PI/180,nA=180/Math.PI;function Td(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(gr[r&255]+gr[r>>8&255]+gr[r>>16&255]+gr[r>>24&255]+"-"+gr[t&255]+gr[t>>8&255]+"-"+gr[t>>16&15|64]+gr[t>>24&255]+"-"+gr[e&63|128]+gr[e>>8&255]+"-"+gr[e>>16&255]+gr[e>>24&255]+gr[s&255]+gr[s>>8&255]+gr[s>>16&255]+gr[s>>24&255]).toLowerCase()}function kt(r,t,e){return Math.max(t,Math.min(e,r))}function Q0(r,t){return(r%t+t)%t}function Ttt(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function Ntt(r,t,e){return r===t?0:(e-r)/(t-r)}function Bu(r,t,e){return(1-e)*r+e*t}function Stt(r,t,e,s){return Bu(r,t,1-Math.exp(-e*s))}function _tt(r,t=1){return t-Math.abs(Q0(r,t*2)-t)}function Att(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function ztt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Ctt(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Ett(r,t){return r+Math.random()*(t-r)}function Vtt(r){return r*(.5-Math.random())}function Rtt(r){r!==void 0&&(Fv=r);let t=Fv+=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 Ltt(r){return r*iA}function Itt(r){return r*nA}function Ptt(r){return(r&r-1)==0&&r!==0}function Ftt(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function Ott(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function Btt(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Gs(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Ht(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const ktt={DEG2RAD:iA,RAD2DEG:nA,generateUUID:Td,clamp:kt,euclideanModulo:Q0,mapLinear:Ttt,inverseLerp:Ntt,lerp:Bu,damp:Stt,pingpong:_tt,smoothstep:Att,smootherstep:ztt,randInt:Ctt,randFloat:Ett,randFloatSpread:Vtt,seededRandom:Rtt,degToRad:Ltt,radToDeg:Itt,isPowerOfTwo:Ptt,ceilPowerOfTwo:Ftt,floorPowerOfTwo:Ott,setQuaternionFromProperEuler:Btt,normalize:Ht,denormalize:Gs},Vg=0,Dtt=1015,Rg="",Us="srgb",Ov="srgb-linear",Bv="linear",ku="srgb",ap=35044,Ca=2e3,Lg=2001;var jh=class aA{constructor(t,e,s,i,n,a,o,l,h){aA.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],V=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*V,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*V,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*V,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Ff.makeScale(t,e)),this}rotate(t){return this.premultiply(Ff.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ff.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Ff=new jh,kv={};function Dv(r){r in kv||(kv[r]=!0,console.warn(r))}const Uv=new jh().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$v=new jh().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Utt(){let r={enabled:!0,workingColorSpace:Ov,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===ku&&(i.r=yl(i.r),i.g=yl(i.g),i.b=yl(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ku&&(i.r=xl(i.r),i.g=xl(i.g),i.b=xl(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Rg?Bv:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return Dv("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return Dv("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[Ov]:{primaries:t,whitePoint:s,transfer:Bv,toXYZ:Uv,fromXYZ:$v,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Us},outputColorSpaceConfig:{drawingBufferColorSpace:Us}},[Us]:{primaries:t,whitePoint:s,transfer:ku,toXYZ:Uv,fromXYZ:$v,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Us}}}),r}const Oe=Utt();function yl(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function xl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}const oA={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},zn={h:0,s:0,l:0},ld={h:0,s:0,l:0};function Of(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var K0=class{constructor(r,t,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,t,e)}set(r,t,e){if(t===void 0&&e===void 0){let s=r;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(r,t,e);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,t=Us){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,Oe.colorSpaceToWorking(this,t),this}setRGB(r,t,e,s=Oe.workingColorSpace){return this.r=r,this.g=t,this.b=e,Oe.colorSpaceToWorking(this,s),this}setHSL(r,t,e,s=Oe.workingColorSpace){if(r=Q0(r,1),t=kt(t,0,1),e=kt(e,0,1),t===0)this.r=this.g=this.b=e;else{let i=e<=.5?e*(1+t):e+t-e*t,n=2*e-i;this.r=Of(n,i,r+1/3),this.g=Of(n,i,r),this.b=Of(n,i,r-1/3)}return Oe.colorSpaceToWorking(this,s),this}setStyle(r,t=Us){function e(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+r+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(r)){let i,n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(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(a))return e(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(a))return e(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 "+r)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(r)){let i=s[1],n=i.length;if(n===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(n===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,t);return this}setColorName(r,t=Us){let e=oA[r.toLowerCase()];return e===void 0?console.warn("THREE.Color: Unknown color "+r):this.setHex(e,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=yl(r.r),this.g=yl(r.g),this.b=yl(r.b),this}copyLinearToSRGB(r){return this.r=xl(r.r),this.g=xl(r.g),this.b=xl(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=Us){return Oe.workingToColorSpace(yr.copy(this),r),Math.round(kt(yr.r*255,0,255))*65536+Math.round(kt(yr.g*255,0,255))*256+Math.round(kt(yr.b*255,0,255))}getHexString(r=Us){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,t=Oe.workingColorSpace){Oe.workingToColorSpace(yr.copy(this),t);let e=yr.r,s=yr.g,i=yr.b,n=Math.max(e,s,i),a=Math.min(e,s,i),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case e:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-e)/u+2;break;case i:o=(e-s)/u+4;break}o/=6}return r.h=o,r.s=l,r.l=h,r}getRGB(r,t=Oe.workingColorSpace){return Oe.workingToColorSpace(yr.copy(this),t),r.r=yr.r,r.g=yr.g,r.b=yr.b,r}getStyle(r=Us){Oe.workingToColorSpace(yr.copy(this),r);let t=yr.r,e=yr.g,s=yr.b;return r===Us?`rgb(${Math.round(t*255)},${Math.round(e*255)},${Math.round(s*255)})`:`color(${r} ${t.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(r,t,e){return this.getHSL(zn),this.setHSL(zn.h+r,zn.s+t,zn.l+e)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,t){return this.r=r.r+t.r,this.g=r.g+t.g,this.b=r.b+t.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,t){return this.r+=(r.r-this.r)*t,this.g+=(r.g-this.g)*t,this.b+=(r.b-this.b)*t,this}lerpColors(r,t,e){return this.r=r.r+(t.r-r.r)*e,this.g=r.g+(t.g-r.g)*e,this.b=r.b+(t.b-r.b)*e,this}lerpHSL(r,t){this.getHSL(zn),r.getHSL(ld);let e=Bu(zn.h,ld.h,t),s=Bu(zn.s,ld.s,t),i=Bu(zn.l,ld.l,t);return this.setHSL(e,s,i),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){let t=this.r,e=this.g,s=this.b,i=r.elements;return this.r=i[0]*t+i[3]*e+i[6]*s,this.g=i[1]*t+i[4]*e+i[7]*s,this.b=i[2]*t+i[5]*e+i[8]*s,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,t=0){return this.r=r[t],this.g=r[t+1],this.b=r[t+2],this}toArray(r=[],t=0){return r[t]=this.r,r[t+1]=this.g,r[t+2]=this.b,r}fromBufferAttribute(r,t){return this.r=r.getX(t),this.g=r.getY(t),this.b=r.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const yr=new K0;K0.NAMES=oA;var $tt=class lA{constructor(t,e,s,i){lA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}},jtt=class{constructor(r=0,t=0,e=0,s=1){this.isQuaternion=!0,this._x=r,this._y=t,this._z=e,this._w=s}static slerpFlat(r,t,e,s,i,n,a){let o=e[s+0],l=e[s+1],h=e[s+2],u=e[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){r[t+0]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u;return}if(a===1){r[t+0]=c,r[t+1]=d,r[t+2]=p,r[t+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,x=o*c+l*d+h*p+u*m,b=x>=0?1:-1,w=1-x*x;if(w>2**-52){let _=Math.sqrt(w),V=Math.atan2(_,x*b);f=Math.sin(f*V)/_,a=Math.sin(a*V)/_}let S=a*b;if(o=o*f+c*S,l=l*f+d*S,h=h*f+p*S,u=u*f+m*S,f===1-a){let _=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=_,l*=_,h*=_,u*=_}}r[t]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u}static multiplyQuaternionsFlat(r,t,e,s,i,n){let a=e[s],o=e[s+1],l=e[s+2],h=e[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return r[t]=a*p+h*u+o*d-l*c,r[t+1]=o*p+h*c+l*u-a*d,r[t+2]=l*p+h*d+a*c-o*u,r[t+3]=h*p-a*u-o*c-l*d,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,t,e,s){return this._x=r,this._y=t,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,t=!0){let e=r._x,s=r._y,i=r._z,n=r._order,a=Math.cos,o=Math.sin,l=a(e/2),h=a(s/2),u=a(i/2),c=o(e/2),d=o(s/2),p=o(i/2);switch(n){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,t){let e=t/2,s=Math.sin(e);return this._x=r.x*s,this._y=r.y*s,this._z=r.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(r){let t=r.elements,e=t[0],s=t[4],i=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],c=e+a+u;if(c>0){let d=.5/Math.sqrt(c+1);this._w=.25/d,this._x=(h-o)*d,this._y=(i-l)*d,this._z=(n-s)*d}else if(e>a&&e>u){let d=2*Math.sqrt(1+e-a-u);this._w=(h-o)/d,this._x=.25*d,this._y=(s+n)/d,this._z=(i+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-e-u);this._w=(i-l)/d,this._x=(s+n)/d,this._y=.25*d,this._z=(o+h)/d}else{let d=2*Math.sqrt(1+u-e-a);this._w=(n-s)/d,this._x=(i+l)/d,this._y=(o+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(r,t){let e=r.dot(t)+1;return e<2**-52?(e=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=e):(this._x=0,this._y=-r.z,this._z=r.y,this._w=e)):(this._x=r.y*t.z-r.z*t.y,this._y=r.z*t.x-r.x*t.z,this._z=r.x*t.y-r.y*t.x,this._w=e),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(kt(this.dot(r),-1,1)))}rotateTowards(r,t){let e=this.angleTo(r);if(e===0)return this;let s=Math.min(1,t/e);return this.slerp(r,s),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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x*=r,this._y*=r,this._z*=r,this._w*=r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,t){let e=r._x,s=r._y,i=r._z,n=r._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=e*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-e*l,this._z=i*h+n*l+e*o-s*a,this._w=n*h-e*a-s*o-i*l,this._onChangeCallback(),this}slerp(r,t){if(t===0)return this;if(t===1)return this.copy(r);let e=this._x,s=this._y,i=this._z,n=this._w,a=n*r._w+e*r._x+s*r._y+i*r._z;if(a<0?(this._w=-r._w,this._x=-r._x,this._y=-r._y,this._z=-r._z,a=-a):this.copy(r),a>=1)return this._w=n,this._x=e,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-t;return this._w=d*n+t*this._w,this._x=d*e+t*this._x,this._y=d*s+t*this._y,this._z=d*i+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(r,t,e){return this.copy(r).slerp(t,e)}random(){let r=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(r),s*Math.cos(r),i*Math.sin(t),i*Math.cos(t))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,t=0){return this._x=r[t],this._y=r[t+1],this._z=r[t+2],this._w=r[t+3],this._onChangeCallback(),this}toArray(r=[],t=0){return r[t]=this._x,r[t+1]=this._y,r[t+2]=this._z,r[t+3]=this._w,r}fromBufferAttribute(r,t){return this._x=r.getX(t),this._y=r.getY(t),this._z=r.getZ(t),this._w=r.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ti=class uA{constructor(t=0,e=0,s=0){uA.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(jv.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(jv.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Bf.copy(this).projectOnVector(t),this.sub(Bf)}reflect(t){return this.sub(Bf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Bf=new ti,jv=new jtt;var hA=class Ig{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Ig.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,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ig().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/Wo.setFromMatrixColumn(t,0).length(),n=1/Wo.setFromMatrixColumn(t,1).length(),a=1/Wo.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Wtt,t,qtt)}lookAt(t,e,s){let i=this.elements;return Wr.subVectors(t,e),Wr.lengthSq()===0&&(Wr.z=1),Wr.normalize(),Cn.crossVectors(s,Wr),Cn.lengthSq()===0&&(Math.abs(s.z)===1?Wr.x+=1e-4:Wr.z+=1e-4,Wr.normalize(),Cn.crossVectors(s,Wr)),Cn.normalize(),ud.crossVectors(Wr,Cn),i[0]=Cn.x,i[4]=ud.x,i[8]=Wr.x,i[1]=Cn.y,i[5]=ud.y,i[9]=Wr.y,i[2]=Cn.z,i[6]=ud.z,i[10]=Wr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],V=s[15],z=i[0],A=i[4],I=i[8],et=i[12],nt=i[1],it=i[5],vt=i[9],mt=i[13],Rt=i[2],Vt=i[6],Yt=i[10],se=i[14],te=i[3],ft=i[7],bt=i[11],Et=i[15];return n[0]=a*z+o*nt+l*Rt+h*te,n[4]=a*A+o*it+l*Vt+h*ft,n[8]=a*I+o*vt+l*Yt+h*bt,n[12]=a*et+o*mt+l*se+h*Et,n[1]=u*z+c*nt+d*Rt+p*te,n[5]=u*A+c*it+d*Vt+p*ft,n[9]=u*I+c*vt+d*Yt+p*bt,n[13]=u*et+c*mt+d*se+p*Et,n[2]=m*z+f*nt+x*Rt+b*te,n[6]=m*A+f*it+x*Vt+b*ft,n[10]=m*I+f*vt+x*Yt+b*bt,n[14]=m*et+f*mt+x*se+b*Et,n[3]=w*z+S*nt+_*Rt+V*te,n[7]=w*A+S*it+_*Vt+V*ft,n[11]=w*I+S*vt+_*Yt+V*bt,n[15]=w*et+S*mt+_*se+V*Et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,V=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*V;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=V*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,V=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*V,i[1]=(p+_)*V,i[2]=(m-S)*V,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=Wo.set(i[0],i[1],i[2]).length(),a=Wo.set(i[4],i[5],i[6]).length(),o=Wo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Ps.copy(this);let h=1/n,u=1/a,c=1/o;return Ps.elements[0]*=h,Ps.elements[1]*=h,Ps.elements[2]*=h,Ps.elements[4]*=u,Ps.elements[5]*=u,Ps.elements[6]*=u,Ps.elements[8]*=c,Ps.elements[9]*=c,Ps.elements[10]*=c,e.setFromRotationMatrix(Ps),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Ca){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===Ca)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Lg)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,s,i,n,a,o=Ca){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===Ca)m=(a+n)*c,f=-2*c;else if(o===Lg)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const Wo=new ti,Ps=new hA,Wtt=new ti(0,0,0),qtt=new ti(1,1,1),Cn=new ti,ud=new ti,Wr=new ti;var cA=class dA{constructor(t=0,e=0){dA.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Htt=class pA{constructor(t=0,e=0,s=0,i=1){pA.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,V=(b+1)/2,z=(u+d)/4,A=(c+f)/4,I=(m+x)/4;return S>_&&S>V?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>V?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=I/i):V<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(V),s=A/n,i=I/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this.w=kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this.w=kt(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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 Pg(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const mA=(...r)=>Pg(r);function Gtt(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of Fg(r))e.push(Pg(s.slice(0,-4)),i.getCacheKey(t));return Pg(e)}function*Fg(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function Og(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function fA(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new K0(...t):e==="vec2"?new cA(...t):e==="vec3"?new ti(...t):e==="vec4"?new Htt(...t):e==="mat2"?new $tt(...t):e==="mat3"?new jh(...t):e==="mat4"?new hA(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Ytt(t[0]):null}function Xtt(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Ytt(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}var Ztt=class{addEventListener(r,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[r]===void 0&&(e[r]=[]),e[r].indexOf(t)===-1&&e[r].push(t)}hasEventListener(r,t){let e=this._listeners;return e===void 0?!1:e[r]!==void 0&&e[r].indexOf(t)!==-1}removeEventListener(r,t){let e=this._listeners;if(e===void 0)return;let s=e[r];if(s!==void 0){let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(r){let t=this._listeners;if(t===void 0)return;let e=t[r.type];if(e!==void 0){r.target=this;let s=e.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,r);r.target=null}}};const Jtt={analyze:"setup",generate:"analyze"};let Qtt=0;var Ktt=class extends Ztt{static get type(){return"Node"}constructor(r=null){super(),this.nodeType=r,this.updateType=Rn.NONE,this.updateBeforeType=Rn.NONE,this.updateAfterType=Rn.NONE,this.uuid=ktt.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Qtt++})}set needsUpdate(r){r===!0&&this.version++}get type(){return this.constructor.type}onUpdate(r,t){return this.updateType=t,this.update=r.bind(this.getSelf()),this}onFrameUpdate(r){return this.onUpdate(r,Rn.FRAME)}onRenderUpdate(r){return this.onUpdate(r,Rn.RENDER)}onObjectUpdate(r){return this.onUpdate(r,Rn.OBJECT)}onReference(r){return this.updateReference=r.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:r}of Fg(this))yield r}dispose(){this.dispatchEvent({type:"dispose"})}traverse(r){r(this);for(let t of this.getChildren())t.traverse(r)}getCacheKey(r=!1){return r||(r=this.version!==this._cacheKeyVersion),(r===!0||this._cacheKey===null)&&(this._cacheKey=mA(Gtt(this,r),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(r){let t=this.getNodeType(r);return r.getElementType(t)}getMemberType(){return"void"}getNodeType(r){let t=r.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(r):this.nodeType}getShared(r){let t=this.getHash(r);return r.getNodeFromHash(t)||this}setup(r){let t=r.getNodeProperties(this),e=0;for(let s of this.getChildren())t["node"+e++]=s;return t.outputNode||null}analyze(r,t=null){let e=r.increaseUsage(this);if(this.parents===!0){let s=r.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[r.shaderStage]=s.stages[r.shaderStage]||[],s.stages[r.shaderStage].push(t)}if(e===1){let s=r.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(r,this)}}generate(r,t){let{outputNode:e}=r.getNodeProperties(this);if(e&&e.isNode===!0)return e.build(r,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(r,t=null){let e=this.getShared(r);if(this!==e)return e.build(r,t);let s=r.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[r.buildStage]=!0;let i=Jtt[r.buildStage];if(i&&s.buildStages[i]!==!0){let o=r.getBuildStage();r.setBuildStage(i),this.build(r),r.setBuildStage(o)}r.addNode(this),r.addChain(this);let n=null,a=r.getBuildStage();if(a==="setup"){this.updateReference(r);let o=r.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(r)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=r.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(r)}}n=o.outputNode}else if(a==="analyze")this.analyze(r,t);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(r),h=r.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(r)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&r.context.nodeBlock!==void 0&&r.addFlowCodeHierarchy(this,r.context.nodeBlock),n=r.format(n,l,t)}else n=this.generate(r,t)||"";return r.removeChain(this),r.addSequentialNode(this),n}getSerializeChildren(){return Fg(this)}serialize(r){let t=this.getSerializeChildren(),e={};for(let{property:s,index:i,childNode:n}of t)i===void 0?e[s]=n.toJSON(r.meta).uuid:(e[s]===void 0&&(e[s]=Number.isInteger(i)?[]:{}),e[s][i]=n.toJSON(r.meta).uuid);Object.keys(e).length>0&&(r.inputNodes=e)}deserialize(r){if(r.inputNodes!==void 0){let t=r.meta.nodes;for(let e in r.inputNodes)if(Array.isArray(r.inputNodes[e])){let s=[];for(let i of r.inputNodes[e])s.push(t[i]);this[e]=s}else if(typeof r.inputNodes[e]=="object"){let s={};for(let i in r.inputNodes[e]){let n=r.inputNodes[e][i];s[i]=t[n]}this[e]=s}else{let s=r.inputNodes[e];this[e]=t[s]}}}toJSON(r){let{uuid:t,type:e}=this,s=r===void 0||typeof r=="string";s&&(r={textures:{},images:{},nodes:{}});let i=r.nodes[t];i===void 0&&(i={uuid:t,type:e,meta:r,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(r.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s){let a=n(r.textures),o=n(r.images),l=n(r.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},$e=Ktt,tet=class extends $e{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},ss=tet,eet=class extends $e{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},tx=eet,ret=class extends $e{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},gA=ret,set=class extends ss{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}},iet=set;const net=$h.join("");var aet=class extends $e{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max($h.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===net.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},Wv=aet,oet=class extends ss{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=$h[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},uet=oet,het=class extends ss{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=$h[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},cet=het,det=class extends $e{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?Og(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=Og(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=Xtt(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?fA(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}},ex=det;const qv=/float|u?int/;var pet=class extends ex{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return qv.test(e)&&qv.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},mn=pet,met=class extends $e{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}},fet=met;let get=null;const rl=new Map;function j(r,t){if(rl.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);rl.set(r,t)}const yA=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Hv=r=>yA(r).split("").sort().join(""),xA={setup(r,t){let e=t.shift();return r(Zp(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(get.assign(e,...s),e);if(rl.has(t)){let s=rl.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&rl.has(t.slice(0,t.length-6))){let s=rl.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=yA(t),ht(new Wv(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Hv(t.slice(3).toLowerCase()),s=>ht(new uet(r,t,ht(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Hv(t.slice(4).toLowerCase()),()=>ht(new cet(ht(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),ht(new Wv(r,t));if(/^\d+$/.test(t)===!0)return ht(new tx(e,new mn(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>ht(new fet(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},kf=new WeakMap,Gv=new WeakMap,yet=function(r,t=null){let e=Og(r);if(e==="node"){let s=kf.get(r);return s===void 0&&(s=new Proxy(r,xA),kf.set(r,s),kf.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return ht(Bg(r,t));if(e==="shader")return As(r)}return r},xet=function(r,t=null){for(let e in r)r[e]=ht(r[e],t);return r},bet=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=ht(r[s],t);return r},vet=function(r,t=null,e=null,s=null){let i=u=>ht(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return t===null?n=(...u)=>i(new r(...Nd(h(u)))):e===null?n=(...u)=>i(new r(t,...Nd(h(u)))):(e=ht(e),n=(...u)=>i(new r(t,...Nd(h(u)),e))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var wet=class extends $e{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=Gv.get(r.constructor);a===void 0&&(a=new WeakMap,Gv.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=ht(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=ht(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=ht(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},Met=class extends $e{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return Zp(r),ht(new wet(this,r))}setup(){return this.call()}};const Tet=[!1,!0],Net=[0,1,2,3],_et=[-1,-2],bA=[.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],rx=new Map;for(let r of Tet)rx.set(r,new mn(r));const sx=new Map;for(let r of Net)sx.set(r,new mn(r,"uint"));const ix=new Map([...sx].map(r=>new mn(r.value,"int")));for(let r of _et)ix.set(r,new mn(r,"int"));const Xp=new Map([...ix].map(r=>new mn(r.value)));for(let r of bA)Xp.set(r,new mn(r));for(let r of bA)Xp.set(-r,new mn(-r));const Yp={bool:rx,uint:sx,ints:ix,float:Xp},Xv=new Map([...rx,...Xp]),Bg=(r,t)=>Xv.has(r)?Xv.get(r):r.isNode===!0?r:new mn(r,t),Aet=r=>{try{return r.getNodeType()}catch{return}},je=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[fA(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return ht(t.get(e[0]));if(e.length===1){let i=Bg(e[0],r);return Aet(i)===r?ht(i):ht(new gA(i,r))}let s=e.map(i=>Bg(i));return ht(new iet(s,r))}},zet=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Cet(r,t){return new Proxy(new Met(r,t),xA)}const ht=(r,t=null)=>yet(r,t),Zp=(r,t=null)=>new xet(r,t),Nd=(r,t=null)=>new bet(r,t),tt=(...r)=>new vet(...r);let Eet=0;const As=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Cet(r,e),i=(...n)=>{let a;Zp(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+Eet++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i};function Vet(r){return r}j("toStack",Vet);const Ret=new je("color"),Mi=new je("float",Yp.float),sh=new je("int",Yp.ints),Let=new je("uint",Yp.uint),Iet=new je("bool",Yp.bool),vA=new je("vec2"),Pet=new je("ivec2"),Fet=new je("uvec2"),Oet=new je("bvec2"),Fl=new je("vec3"),Bet=new je("ivec3"),ket=new je("uvec3"),Det=new je("bvec3"),ka=new je("vec4"),Uet=new je("ivec4"),$et=new je("uvec4"),jet=new je("bvec4"),Wet=new je("mat2"),wA=new je("mat3"),qet=new je("mat4");j("toColor",Ret),j("toFloat",Mi),j("toInt",sh),j("toUint",Let),j("toBool",Iet),j("toVec2",vA),j("toIVec2",Pet),j("toUVec2",Fet),j("toBVec2",Oet),j("toVec3",Fl),j("toIVec3",Bet),j("toUVec3",ket),j("toBVec3",Det),j("toVec4",ka),j("toIVec4",Uet),j("toUVec4",$et),j("toBVec4",jet),j("toMat2",Wet),j("toMat3",wA),j("toMat4",qet);const Het=tt(tx).setParameterLength(2),Get=(r,t)=>ht(new gA(ht(r),t));j("element",Het),j("convert",Get),j("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),r));const Xet={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Le=class kg extends ss{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new kg(t,e,s);for(let a=0;a<i.length-1;a++)n=new kg(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(Xet[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===Ca;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const MA=tt(Le,"+").setParameterLength(2,1/0).setName("add"),Dg=tt(Le,"-").setParameterLength(2,1/0).setName("sub"),nx=tt(Le,"*").setParameterLength(2,1/0).setName("mul"),TA=tt(Le,"/").setParameterLength(2,1/0).setName("div"),Jp=tt(Le,"%").setParameterLength(2).setName("mod"),NA=tt(Le,"==").setParameterLength(2).setName("equal"),Yet=tt(Le,"!=").setParameterLength(2).setName("notEqual"),Zet=tt(Le,"<").setParameterLength(2).setName("lessThan"),Jet=tt(Le,">").setParameterLength(2).setName("greaterThan"),Qet=tt(Le,"<=").setParameterLength(2).setName("lessThanEqual"),Ket=tt(Le,">=").setParameterLength(2).setName("greaterThanEqual"),trt=tt(Le,"&&").setParameterLength(2,1/0).setName("and"),ert=tt(Le,"||").setParameterLength(2,1/0).setName("or"),rrt=tt(Le,"!").setParameterLength(1).setName("not"),srt=tt(Le,"^^").setParameterLength(2).setName("xor"),irt=tt(Le,"&").setParameterLength(2).setName("bitAnd"),nrt=tt(Le,"~").setParameterLength(2).setName("bitNot"),art=tt(Le,"|").setParameterLength(2).setName("bitOr"),ort=tt(Le,"^").setParameterLength(2).setName("bitXor"),lrt=tt(Le,"<<").setParameterLength(2).setName("shiftLeft"),urt=tt(Le,">>").setParameterLength(2).setName("shiftRight"),hrt=As(([r])=>(r.addAssign(1),r)),crt=As(([r])=>(r.subAssign(1),r)),drt=As(([r])=>{let t=sh(r).toConst();return r.addAssign(1),t}),prt=As(([r])=>{let t=sh(r).toConst();return r.subAssign(1),t});j("add",MA),j("sub",Dg),j("mul",nx),j("div",TA),j("mod",Jp),j("equal",NA),j("notEqual",Yet),j("lessThan",Zet),j("greaterThan",Jet),j("lessThanEqual",Qet),j("greaterThanEqual",Ket),j("and",trt),j("or",ert),j("not",rrt),j("xor",srt),j("bitAnd",irt),j("bitNot",nrt),j("bitOr",art),j("bitXor",ort),j("shiftLeft",lrt),j("shiftRight",urt),j("incrementBefore",hrt),j("decrementBefore",crt),j("increment",drt),j("decrement",prt);const mrt=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Jp(r,t)),frt=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Jp(sh(r),sh(t)));j("remainder",mrt),j("modInt",frt);var O=class re extends ss{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===re.MAX||t===re.MIN)&&arguments.length>3){let n=new re(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new re(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===re.LENGTH||e===re.DISTANCE||e===re.DOT?"float":e===re.CROSS?"vec3":e===re.ALL||e===re.ANY?"bool":e===re.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===re.ONE_MINUS)n=Dg(1,e);else if(i===re.RECIPROCAL)n=TA(1,e);else if(i===re.DIFFERENCE)n=ax(Dg(e,s));else if(i===re.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=ka(Fl(o),0):a=ka(Fl(a),0);let l=nx(a,o).xyz;n=SA(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===re.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===re.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Ca&&i===re.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Ca&&(i===re.MIN||i===re.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===re.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===re.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===Lg&&i===re.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===re.DFDX||i===re.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};O.ALL="all",O.ANY="any",O.RADIANS="radians",O.DEGREES="degrees",O.EXP="exp",O.EXP2="exp2",O.LOG="log",O.LOG2="log2",O.SQRT="sqrt",O.INVERSE_SQRT="inversesqrt",O.FLOOR="floor",O.CEIL="ceil",O.NORMALIZE="normalize",O.FRACT="fract",O.SIN="sin",O.COS="cos",O.TAN="tan",O.ASIN="asin",O.ACOS="acos",O.ATAN="atan",O.ABS="abs",O.SIGN="sign",O.LENGTH="length",O.NEGATE="negate",O.ONE_MINUS="oneMinus",O.DFDX="dFdx",O.DFDY="dFdy",O.ROUND="round",O.RECIPROCAL="reciprocal",O.TRUNC="trunc",O.FWIDTH="fwidth",O.TRANSPOSE="transpose",O.BITCAST="bitcast",O.EQUALS="equals",O.MIN="min",O.MAX="max",O.STEP="step",O.REFLECT="reflect",O.DISTANCE="distance",O.DIFFERENCE="difference",O.DOT="dot",O.CROSS="cross",O.POW="pow",O.TRANSFORM_DIRECTION="transformDirection",O.MIX="mix",O.CLAMP="clamp",O.REFRACT="refract",O.SMOOTHSTEP="smoothstep",O.FACEFORWARD="faceforward";const grt=Mi(Math.PI);Mi(Math.PI*2);const yrt=tt(O,O.ALL).setParameterLength(1),xrt=tt(O,O.ANY).setParameterLength(1),brt=tt(O,O.RADIANS).setParameterLength(1),vrt=tt(O,O.DEGREES).setParameterLength(1),wrt=tt(O,O.EXP).setParameterLength(1),Mrt=tt(O,O.EXP2).setParameterLength(1),Trt=tt(O,O.LOG).setParameterLength(1),Nrt=tt(O,O.LOG2).setParameterLength(1),Srt=tt(O,O.SQRT).setParameterLength(1),_rt=tt(O,O.INVERSE_SQRT).setParameterLength(1),Art=tt(O,O.FLOOR).setParameterLength(1),zrt=tt(O,O.CEIL).setParameterLength(1),SA=tt(O,O.NORMALIZE).setParameterLength(1),_A=tt(O,O.FRACT).setParameterLength(1),AA=tt(O,O.SIN).setParameterLength(1),Crt=tt(O,O.COS).setParameterLength(1),Ert=tt(O,O.TAN).setParameterLength(1),Vrt=tt(O,O.ASIN).setParameterLength(1),Rrt=tt(O,O.ACOS).setParameterLength(1),zA=tt(O,O.ATAN).setParameterLength(1,2),ax=tt(O,O.ABS).setParameterLength(1),CA=tt(O,O.SIGN).setParameterLength(1),Lrt=tt(O,O.LENGTH).setParameterLength(1),Irt=tt(O,O.NEGATE).setParameterLength(1),Prt=tt(O,O.ONE_MINUS).setParameterLength(1),Frt=tt(O,O.DFDX).setParameterLength(1),Ort=tt(O,O.DFDY).setParameterLength(1),Brt=tt(O,O.ROUND).setParameterLength(1),krt=tt(O,O.RECIPROCAL).setParameterLength(1),Drt=tt(O,O.TRUNC).setParameterLength(1),Urt=tt(O,O.FWIDTH).setParameterLength(1),$rt=tt(O,O.TRANSPOSE).setParameterLength(1),jrt=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),NA(r,t)),Wrt=tt(O,O.MIN).setParameterLength(2,1/0),qrt=tt(O,O.MAX).setParameterLength(2,1/0),Hrt=tt(O,O.STEP).setParameterLength(2),Grt=tt(O,O.REFLECT).setParameterLength(2),Xrt=tt(O,O.DISTANCE).setParameterLength(2),Yrt=tt(O,O.DIFFERENCE).setParameterLength(2),Wh=tt(O,O.DOT).setParameterLength(2),Zrt=tt(O,O.CROSS).setParameterLength(2),EA=tt(O,O.POW).setParameterLength(2),Jrt=tt(O,O.POW,2).setParameterLength(1),Qrt=tt(O,O.POW,3).setParameterLength(1),Krt=tt(O,O.POW,4).setParameterLength(1),tst=tt(O,O.TRANSFORM_DIRECTION).setParameterLength(2),est=r=>nx(CA(r),EA(ax(r),1/3)),rst=r=>Wh(r,r),Qp=tt(O,O.MIX).setParameterLength(3),VA=(r,t=0,e=1)=>ht(new O(O.CLAMP,ht(r),ht(t),ht(e))),sst=r=>VA(r),ist=tt(O,O.REFRACT).setParameterLength(3),nst=tt(O,O.SMOOTHSTEP).setParameterLength(3),ast=tt(O,O.FACEFORWARD).setParameterLength(3),ost=As(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=Wh(r.xy,vA(t,e)),n=Jp(i,grt);return _A(AA(n).mul(s))}),lst=(r,t,e)=>Qp(t,e,r),ust=(r,t,e)=>nst(t,e,r),hst=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),zA(r,t));j("all",yrt),j("any",xrt),j("equals",jrt),j("radians",brt),j("degrees",vrt),j("exp",wrt),j("exp2",Mrt),j("log",Trt),j("log2",Nrt),j("sqrt",Srt),j("inverseSqrt",_rt),j("floor",Art),j("ceil",zrt),j("normalize",SA),j("fract",_A),j("sin",AA),j("cos",Crt),j("tan",Ert),j("asin",Vrt),j("acos",Rrt),j("atan",zA),j("abs",ax),j("sign",CA),j("length",Lrt),j("lengthSq",rst),j("negate",Irt),j("oneMinus",Prt),j("dFdx",Frt),j("dFdy",Ort),j("round",Brt),j("reciprocal",krt),j("trunc",Drt),j("fwidth",Urt),j("atan2",hst),j("min",Wrt),j("max",qrt),j("step",Hrt),j("reflect",Grt),j("distance",Xrt),j("dot",Wh),j("cross",Zrt),j("pow",EA),j("pow2",Jrt),j("pow3",Qrt),j("pow4",Krt),j("transformDirection",tst),j("mix",lst),j("clamp",VA),j("refract",ist),j("smoothstep",ust),j("faceForward",ast),j("difference",Yrt),j("saturate",sst),j("cbrt",est),j("transpose",$rt),j("rand",ost);var Yv=class extends ss{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const cst=(...r)=>{let t;if(r.length===1){let e=r[0];t=new Yv(null,e.length,e)}else{let e=r[0],s=r[1];t=new Yv(e,s)}return ht(t)};j("toArray",(r,t)=>cst(Array(t).fill(r)));var RA=class extends $e{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const dst=r=>new RA(r),pst=(r,t=0)=>new RA(r,!0,t),mst=pst("render"),fst=dst("object");var gst=class extends ex{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=fst}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const yst=(r,t)=>{let e=zet(t||r),s=r;return ht(new gst(s,e))};var xst=class extends $e{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const bst=(r,t)=>ht(new xst(r,t));var vst=class extends ss{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return $h.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const wst=tt(vst).setParameterLength(2);j("assign",wst);var Mst=class extends ss{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(Mi(0));for(let o=0;o<i.length;o++)t.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(n(Mi(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const Tst=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Nd(t):Zp(t[0]),ht(new Mst(ht(r),t)));j("call",Tst);var Nst=class extends $e{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?bst(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
151
|
+
${r.tab}if ( ${u} ) {
|
|
152
|
+
|
|
153
|
+
`).addFlowTab();let c=n.build(r,e);if(c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),r.removeFlowTab().addFlowCode(r.tab+" "+c+`
|
|
154
|
+
|
|
155
|
+
`+r.tab+"}"),a!==null){r.addFlowCode(` else {
|
|
156
|
+
|
|
157
|
+
`).addFlowTab();let d=a.build(r,e);d&&(l?d=h+" = "+d+";":(d="return "+d+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),d="// "+d))),r.removeFlowTab().addFlowCode(r.tab+" "+d+`
|
|
158
|
+
|
|
159
|
+
`+r.tab+`}
|
|
160
|
+
|
|
161
|
+
`)}else r.addFlowCode(`
|
|
162
|
+
|
|
163
|
+
`);return r.format(h,e,t)}};const ox=tt(Nst).setParameterLength(2,3);j("select",ox);const Sst=(...r)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),ox(...r));j("cond",Sst);var _st=class extends $e{static get type(){return"ContextNode"}constructor(r,t={}){super(),this.isContextNode=!0,this.node=r,this.value=t}getScope(){return this.node.getScope()}getNodeType(r){return this.node.getNodeType(r)}analyze(r){let t=r.getContext();r.setContext({...r.context,...this.value}),this.node.build(r),r.setContext(t)}setup(r){let t=r.getContext();r.setContext({...r.context,...this.value}),this.node.build(r),r.setContext(t)}generate(r,t){let e=r.getContext();r.setContext({...r.context,...this.value});let s=this.node.build(r,t);return r.setContext(e),s}};const LA=tt(_st).setParameterLength(1,2),Ast=(r,t)=>LA(r,{label:t});j("context",LA),j("label",Ast);var zst=class extends $e{static get type(){return"VarNode"}constructor(r,t=null,e=!1){super(),this.node=r,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=e,this.parents=!0}getMemberType(r,t){return this.node.getMemberType(r,t)}getElementType(r){return this.node.getElementType(r)}getNodeType(r){return this.node.getNodeType(r)}generate(r){let{node:t,name:e,readOnly:s}=this,{renderer:i}=r,n=i.backend.isWebGPUBackend===!0,a=!1,o=!1;s&&(a=r.isDeterministic(t),o=n?s:a);let l=r.getVectorType(this.getNodeType(r)),h=t.build(r,l),u=r.getVarFromNode(this,e,l,void 0,o),c=r.getPropertyName(u),d=c;if(o)if(n)d=a?`const ${c}`:`let ${c}`;else{let p=r.getArrayCount(t);d=`const ${r.getVar(u.type,c,p)}`}return r.addLineFlowCode(`${d} = ${h}`,this),c}};const lx=tt(zst),Cst=(r,t=null)=>lx(r,t).toStack(),Est=(r,t=null)=>lx(r,t,!0).toStack();j("toVar",Cst),j("toConst",Est);const Vst=r=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),lx(r));j("temp",Vst);var Rst=class extends $e{static get type(){return"VaryingNode"}constructor(r,t=null){super(),this.node=r,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(r,t=null){return this.interpolationType=r,this.interpolationSampling=t,this}getHash(r){return this.name||super.getHash(r)}getNodeType(r){return this.node.getNodeType(r)}setupVarying(r){let t=r.getNodeProperties(this),e=t.varying;if(e===void 0){let s=this.name,i=this.getNodeType(r),n=this.interpolationType,a=this.interpolationSampling;t.varying=e=r.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return e.needsInterpolation||(e.needsInterpolation=r.shaderStage==="fragment"),e}setup(r){this.setupVarying(r),r.flowNodeFromShaderStage(od.VERTEX,this.node)}analyze(r){this.setupVarying(r),r.flowNodeFromShaderStage(od.VERTEX,this.node)}generate(r){let t=r.getNodeProperties(this),e=this.setupVarying(r);if(t.propertyName===void 0){let s=this.getNodeType(r),i=r.getPropertyName(e,od.VERTEX);r.flowNodeFromShaderStage(od.VERTEX,this.node,s,i),t.propertyName=i}return r.getPropertyName(e)}};const Du=tt(Rst).setParameterLength(1,2),Lst=r=>Du(r);j("toVarying",Du),j("toVertexStage",Lst),j("varying",(...r)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Du(...r))),j("vertexStage",(...r)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Du(...r)));const Ist=As(([r])=>{let t=r.mul(.9478672986).add(.0521327014).pow(2.4),e=r.mul(.0773993808),s=r.lessThanEqual(.04045);return Qp(t,e,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Pst=As(([r])=>{let t=r.pow(.41666).mul(1.055).sub(.055),e=r.mul(12.92),s=r.lessThanEqual(.0031308);return Qp(t,e,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ux="WorkingColorSpace",Fst="OutputColorSpace";var IA=class extends ss{static get type(){return"ColorSpaceNode"}constructor(r,t,e){super("vec4"),this.colorNode=r,this.source=t,this.target=e}resolveColorSpace(r,t){return t===ux?Oe.workingColorSpace:t===Fst?r.context.outputColorSpace||r.renderer.outputColorSpace:t}setup(r){let{colorNode:t}=this,e=this.resolveColorSpace(r,this.source),s=this.resolveColorSpace(r,this.target),i=t;return Oe.enabled===!1||e===s||!e||!s||(Oe.getTransfer(e)===ku&&(i=ka(Ist(i.rgb),i.a)),Oe.getPrimaries(e)!==Oe.getPrimaries(s)&&(i=ka(wA(Oe._getMatrix(new jh,e,s)).mul(i.rgb),i.a)),Oe.getTransfer(s)===ku&&(i=ka(Pst(i.rgb),i.a))),i}};const Ost=(r,t)=>ht(new IA(ht(r),ux,t)),Bst=(r,t)=>ht(new IA(ht(r),t,ux));j("workingToColorSpace",Ost),j("colorSpaceToWorking",Bst);var kst=class extends tx{static get type(){return"ReferenceElementNode"}constructor(r,t){super(r,t),this.referenceNode=r,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(r){let t=super.generate(r),e=this.referenceNode.getNodeType(),s=this.getNodeType();return r.format(t,e,s)}},Dst=class extends $e{static get type(){return"ReferenceBaseNode"}constructor(r,t,e=null,s=null){super(),this.property=r,this.uniformType=t,this.object=e,this.count=s,this.properties=r.split("."),this.reference=e,this.node=null,this.group=null,this.updateType=Rn.OBJECT}setGroup(r){return this.group=r,this}element(r){return ht(new kst(this,ht(r)))}setNodeType(r){let t=yst(null,r).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(r){return this.node===null&&(this.updateReference(r),this.updateValue()),this.node.getNodeType(r)}getValueFromReference(r=this.reference){let{properties:t}=this,e=r[t[0]];for(let s=1;s<t.length;s++)e=e[t[s]];return e}updateReference(r){return this.reference=this.object===null?r.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let r=this.getValueFromReference();Array.isArray(r)?this.node.array=r:this.node.value=r}},Ust=Dst,$st=class extends Ust{static get type(){return"RendererReferenceNode"}constructor(r,t,e=null){super(r,t,e),this.renderer=e,this.setGroup(mst)}updateReference(r){return this.reference=this.renderer===null?r.renderer:this.renderer,this.reference}};const jst=(r,t,e=null)=>ht(new $st(r,t,e));var Wst=class extends ss{static get type(){return"ToneMappingNode"}constructor(r,t=Hst,e=null){super("vec3"),this.toneMapping=r,this.exposureNode=t,this.colorNode=e}customCacheKey(){return mA(this.toneMapping)}setup(r){let t=this.colorNode||r.context.color,e=this.toneMapping;if(e===Vg)return t;let s=null,i=r.renderer.library.getToneMappingFunction(e);return i===null?(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",e),s=t):s=ka(i(t.rgb,this.exposureNode),t.a),s}};const qst=(r,t,e)=>ht(new Wst(r,ht(t),ht(e))),Hst=jst("toneMappingExposure","float");j("toneMapping",(r,t,e)=>qst(t,e,r));const Fe=new ti,hd=new cA;let Gst=0;var Xst=class{constructor(r,t,e=!1){if(Array.isArray(r))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Gst++}),this.name="",this.array=r,this.itemSize=t,this.count=r===void 0?0:r.length/t,this.normalized=e,this.usage=ap,this.updateRanges=[],this.gpuType=Dtt,this.version=0}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,t){this.updateRanges.push({start:r,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.name=r.name,this.array=new r.array.constructor(r.array),this.itemSize=r.itemSize,this.count=r.count,this.normalized=r.normalized,this.usage=r.usage,this.gpuType=r.gpuType,this}copyAt(r,t,e){r*=this.itemSize,e*=t.itemSize;for(let s=0,i=this.itemSize;s<i;s++)this.array[r+s]=t.array[e+s];return this}copyArray(r){return this.array.set(r),this}applyMatrix3(r){if(this.itemSize===2)for(let t=0,e=this.count;t<e;t++)hd.fromBufferAttribute(this,t),hd.applyMatrix3(r),this.setXY(t,hd.x,hd.y);else if(this.itemSize===3)for(let t=0,e=this.count;t<e;t++)Fe.fromBufferAttribute(this,t),Fe.applyMatrix3(r),this.setXYZ(t,Fe.x,Fe.y,Fe.z);return this}applyMatrix4(r){for(let t=0,e=this.count;t<e;t++)Fe.fromBufferAttribute(this,t),Fe.applyMatrix4(r),this.setXYZ(t,Fe.x,Fe.y,Fe.z);return this}applyNormalMatrix(r){for(let t=0,e=this.count;t<e;t++)Fe.fromBufferAttribute(this,t),Fe.applyNormalMatrix(r),this.setXYZ(t,Fe.x,Fe.y,Fe.z);return this}transformDirection(r){for(let t=0,e=this.count;t<e;t++)Fe.fromBufferAttribute(this,t),Fe.transformDirection(r),this.setXYZ(t,Fe.x,Fe.y,Fe.z);return this}set(r,t=0){return this.array.set(r,t),this}getComponent(r,t){let e=this.array[r*this.itemSize+t];return this.normalized&&(e=Gs(e,this.array)),e}setComponent(r,t,e){return this.normalized&&(e=Ht(e,this.array)),this.array[r*this.itemSize+t]=e,this}getX(r){let t=this.array[r*this.itemSize];return this.normalized&&(t=Gs(t,this.array)),t}setX(r,t){return this.normalized&&(t=Ht(t,this.array)),this.array[r*this.itemSize]=t,this}getY(r){let t=this.array[r*this.itemSize+1];return this.normalized&&(t=Gs(t,this.array)),t}setY(r,t){return this.normalized&&(t=Ht(t,this.array)),this.array[r*this.itemSize+1]=t,this}getZ(r){let t=this.array[r*this.itemSize+2];return this.normalized&&(t=Gs(t,this.array)),t}setZ(r,t){return this.normalized&&(t=Ht(t,this.array)),this.array[r*this.itemSize+2]=t,this}getW(r){let t=this.array[r*this.itemSize+3];return this.normalized&&(t=Gs(t,this.array)),t}setW(r,t){return this.normalized&&(t=Ht(t,this.array)),this.array[r*this.itemSize+3]=t,this}setXY(r,t,e){return r*=this.itemSize,this.normalized&&(t=Ht(t,this.array),e=Ht(e,this.array)),this.array[r+0]=t,this.array[r+1]=e,this}setXYZ(r,t,e,s){return r*=this.itemSize,this.normalized&&(t=Ht(t,this.array),e=Ht(e,this.array),s=Ht(s,this.array)),this.array[r+0]=t,this.array[r+1]=e,this.array[r+2]=s,this}setXYZW(r,t,e,s,i){return r*=this.itemSize,this.normalized&&(t=Ht(t,this.array),e=Ht(e,this.array),s=Ht(s,this.array),i=Ht(i,this.array)),this.array[r+0]=t,this.array[r+1]=e,this.array[r+2]=s,this.array[r+3]=i,this}onUpload(r){return this.onUploadCallback=r,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let r={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(r.name=this.name),this.usage!==ap&&(r.usage=this.usage),r}};const _r=new ti;var Yst=class PA{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)_r.fromBufferAttribute(this,e),_r.applyMatrix4(t),this.setXYZ(e,_r.x,_r.y,_r.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)_r.fromBufferAttribute(this,e),_r.applyNormalMatrix(t),this.setXYZ(e,_r.x,_r.y,_r.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)_r.fromBufferAttribute(this,e),_r.transformDirection(t),this.setXYZ(e,_r.x,_r.y,_r.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Gs(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=Ht(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=Ht(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ht(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ht(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ht(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Gs(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Gs(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Gs(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Gs(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ht(e,this.array),s=Ht(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ht(e,this.array),s=Ht(s,this.array),i=Ht(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ht(e,this.array),s=Ht(s,this.array),i=Ht(i,this.array),n=Ht(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=n,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 s=0;s<this.count;s++){let i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return new Xst(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 PA(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let s=0;s<this.count;s++){let i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Zst=class{constructor(r,t){this.isInterleavedBuffer=!0,this.array=r,this.stride=t,this.count=r===void 0?0:r.length/t,this.usage=ap,this.updateRanges=[],this.version=0,this.uuid=Td()}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,t){this.updateRanges.push({start:r,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.array=new r.array.constructor(r.array),this.count=r.count,this.stride=r.stride,this.usage=r.usage,this}copyAt(r,t,e){r*=this.stride,e*=t.stride;for(let s=0,i=this.stride;s<i;s++)this.array[r+s]=t.array[e+s];return this}set(r,t=0){return this.array.set(r,t),this}clone(r){r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Td()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(r.arrayBuffers[this.array.buffer._uuid]),e=new this.constructor(t,this.stride);return e.setUsage(this.usage),e}onUpload(r){return this.onUploadCallback=r,this}toJSON(r){return r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Td()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.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}}},Jst=class extends ex{static get type(){return"BufferAttributeNode"}constructor(r,t=null,e=0,s=0){super(r,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=e,this.bufferOffset=s,this.usage=ap,this.instanced=!1,this.attribute=null,this.global=!0,r&&r.isBufferAttribute===!0&&(this.attribute=r,this.usage=r.usage,this.instanced=r.isInstancedBufferAttribute)}getHash(r){if(this.bufferStride===0&&this.bufferOffset===0){let t=r.globalCache.getData(this.value);return t===void 0&&(t={node:this},r.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(r){return this.bufferType===null&&(this.bufferType=r.getTypeFromAttribute(this.attribute)),this.bufferType}setup(r){if(this.attribute!==null)return;let t=this.getNodeType(r),e=this.value,s=r.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=e.isInterleavedBuffer===!0?e:new Zst(e,i),o=new Yst(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(r){let t=this.getNodeType(r),e=r.getBufferAttributeFromNode(this,t),s=r.getPropertyName(e),i=null;return r.shaderStage==="vertex"||r.shaderStage==="compute"?(this.name=s,i=s):i=Du(this).build(r,t),i}getInputType(){return"bufferAttribute"}setUsage(r){return this.usage=r,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=r),this}setInstanced(r){return this.instanced=r,this}};const Qst=(r,t=null,e=0,s=0)=>ht(new Jst(r,t,e,s));j("toAttribute",r=>Qst(r.value));var Kst=class extends $e{static get type(){return"ComputeNode"}constructor(r,t,e=[64]){super("void"),this.isComputeNode=!0,this.computeNode=r,this.count=t,this.workgroupSize=e,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Rn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(r){return this.name=r,this}updateDispatchCount(){let{count:r,workgroupSize:t}=this,e=t[0];for(let s=1;s<t.length;s++)e*=t[s];this.dispatchCount=Math.ceil(r/e)}onInit(r){return this.onInitFunction=r,this}updateBefore({renderer:r}){r.compute(this)}setup(r){let t=this.computeNode.build(r);if(t){let e=r.getNodeProperties(this);e.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(r,t){let{shaderStage:e}=r;if(e==="compute"){let s=this.computeNode.build(r,"void");s!==""&&r.addLineFlowCode(s,this)}else{let s=r.getNodeProperties(this),i=s.outputComputeNode;if(i)return i.build(r,t)}}};const tit=(r,t,e)=>ht(new Kst(ht(r),t,e));j("compute",tit);var eit=class extends $e{static get type(){return"CacheNode"}constructor(r,t=!0){super(),this.node=r,this.parent=t,this.isCacheNode=!0}getNodeType(r){let t=r.getCache(),e=r.getCacheFromNode(this,this.parent);r.setCache(e);let s=this.node.getNodeType(r);return r.setCache(t),s}build(r,...t){let e=r.getCache(),s=r.getCacheFromNode(this,this.parent);r.setCache(s);let i=this.node.build(r,...t);return r.setCache(e),i}};const rit=(r,t)=>ht(new eit(ht(r),t));j("cache",rit);var sit=class extends $e{static get type(){return"BypassNode"}constructor(r,t){super(),this.isBypassNode=!0,this.outputNode=r,this.callNode=t}getNodeType(r){return this.outputNode.getNodeType(r)}generate(r){let t=this.callNode.build(r,"void");return t!==""&&r.addLineFlowCode(t,this),this.outputNode.build(r)}};const iit=tt(sit).setParameterLength(2);j("bypass",iit);var FA=class extends $e{static get type(){return"RemapNode"}constructor(r,t,e,s=Mi(0),i=Mi(1)){super(),this.node=r,this.inLowNode=t,this.inHighNode=e,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){let{node:r,inLowNode:t,inHighNode:e,outLowNode:s,outHighNode:i,doClamp:n}=this,a=r.sub(t).div(e.sub(t));return n===!0&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}};const nit=tt(FA,null,null,{doClamp:!1}).setParameterLength(3,5),ait=tt(FA).setParameterLength(3,5);j("remap",nit),j("remapClamp",ait);var oit=class extends $e{static get type(){return"ExpressionNode"}constructor(r="",t="void"){super(t),this.snippet=r}generate(r,t){let e=this.getNodeType(r),s=this.snippet;if(e==="void")r.addLineFlowCode(s,this);else return r.format(s,e,t)}};const Zv=tt(oit).setParameterLength(1,2),lit=r=>(r?ox(r,Zv("discard")):Zv("discard")).toStack();j("discard",lit);var uit=class extends ss{static get type(){return"RenderOutputNode"}constructor(r,t,e){super("vec4"),this.colorNode=r,this.toneMapping=t,this.outputColorSpace=e,this.isRenderOutputNode=!0}setup({context:r}){let t=this.colorNode||r.color,e=(this.toneMapping===null?r.toneMapping:this.toneMapping)||Vg,s=(this.outputColorSpace===null?r.outputColorSpace:this.outputColorSpace)||Rg;return e!==Vg&&(t=t.toneMapping(e)),s!==Rg&&s!==Oe.workingColorSpace&&(t=t.workingToColorSpace(s)),t}};const hit=(r,t=null,e=null)=>ht(new uit(ht(r),t,e));j("renderOutput",hit);var cit=class extends ss{static get type(){return"DebugNode"}constructor(r,t=null){super(),this.node=r,this.callback=t}getNodeType(r){return this.node.getNodeType(r)}setup(r){return this.node.build(r)}analyze(r){return this.node.build(r)}generate(r){let t=this.callback,e=this.node.build(r),s="--- TSL debug - "+r.shaderStage+" shader ---",i="-".repeat(s.length),n="";return n+="// #"+s+`#
|
|
164
|
+
`,n+=r.flow.code.replace(/^\t/gm,"")+`
|
|
165
|
+
`,n+="/* ... */ "+e+` /* ... */
|
|
166
|
+
`,n+="// #"+i+`#
|
|
167
|
+
`,t===null?console.log(n):t(r,n),e}};const dit=(r,t=null)=>ht(new cit(ht(r),t));j("debug",dit);const pit=As(([r])=>OA(r.rgb)),mit=As(([r,t=Mi(1)])=>t.mix(OA(r.rgb),r.rgb)),fit=As(([r,t=Mi(1)])=>{let e=MA(r.r,r.g,r.b).div(3),s=r.r.max(r.g.max(r.b)),i=s.sub(e).mul(t).mul(-3);return Qp(r.rgb,s,i)}),git=As(([r,t=Mi(1)])=>{let e=Fl(.57735,.57735,.57735),s=t.cos();return Fl(r.rgb.mul(s).add(e.cross(r.rgb).mul(t.sin()).add(e.mul(Wh(e,r.rgb).mul(s.oneMinus())))))}),OA=(r,t=Fl(Oe.getLuminanceCoefficients(new ti)))=>Wh(r,t),bl={name:"Grayscale",props:{},fragmentNode:({childNode:r})=>{let{vec4:t}=rs;if(!r)return console.error("You must pass a child component into the Grayscale shader."),t(0);let e=r||t(0,0,0,0);return t(pit(e.rgb).rgb,e.a)}};function yit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const BA={blendMode:"normal",opacity:1};try{bl&&bl.props&&Object.entries(bl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(BA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const xit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${bl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>yit(r,BA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(bl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,bl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},vl={name:"HueShift",props:{shift:{type:Number,default:0,description:"The amount to shift the hue by"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=rs;if(!t)return console.error("You must pass a child component into the Hue Shift shader."),e(0);let s=t||e(0,0,0,0);return e(git(s.rgb,r.shift.uniform).rgb,s.a)}};function bit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const kA={blendMode:"normal",opacity:1};try{vl&&vl.props&&Object.entries(vl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(kA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const vit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>bit(r,kA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(vl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,vl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},wl={name:"Invert",props:{},fragmentNode:({childNode:r})=>{let{vec4:t,vec3:e}=rs;if(!r)return console.error("You must pass a child component into the Invert shader."),t(0);let s=r||t(0,0,0,0);return t(e(1,1,1).sub(s.rgb),s.a)}};function wit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const DA={blendMode:"normal",opacity:1};try{wl&&wl.props&&Object.entries(wl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(DA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Mit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${wl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>wit(r,DA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(wl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,wl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},Ml={name:"LinearGradient",props:{startColor:{type:String,default:"#1aff00",transform:Ju,description:"The starting color of the gradient"},endColor:{type:String,default:"#0000ff",transform:Ju,description:"The ending color of the gradient"},angle:{type:Number,default:0,description:"rotation angle in degrees (0-360, where 0 = left-to-right)"},center:{type:Object,default:{x:.5,y:.5},transform:Ky},autoRotate:{type:Boolean,default:!1,description:"Enable automatic rotation of the gradient"},autoRotateSpeed:{type:Number,default:1,description:"Speed of the automatic rotation in degrees per second"}},fragmentNode:({uniforms:r,onBeforeRender:t})=>{let{vec2:e,mix:s,float:i,cos:n,sin:a,dot:o,radians:l,viewportUV:h,abs:u,div:c,uniform:d}=rs,p=d(0);t(({deltaTime:et})=>{if(r.autoRotate.uniform.value){let nt=r.autoRotateSpeed.uniform.value*et*100;p.value=(p.value+nt)%360}});let m=r.angle.uniform.add(p),f=l(m),x=n(f),b=a(f),w=e(x,b),S=e(r.center.uniform[0],r.center.uniform[1]),_=h.sub(S),V=o(_,w),z=i(.5).mul(u(x).add(u(b))),A=c(V,z.max(1e-6)),I=A.mul(.5).add(.5).clamp(i(0),i(1));return s(r.startColor.uniform,r.endColor.uniform,I)}};function Tit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const UA={blendMode:"normal",opacity:1};try{Ml&&Ml.props&&Object.entries(Ml.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(UA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Nit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${Ml.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Tit(r,UA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(Ml,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Ml.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})};var Sit=class extends ss{static get type(){return"PosterizeNode"}constructor(r,t){super(),this.sourceNode=r,this.stepsNode=t}setup(){let{sourceNode:r,stepsNode:t}=this;return r.mul(t).floor().div(t)}};const _it=tt(Sit).setParameterLength(2),Tl={name:"Posterize",props:{intensity:{type:Number,default:5,description:"The intensity of the posterization effect (lower is more posterized)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e,int:s}=rs;if(!t)return console.error("You must pass a child component into the Posterize shader."),e(0);let i=t||e(0,0,0,0);return _it(i,s(r.intensity.uniform))}};function Ait(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const $A={blendMode:"normal",opacity:1};try{Tl&&Tl.props&&Object.entries(Tl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&($A[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const zit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${Tl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Ait(r,$A),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(Tl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Tl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},Nl={name:"Saturation",props:{intensity:{type:Number,default:1,description:"The intensity of the saturation effect (1 being no change)"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=rs;if(!t)return console.error("You must pass a child component into the Saturation shader."),e(0);let s=t||e(0,0,0,0);return e(mit(s.rgb,r.intensity.uniform).rgb,s.a)}};function Cit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const jA={blendMode:"normal",opacity:1};try{Nl&&Nl.props&&Object.entries(Nl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(jA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Eit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${Nl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Cit(r,jA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(Nl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Nl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},Sl={name:"SolidColor",props:{color:{type:String,default:"#5b18ca",transform:Ju,description:"The solid color to display"}},fragmentNode:({uniforms:r})=>r.color.uniform};function Vit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const WA={blendMode:"normal",opacity:1};try{Sl&&Sl.props&&Object.entries(Sl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(WA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Rit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${Sl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Vit(r,WA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(Sl,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Sl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},_l={name:"Twirl",props:{center:{type:Object,default:{x:.5,y:.5},transform:Ky,description:"The center point of the twirl effect"},intensity:{type:Number,default:1,description:"The strength of the twirl effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec2:e,vec4:s,cos:i,sin:n,length:a,uv:o,convertToTexture:l}=rs;if(!t)return console.error("You must pass a child component into the Twirl shader."),s(0);let h=l(t),u=o(),c=e(r.center.uniform.x,r.center.uniform.y),d=u.sub(c),p=r.intensity.uniform.mul(a(d)),m=i(p),f=n(p),x=m.mul(d.x).sub(f.mul(d.y)),b=f.mul(d.x).add(m.mul(d.y)),w=e(x.add(c.x),b.add(c.y));return s(h.sample(w))}};function Lit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const qA={blendMode:"normal",opacity:1};try{_l&&_l.props&&Object.entries(_l.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(qA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Iit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${_l.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Lit(r,qA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(_l,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,_l.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})},Al={name:"Vibrance",props:{intensity:{type:Number,default:0,description:"The intensity of the vibrance effect"}},fragmentNode:({uniforms:r,childNode:t})=>{let{vec4:e}=rs;if(!t)return console.error("You must pass a child component into the Vibrance shader."),e(0);let s=t||e(0,0,0,0);return e(fit(s.rgb,r.intensity.uniform).rgb,s.a)}};function Pit(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const HA={blendMode:"normal",opacity:1};try{Al&&Al.props&&Object.entries(Al.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(HA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Fit=r=>{const t=J.useContext(xe);if(!t)throw new Error("Shader components must be used inside an <Ombre> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=J.useMemo(()=>r.id||`${Al.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=J.useMemo(()=>Pit(r,HA),[r]),l=J.useRef(null);l.current===null&&(l.current=Ms.createUniformsMap(Al,o,a));const h=J.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(J.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,Al.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),J.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),J.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return Vr.jsx(xe.Provider,{value:h,children:r.children})};exports.Circle=vtt;exports.GlassTiles=Mtt;exports.Grayscale=xit;exports.HueShift=vit;exports.Invert=Mit;exports.LinearGradient=Nit;exports.Ombre=xtt;exports.Posterize=zit;exports.Saturation=Eit;exports.SolidColor=Rit;exports.Twirl=Iit;exports.Vibrance=Fit;
|
|
168
|
+
//# sourceMappingURL=index.cjs.map
|