From ec21229d75eee17446dc7a453f98e8a63b473124 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 6 Jun 2025 16:35:09 +0900 Subject: [PATCH 1/4] Updated builds. --- build/three.cjs | 6 +-- build/three.core.js | 6 +-- build/three.core.min.js | 2 +- build/three.webgpu.js | 84 +++++++++++++++++++++------------ build/three.webgpu.min.js | 2 +- build/three.webgpu.nodes.js | 84 +++++++++++++++++++++------------ build/three.webgpu.nodes.min.js | 2 +- 7 files changed, 117 insertions(+), 69 deletions(-) diff --git a/build/three.cjs b/build/three.cjs index fccf327d8f2b3f..dc5a75765cd251 100644 --- a/build/three.cjs +++ b/build/three.cjs @@ -5,7 +5,7 @@ */ 'use strict'; -const REVISION = '177'; +const REVISION = '178dev'; /** * Represents mouse buttons and interaction types in context of controls. @@ -1619,8 +1619,8 @@ const InterpolationSamplingMode = { NORMAL: 'normal', CENTROID: 'centroid', SAMPLE: 'sample', - FLAT_FIRST: 'flat first', - FLAT_EITHER: 'flat either' + FIRST: 'first', + EITHER: 'either' }; /** diff --git a/build/three.core.js b/build/three.core.js index d32975ab86b980..606d78e77abeba 100644 --- a/build/three.core.js +++ b/build/three.core.js @@ -3,7 +3,7 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -const REVISION = '177'; +const REVISION = '178dev'; /** * Represents mouse buttons and interaction types in context of controls. @@ -1617,8 +1617,8 @@ const InterpolationSamplingMode = { NORMAL: 'normal', CENTROID: 'centroid', SAMPLE: 'sample', - FLAT_FIRST: 'flat first', - FLAT_EITHER: 'flat either' + FIRST: 'first', + EITHER: 'either' }; /** diff --git a/build/three.core.min.js b/build/three.core.min.js index 0e4d6dc3126f65..1f8c35999ff837 100644 --- a/build/three.core.min.js +++ b/build/three.core.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -const t="177",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},s=0,r=1,n=2,a=3,o=0,h=1,l=2,c=3,u=0,d=1,p=2,m=0,y=1,g=2,f=3,x=4,b=5,v=100,w=101,M=102,S=103,_=104,A=200,T=201,z=202,I=203,C=204,B=205,k=206,R=207,E=208,P=209,O=210,N=211,F=212,V=213,L=214,j=0,W=1,U=2,D=3,H=4,q=5,J=6,X=7,Y=0,Z=1,G=2,$=0,Q=1,K=2,tt=3,et=4,it=5,st=6,rt=7,nt="attached",at="detached",ot=300,ht=301,lt=302,ct=303,ut=304,dt=306,pt=1e3,mt=1001,yt=1002,gt=1003,ft=1004,xt=1004,bt=1005,vt=1005,wt=1006,Mt=1007,St=1007,_t=1008,At=1008,Tt=1009,zt=1010,It=1011,Ct=1012,Bt=1013,kt=1014,Rt=1015,Et=1016,Pt=1017,Ot=1018,Nt=1020,Ft=35902,Vt=1021,Lt=1022,jt=1023,Wt=1026,Ut=1027,Dt=1028,Ht=1029,qt=1030,Jt=1031,Xt=1032,Yt=1033,Zt=33776,Gt=33777,$t=33778,Qt=33779,Kt=35840,te=35841,ee=35842,ie=35843,se=36196,re=37492,ne=37496,ae=37808,oe=37809,he=37810,le=37811,ce=37812,ue=37813,de=37814,pe=37815,me=37816,ye=37817,ge=37818,fe=37819,xe=37820,be=37821,ve=36492,we=36494,Me=36495,Se=36283,_e=36284,Ae=36285,Te=36286,ze=2200,Ie=2201,Ce=2202,Be=2300,ke=2301,Re=2302,Ee=2400,Pe=2401,Oe=2402,Ne=2500,Fe=2501,Ve=0,Le=1,je=2,We=3200,Ue=3201,De=3202,He=3203,qe=0,Je=1,Xe="",Ye="srgb",Ze="srgb-linear",Ge="linear",$e="srgb",Qe=0,Ke=7680,ti=7681,ei=7682,ii=7683,si=34055,ri=34056,ni=5386,ai=512,oi=513,hi=514,li=515,ci=516,ui=517,di=518,pi=519,mi=512,yi=513,gi=514,fi=515,xi=516,bi=517,vi=518,wi=519,Mi=35044,Si=35048,_i=35040,Ai=35045,Ti=35049,zi=35041,Ii=35046,Ci=35050,Bi=35042,ki="100",Ri="300 es",Ei=2e3,Pi=2001,Oi={COMPUTE:"compute",RENDER:"render"},Ni={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Fi={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FLAT_FIRST:"flat first",FLAT_EITHER:"flat either"};class Vi{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const s=i[t];if(void 0!==s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,s=e.length;i>8&255]+Li[t>>16&255]+Li[t>>24&255]+"-"+Li[255&e]+Li[e>>8&255]+"-"+Li[e>>16&15|64]+Li[e>>24&255]+"-"+Li[63&i|128]+Li[i>>8&255]+"-"+Li[i>>16&255]+Li[i>>24&255]+Li[255&s]+Li[s>>8&255]+Li[s>>16&255]+Li[s>>24&255]).toLowerCase()}function Hi(t,e,i){return Math.max(e,Math.min(i,t))}function qi(t,e){return(t%e+e)%e}function Ji(t,e,i){return(1-i)*t+i*e}function Xi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Yi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Zi={DEG2RAD:Wi,RAD2DEG:Ui,generateUUID:Di,clamp:Hi,euclideanModulo:qi,mapLinear:function(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:Ji,damp:function(t,e,i,s){return Ji(t,e,1-Math.exp(-i*s))},pingpong:function(t,e=1){return e-Math.abs(qi(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(ji=t);let e=ji+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Wi},radToDeg:function(t){return t*Ui},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,s,r){const n=Math.cos,a=Math.sin,o=n(i/2),h=a(i/2),l=n((e+s)/2),c=a((e+s)/2),u=n((e-s)/2),d=a((e-s)/2),p=n((s-e)/2),m=a((s-e)/2);switch(r){case"XYX":t.set(o*c,h*u,h*d,o*l);break;case"YZY":t.set(h*d,o*c,h*u,o*l);break;case"ZXZ":t.set(h*u,h*d,o*c,o*l);break;case"XZX":t.set(o*c,h*m,h*p,o*l);break;case"YXY":t.set(h*p,o*c,h*m,o*l);break;case"ZYZ":t.set(h*m,h*p,o*c,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Yi,denormalize:Xi};class Gi{constructor(t=0,e=0){Gi.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,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[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=Hi(this.x,t.x,e.x),this.y=Hi(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Hi(this.x,t,e),this.y=Hi(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Hi(i,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(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Hi(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class $i{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,a){let o=i[s+0],h=i[s+1],l=i[s+2],c=i[s+3];const u=r[n+0],d=r[n+1],p=r[n+2],m=r[n+3];if(0===a)return t[e+0]=o,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||h!==d||l!==p){let t=1-a;const e=o*u+h*d+l*p+c*m,i=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const r=Math.sqrt(s),n=Math.atan2(r,e*i);t=Math.sin(t*n)/r,a=Math.sin(a*n)/r}const r=a*i;if(o=o*t+u*r,h=h*t+d*r,l=l*t+p*r,c=c*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=t,h*=t,l*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,s,r,n){const a=i[s],o=i[s+1],h=i[s+2],l=i[s+3],c=r[n],u=r[n+1],d=r[n+2],p=r[n+3];return t[e]=a*p+l*c+o*d-h*u,t[e+1]=o*p+l*u+h*c-a*d,t[e+2]=h*p+l*d+a*u-o*c,t[e+3]=l*p-a*c-o*u-h*d,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,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,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 i=t._x,s=t._y,r=t._z,n=t._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(s/2),c=a(r/2),u=o(i/2),d=o(s/2),p=o(r/2);switch(n){case"XYZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"YXZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"ZXY":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"ZYX":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"YZX":this._x=u*l*c+h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c-u*d*p;break;case"XZY":this._x=u*l*c-h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],a=e[5],o=e[9],h=e[2],l=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(l-o)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(o+l)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Hi(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const s=Math.min(1,e/i);return this.slerp(t,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(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 0===t?(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 i=t._x,s=t._y,r=t._z,n=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+n*a+s*h-r*o,this._y=s*l+n*o+r*a-i*h,this._z=r*l+n*h+i*o-s*a,this._w=n*l-i*a-s*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,s=this._y,r=this._z,n=this._w;let a=n*t._w+i*t._x+s*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=n,this._x=i,this._y=s,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*n+e*this._w,this._x=t*i+e*this._x,this._y=t*s+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(o),l=Math.atan2(h,a),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=n*c+this._w*u,this._x=i*c+this._x*u,this._y=s*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*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 Qi{constructor(t=0,e=0,i=0){Qi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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(ts.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ts.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,a=t.z,o=t.w,h=2*(n*s-a*i),l=2*(a*e-r*s),c=2*(r*i-n*e);return this.x=e+o*h+n*c-a*l,this.y=i+o*l+a*h-r*c,this.z=s+o*c+r*l-n*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,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,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=Hi(this.x,t.x,e.x),this.y=Hi(this.y,t.y,e.y),this.z=Hi(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Hi(this.x,t,e),this.y=Hi(this.y,t,e),this.z=Hi(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Hi(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,r=t.z,n=e.x,a=e.y,o=e.z;return this.x=s*o-r*a,this.y=r*n-i*o,this.z=i*a-s*n,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Ki.copy(this).projectOnVector(t),this.sub(Ki)}reflect(t){return this.sub(Ki.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Hi(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}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,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}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=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ki=new Qi,ts=new $i;class es{constructor(t,e,i,s,r,n,a,o,h){es.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h)}set(t,e,i,s,r,n,a,o,h){const l=this.elements;return l[0]=t,l[1]=s,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[3],o=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=s[0],y=s[3],g=s[6],f=s[1],x=s[4],b=s[7],v=s[2],w=s[5],M=s[8];return r[0]=n*m+a*f+o*v,r[3]=n*y+a*x+o*w,r[6]=n*g+a*b+o*M,r[1]=h*m+l*f+c*v,r[4]=h*y+l*x+c*w,r[7]=h*g+l*b+c*M,r[2]=u*m+d*f+p*v,r[5]=u*y+d*x+p*w,r[8]=u*g+d*b+p*M,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],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*n*l-e*a*h-i*r*l+i*a*o+s*r*h-s*n*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=l*n-a*h,u=a*o-l*r,d=h*r-n*o,p=e*c+i*u+s*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(s*h-l*i)*m,t[2]=(a*i-s*n)*m,t[3]=u*m,t[4]=(l*e-s*o)*m,t[5]=(s*r-a*e)*m,t[6]=d*m,t[7]=(i*o-h*e)*m,t[8]=(n*e-i*r)*m,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,i,s,r,n,a){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*n+h*a)+n+t,-s*h,s*o,-s*(-h*n+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(is.makeScale(t,e)),this}rotate(t){return this.premultiply(is.makeRotation(-t)),this}translate(t,e){return this.premultiply(is.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const is=new es;function ss(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const rs={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ns(t,e){return new rs[t](e)}function as(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function os(){const t=as("canvas");return t.style.display="block",t}const hs={};function ls(t){t in hs||(hs[t]=!0,console.warn(t))}function cs(t,e,i){return new Promise((function(s,r){setTimeout((function n(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(n,i);break;default:s()}}),i)}))}function us(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function ds(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}const ps=(new es).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ms=(new es).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ys(){const t={enabled:!0,workingColorSpace:Ze,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===$e&&(t.r=fs(t.r),t.g=fs(t.g),t.b=fs(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===$e&&(t.r=xs(t.r),t.g=xs(t.g),t.b=xs(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?Ge:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return ls("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return ls("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],s=[.3127,.329];return t.define({[Ze]:{primaries:e,whitePoint:s,transfer:Ge,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:Ye},outputColorSpaceConfig:{drawingBufferColorSpace:Ye}},[Ye]:{primaries:e,whitePoint:s,transfer:$e,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:Ye}}}),t}const gs=ys();function fs(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function xs(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let bs;class vs{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===bs&&(bs=as("canvas")),bs.width=t.width,bs.height=t.height;const e=bs.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=bs}return i.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=as("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),r=s.data;for(let t=0;t1),this.pmremVersion=0}get width(){return this.source.getSize(As).x}get height(){return this.source.getSize(As).y}get depth(){return this.source.getSize(As).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 i=t[e];if(void 0===i){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[e]=i:console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ot)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case pt:t.x=t.x-Math.floor(t.x);break;case mt:t.x=t.x<0?0:1;break;case yt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case pt:t.y=t.y-Math.floor(t.y);break;case mt:t.y=t.y<0?0:1;break;case yt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ts.DEFAULT_IMAGE=null,Ts.DEFAULT_MAPPING=ot,Ts.DEFAULT_ANISOTROPY=1;class zs{constructor(t=0,e=0,i=0,s=1){zs.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}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,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,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=void 0!==t.w?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,i=this.y,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,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,i,s,r;const n=.01,a=.1,o=t.elements,h=o[0],l=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],y=o[6],g=o[10];if(Math.abs(l-u)o&&t>f?tf?o1;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,i=t.textures.length;e=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,Ns),Ns.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Hs),qs.subVectors(this.max,Hs),Vs.subVectors(t.a,Hs),Ls.subVectors(t.b,Hs),js.subVectors(t.c,Hs),Ws.subVectors(Ls,Vs),Us.subVectors(js,Ls),Ds.subVectors(Vs,js);let e=[0,-Ws.z,Ws.y,0,-Us.z,Us.y,0,-Ds.z,Ds.y,Ws.z,0,-Ws.x,Us.z,0,-Us.x,Ds.z,0,-Ds.x,-Ws.y,Ws.x,0,-Us.y,Us.x,0,-Ds.y,Ds.x,0];return!!Ys(e,Vs,Ls,js,qs)&&(e=[1,0,0,0,1,0,0,0,1],!!Ys(e,Vs,Ls,js,qs)&&(Js.crossVectors(Ws,Us),e=[Js.x,Js.y,Js.z],Ys(e,Vs,Ls,js,qs)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ns).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Ns).length()),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()||(Os[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Os[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Os[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Os[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Os[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Os[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Os[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Os[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Os)),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 Os=[new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi],Ns=new Qi,Fs=new Ps,Vs=new Qi,Ls=new Qi,js=new Qi,Ws=new Qi,Us=new Qi,Ds=new Qi,Hs=new Qi,qs=new Qi,Js=new Qi,Xs=new Qi;function Ys(t,e,i,s,r){for(let n=0,a=t.length-3;n<=a;n+=3){Xs.fromArray(t,n);const a=r.x*Math.abs(Xs.x)+r.y*Math.abs(Xs.y)+r.z*Math.abs(Xs.z),o=e.dot(Xs),h=i.dot(Xs),l=s.dot(Xs);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>a)return!1}return!0}const Zs=new Ps,Gs=new Qi,$s=new Qi;class Qs{constructor(t=new Qi,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 i=this.center;void 0!==e?i.copy(e):Zs.setFromPoints(t).getCenter(i);let s=0;for(let e=0,r=t.length;ethis.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;Gs.subVectors(t,this.center);const e=Gs.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Gs,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):($s.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gs.copy(t.center).add($s)),this.expandByPoint(Gs.copy(t.center).sub($s))),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 Ks=new Qi,tr=new Qi,er=new Qi,ir=new Qi,sr=new Qi,rr=new Qi,nr=new Qi;class ar{constructor(t=new Qi,e=new Qi(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,Ks)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ks.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ks.copy(this.origin).addScaledVector(this.direction,e),Ks.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){tr.copy(t).add(e).multiplyScalar(.5),er.copy(e).sub(t).normalize(),ir.copy(this.origin).sub(tr);const r=.5*t.distanceTo(e),n=-this.direction.dot(er),a=ir.dot(this.direction),o=-ir.dot(er),h=ir.lengthSq(),l=Math.abs(1-n*n);let c,u,d,p;if(l>0)if(c=n*o-a,u=n*a-o,p=r*l,c>=0)if(u>=-p)if(u<=p){const t=1/l;c*=t,u*=t,d=c*(c+n*u+2*a)+u*(n*c+u+2*o)+h}else u=r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u=-r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u<=-p?(c=Math.max(0,-(-n*r+a)),u=c>0?-r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h):u<=p?(c=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+h):(c=Math.max(0,-(n*r+a)),u=c>0?r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h);else u=n>0?-r:r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,c),s&&s.copy(tr).addScaledVector(er,u),d}intersectSphere(t,e){Ks.subVectors(t.center,this.origin);const i=Ks.dot(this.direction),s=Ks.dot(Ks)-i*i,r=t.radius*t.radius;if(s>r)return null;const n=Math.sqrt(r-s),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,r,n,a,o;const h=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return h>=0?(i=(t.min.x-u.x)*h,s=(t.max.x-u.x)*h):(i=(t.max.x-u.x)*h,s=(t.min.x-u.x)*h),l>=0?(r=(t.min.y-u.y)*l,n=(t.max.y-u.y)*l):(r=(t.max.y-u.y)*l,n=(t.min.y-u.y)*l),i>n||r>s?null:((r>i||isNaN(i))&&(i=r),(n=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),i>o||a>s?null:((a>i||i!=i)&&(i=a),(o=0?i:s,e)))}intersectsBox(t){return null!==this.intersectBox(t,Ks)}intersectTriangle(t,e,i,s,r){sr.subVectors(e,t),rr.subVectors(i,t),nr.crossVectors(sr,rr);let n,a=this.direction.dot(nr);if(a>0){if(s)return null;n=1}else{if(!(a<0))return null;n=-1,a=-a}ir.subVectors(this.origin,t);const o=n*this.direction.dot(rr.crossVectors(ir,rr));if(o<0)return null;const h=n*this.direction.dot(sr.cross(ir));if(h<0)return null;if(o+h>a)return null;const l=-n*ir.dot(nr);return l<0?null:this.at(l/a,r)}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 or{constructor(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y){or.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y)}set(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=r,g[5]=n,g[9]=a,g[13]=o,g[2]=h,g[6]=l,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=y,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 or).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/hr.setFromMatrixColumn(t,0).length(),r=1/hr.setFromMatrixColumn(t,1).length(),n=1/hr.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,r=t.z,n=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=n*l,i=n*c,s=a*l,r=a*c;e[0]=o*l,e[4]=-o*c,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-a*o,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*o}else if("YXZ"===t.order){const t=o*l,i=o*c,s=h*l,r=h*c;e[0]=t+r*a,e[4]=s*a-i,e[8]=n*h,e[1]=n*c,e[5]=n*l,e[9]=-a,e[2]=i*a-s,e[6]=r+t*a,e[10]=n*o}else if("ZXY"===t.order){const t=o*l,i=o*c,s=h*l,r=h*c;e[0]=t-r*a,e[4]=-n*c,e[8]=s+i*a,e[1]=i+s*a,e[5]=n*l,e[9]=r-t*a,e[2]=-n*h,e[6]=a,e[10]=n*o}else if("ZYX"===t.order){const t=n*l,i=n*c,s=a*l,r=a*c;e[0]=o*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=o*c,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=a*o,e[10]=n*o}else if("YZX"===t.order){const t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=r-t*c,e[8]=s*c+i,e[1]=c,e[5]=n*l,e[9]=-a*l,e[2]=-h*l,e[6]=i*c+s,e[10]=t-r*c}else if("XZY"===t.order){const t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=n*l,e[9]=i*c-s,e[2]=s*c-i,e[6]=a*l,e[10]=r*c+t}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(cr,t,ur)}lookAt(t,e,i){const s=this.elements;return mr.subVectors(t,e),0===mr.lengthSq()&&(mr.z=1),mr.normalize(),dr.crossVectors(i,mr),0===dr.lengthSq()&&(1===Math.abs(i.z)?mr.x+=1e-4:mr.z+=1e-4,mr.normalize(),dr.crossVectors(i,mr)),dr.normalize(),pr.crossVectors(mr,dr),s[0]=dr.x,s[4]=pr.x,s[8]=mr.x,s[1]=dr.y,s[5]=pr.y,s[9]=mr.y,s[2]=dr.z,s[6]=pr.z,s[10]=mr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[4],o=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],y=i[10],g=i[14],f=i[3],x=i[7],b=i[11],v=i[15],w=s[0],M=s[4],S=s[8],_=s[12],A=s[1],T=s[5],z=s[9],I=s[13],C=s[2],B=s[6],k=s[10],R=s[14],E=s[3],P=s[7],O=s[11],N=s[15];return r[0]=n*w+a*A+o*C+h*E,r[4]=n*M+a*T+o*B+h*P,r[8]=n*S+a*z+o*k+h*O,r[12]=n*_+a*I+o*R+h*N,r[1]=l*w+c*A+u*C+d*E,r[5]=l*M+c*T+u*B+d*P,r[9]=l*S+c*z+u*k+d*O,r[13]=l*_+c*I+u*R+d*N,r[2]=p*w+m*A+y*C+g*E,r[6]=p*M+m*T+y*B+g*P,r[10]=p*S+m*z+y*k+g*O,r[14]=p*_+m*I+y*R+g*N,r[3]=f*w+x*A+b*C+v*E,r[7]=f*M+x*T+b*B+v*P,r[11]=f*S+x*z+b*k+v*O,r[15]=f*_+x*I+b*R+v*N,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],i=t[4],s=t[8],r=t[12],n=t[1],a=t[5],o=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*o*c-s*h*c-r*a*u+i*h*u+s*a*d-i*o*d)+t[7]*(+e*o*d-e*h*u+r*n*u-s*n*d+s*h*l-r*o*l)+t[11]*(+e*h*c-e*a*d-r*n*c+i*n*d+r*a*l-i*h*l)+t[15]*(-s*a*l-e*o*c+e*a*u+s*n*c-i*n*u+i*o*l)}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,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],y=t[14],g=t[15],f=c*y*h-m*u*h+m*o*d-a*y*d-c*o*g+a*u*g,x=p*u*h-l*y*h-p*o*d+n*y*d+l*o*g-n*u*g,b=l*m*h-p*c*h+p*a*d-n*m*d-l*a*g+n*c*g,v=p*c*o-l*m*o-p*a*u+n*m*u+l*a*y-n*c*y,w=e*f+i*x+s*b+r*v;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/w;return t[0]=f*M,t[1]=(m*u*r-c*y*r-m*s*d+i*y*d+c*s*g-i*u*g)*M,t[2]=(a*y*r-m*o*r+m*s*h-i*y*h-a*s*g+i*o*g)*M,t[3]=(c*o*r-a*u*r-c*s*h+i*u*h+a*s*d-i*o*d)*M,t[4]=x*M,t[5]=(l*y*r-p*u*r+p*s*d-e*y*d-l*s*g+e*u*g)*M,t[6]=(p*o*r-n*y*r-p*s*h+e*y*h+n*s*g-e*o*g)*M,t[7]=(n*u*r-l*o*r+l*s*h-e*u*h-n*s*d+e*o*d)*M,t[8]=b*M,t[9]=(p*c*r-l*m*r-p*i*d+e*m*d+l*i*g-e*c*g)*M,t[10]=(n*m*r-p*a*r+p*i*h-e*m*h-n*i*g+e*a*g)*M,t[11]=(l*a*r-n*c*r-l*i*h+e*c*h+n*i*d-e*a*d)*M,t[12]=v*M,t[13]=(l*m*s-p*c*s+p*i*u-e*m*u-l*i*y+e*c*y)*M,t[14]=(p*a*s-n*m*s-p*i*o+e*m*o+n*i*y-e*a*y)*M,t[15]=(n*c*s-l*a*s+l*i*o-e*c*o-n*i*u+e*a*u)*M,this}scale(t){const e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),r=1-i,n=t.x,a=t.y,o=t.z,h=r*n,l=r*a;return this.set(h*n+i,h*a-s*o,h*o+s*a,0,h*a+s*o,l*a+i,l*o-s*n,0,h*o-s*a,l*o+s*n,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,r=e._x,n=e._y,a=e._z,o=e._w,h=r+r,l=n+n,c=a+a,u=r*h,d=r*l,p=r*c,m=n*l,y=n*c,g=a*c,f=o*h,x=o*l,b=o*c,v=i.x,w=i.y,M=i.z;return s[0]=(1-(m+g))*v,s[1]=(d+b)*v,s[2]=(p-x)*v,s[3]=0,s[4]=(d-b)*w,s[5]=(1-(u+g))*w,s[6]=(y+f)*w,s[7]=0,s[8]=(p+x)*M,s[9]=(y-f)*M,s[10]=(1-(u+m))*M,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let r=hr.set(s[0],s[1],s[2]).length();const n=hr.set(s[4],s[5],s[6]).length(),a=hr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],lr.copy(this);const o=1/r,h=1/n,l=1/a;return lr.elements[0]*=o,lr.elements[1]*=o,lr.elements[2]*=o,lr.elements[4]*=h,lr.elements[5]*=h,lr.elements[6]*=h,lr.elements[8]*=l,lr.elements[9]*=l,lr.elements[10]*=l,e.setFromRotationMatrix(lr),i.x=r,i.y=n,i.z=a,this}makePerspective(t,e,i,s,r,n,a=2e3){const o=this.elements,h=2*r/(e-t),l=2*r/(i-s),c=(e+t)/(e-t),u=(i+s)/(i-s);let d,p;if(a===Ei)d=-(n+r)/(n-r),p=-2*n*r/(n-r);else{if(a!==Pi)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-n/(n-r),p=-n*r/(n-r)}return o[0]=h,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,r,n,a=2e3){const o=this.elements,h=1/(e-t),l=1/(i-s),c=1/(n-r),u=(e+t)*h,d=(i+s)*l;let p,m;if(a===Ei)p=(n+r)*c,m=-2*c;else{if(a!==Pi)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*c,m=-1*c}return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const hr=new Qi,lr=new or,cr=new Qi(0,0,0),ur=new Qi(1,1,1),dr=new Qi,pr=new Qi,mr=new Qi,yr=new or,gr=new $i;class fr{constructor(t=0,e=0,i=0,s=fr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}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,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,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,i=!0){const s=t.elements,r=s[0],n=s[4],a=s[8],o=s[1],h=s[5],l=s[9],c=s[2],u=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(Hi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Hi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(Hi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Hi(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(Hi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Hi(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return yr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(yr,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return gr.setFromEuler(this),this.setFromQuaternion(gr,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],void 0!==t[3]&&(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}}fr.DEFAULT_ORDER="XYZ";class xr{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map((t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0}))),s.instanceInfo=this._instanceInfo.map((t=>({...t}))),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(s.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,s=i.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(i.geometries=e),s.length>0&&(i.materials=s),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l),c.length>0&&(i.nodes=c)}return i.object=s,i;function n(t){const e=[];for(const i in t){const s=t[i];delete s.metadata,e.push(s)}return e}}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)),!0===e)for(let e=0;e0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,i,s,r){Or.subVectors(s,e),Nr.subVectors(i,e),Fr.subVectors(t,e);const n=Or.dot(Or),a=Or.dot(Nr),o=Or.dot(Fr),h=Nr.dot(Nr),l=Nr.dot(Fr),c=n*h-a*a;if(0===c)return r.set(0,0,0),null;const u=1/c,d=(h*o-a*l)*u,p=(n*l-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,s){return null!==this.getBarycoord(t,e,i,s,Vr)&&(Vr.x>=0&&Vr.y>=0&&Vr.x+Vr.y<=1)}static getInterpolation(t,e,i,s,r,n,a,o){return null===this.getBarycoord(t,e,i,s,Vr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Vr.x),o.addScaledVector(n,Vr.y),o.addScaledVector(a,Vr.z),o)}static getInterpolatedAttribute(t,e,i,s,r,n){return qr.setScalar(0),Jr.setScalar(0),Xr.setScalar(0),qr.fromBufferAttribute(t,e),Jr.fromBufferAttribute(t,i),Xr.fromBufferAttribute(t,s),n.setScalar(0),n.addScaledVector(qr,r.x),n.addScaledVector(Jr,r.y),n.addScaledVector(Xr,r.z),n}static isFrontFacing(t,e,i,s){return Or.subVectors(i,e),Nr.subVectors(t,e),Or.cross(Nr).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),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 Or.subVectors(this.c,this.b),Nr.subVectors(this.a,this.b),.5*Or.cross(Nr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Yr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Yr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,r){return Yr.getInterpolation(t,this.a,this.b,this.c,e,i,s,r)}containsPoint(t){return Yr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Yr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,r=this.c;let n,a;Lr.subVectors(s,i),jr.subVectors(r,i),Ur.subVectors(t,i);const o=Lr.dot(Ur),h=jr.dot(Ur);if(o<=0&&h<=0)return e.copy(i);Dr.subVectors(t,s);const l=Lr.dot(Dr),c=jr.dot(Dr);if(l>=0&&c<=l)return e.copy(s);const u=o*c-l*h;if(u<=0&&o>=0&&l<=0)return n=o/(o-l),e.copy(i).addScaledVector(Lr,n);Hr.subVectors(t,r);const d=Lr.dot(Hr),p=jr.dot(Hr);if(p>=0&&d<=p)return e.copy(r);const m=d*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(i).addScaledVector(jr,a);const y=l*p-d*c;if(y<=0&&c-l>=0&&d-p>=0)return Wr.subVectors(r,s),a=(c-l)/(c-l+(d-p)),e.copy(s).addScaledVector(Wr,a);const g=1/(y+m+u);return n=m*g,a=u*g,e.copy(i).addScaledVector(Lr,n).addScaledVector(jr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Zr={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},Gr={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Qr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class Kr{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ye){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,gs.colorSpaceToWorking(this,e),this}setRGB(t,e,i,s=gs.workingColorSpace){return this.r=t,this.g=e,this.b=i,gs.colorSpaceToWorking(this,s),this}setHSL(t,e,i,s=gs.workingColorSpace){if(t=qi(t,1),e=Hi(e,0,1),i=Hi(i,0,1),0===e)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=Qr(r,s,t+1/3),this.g=Qr(r,s,t),this.b=Qr(r,s,t-1/3)}return gs.colorSpaceToWorking(this,s),this}setStyle(t,e=Ye){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=s[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,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=Ye){const i=Zr[t.toLowerCase()];return void 0!==i?this.setHex(i,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=fs(t.r),this.g=fs(t.g),this.b=fs(t.b),this}copyLinearToSRGB(t){return this.r=xs(t.r),this.g=xs(t.g),this.b=xs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ye){return gs.workingToColorSpace(tn.copy(this),t),65536*Math.round(Hi(255*tn.r,0,255))+256*Math.round(Hi(255*tn.g,0,255))+Math.round(Hi(255*tn.b,0,255))}getHexString(t=Ye){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=gs.workingColorSpace){gs.workingToColorSpace(tn.copy(this),e);const i=tn.r,s=tn.g,r=tn.b,n=Math.max(i,s,r),a=Math.min(i,s,r);let o,h;const l=(a+n)/2;if(a===n)o=0,h=0;else{const t=n-a;switch(h=l<=.5?t/(n+a):t/(2-n-a),n){case i:o=(s-r)/t+(s0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function s(t){const e=[];for(const i in t){const s=t[i];delete s.metadata,e.push(s)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ke&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ke&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ke&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=s(t.textures),r=s(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let s=0;s!==t;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,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){!0===t&&this.version++}}class rn extends sn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kr(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 fr,this.combine=0,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 nn=an();function an(){const t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),s=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(s[t]=0,s[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(s[t]=1024>>-e-14,s[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(s[t]=e+15<<10,s[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(s[t]=31744,s[256|t]=64512,r[t]=24,r[256|t]=24):(s[t]=31744,s[256|t]=64512,r[t]=13,r[256|t]=13)}const n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;!(8388608&e);)e<<=1,i-=8388608;e&=-8388609,i+=947912704,n[t]=e|i}for(let t=1024;t<2048;++t)n[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:s,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function on(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=Hi(t,-65504,65504),nn.floatView[0]=t;const e=nn.uint32View[0],i=e>>23&511;return nn.baseTable[i]+((8388607&e)>>nn.shiftTable[i])}function hn(t){const e=t>>10;return nn.uint32View[0]=nn.mantissaTable[nn.offsetTable[e]+(1023&t)]+nn.exponentTable[e],nn.floatView[0]}class ln{static toHalfFloat(t){return on(t)}static fromHalfFloat(t){return hn(t)}}const cn=new Qi,un=new Gi;let dn=0;class pn{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:dn++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=Mi,this.updateRanges=[],this.gpuType=Rt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&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,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,r=this.itemSize;se.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(){null===this.boundingBox&&(this.boundingBox=new Ps);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Qi(-1/0,-1/0,-1/0),new Qi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const s=i[e];t.data.attributes[e]=s.toJSON(t.data)}const s={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],n=[];for(let e=0,s=i.length;e0&&(s[e]=n,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const n=this.groups;n.length>0&&(t.data.groups=JSON.parse(JSON.stringify(n)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.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 i=t.index;null!==i&&this.setIndex(i.clone());const s=t.attributes;for(const t in s){const i=s[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],s=r[t];for(let t=0,r=s.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)return}kn.copy(r).invert(),Rn.copy(t.ray).applyMatrix4(kn),null!==i.boundingBox&&!1===Rn.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Rn)}}_computeIntersections(t,e,i){let s;const r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,o=u.length;ri.far?null:{distance:l,point:Wn.clone(),object:t}}(t,e,i,s,On,Nn,Fn,jn);if(c){const t=new Qi;Yr.getBarycoord(jn,On,Nn,Fn,t),r&&(c.uv=Yr.getInterpolatedAttribute(r,o,h,l,t,new Gi)),n&&(c.uv1=Yr.getInterpolatedAttribute(n,o,h,l,t,new Gi)),a&&(c.normal=Yr.getInterpolatedAttribute(a,o,h,l,t,new Qi),c.normal.dot(s.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:h,c:l,normal:new Qi,materialIndex:0};Yr.getNormal(On,Nn,Fn,e.normal),c.face=e,c.barycoord=t}return c}class Hn extends Bn{constructor(t=1,e=1,i=1,s=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:r,depthSegments:n};const a=this;s=Math.floor(s),r=Math.floor(r),n=Math.floor(n);const o=[],h=[],l=[],c=[];let u=0,d=0;function p(t,e,i,s,r,n,p,m,y,g,f){const x=n/y,b=p/g,v=n/2,w=p/2,M=m/2,S=y+1,_=g+1;let A=0,T=0;const z=new Qi;for(let n=0;n<_;n++){const a=n*b-w;for(let o=0;o0?1:-1,l.push(z.x,z.y,z.z),c.push(o/y),c.push(1-n/g),A+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class Gn extends Pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new or,this.projectionMatrix=new or,this.projectionMatrixInverse=new or,this.coordinateSystem=Ei}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 $n=new Qi,Qn=new Gi,Kn=new Gi;class ta extends Gn{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,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=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ui*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Wi*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ui*Math.atan(Math.tan(.5*Wi*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,i){$n.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set($n.x,$n.y).multiplyScalar(-t/$n.z),$n.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set($n.x,$n.y).multiplyScalar(-t/$n.z)}getViewSize(t,e){return this.getViewBounds(t,Qn,Kn),e.subVectors(Kn,Qn)}setViewOffset(t,e,i,s,r,n){this.aspect=t/e,null===this.view&&(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=i,this.view.offsetY=s,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Wi*this.fov)/this.zoom,i=2*e,s=this.aspect*i,r=-.5*s;const n=this.view;if(null!==this.view&&this.view.enabled){const t=n.fullWidth,a=n.fullHeight;r+=n.offsetX*s/t,e-=n.offsetY*i/a,s*=n.width/t,i*=n.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-i,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ea=-90;class ia extends Pr{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new ta(ea,1,t,e);s.layers=this.layers,this.add(s);const r=new ta(ea,1,t,e);r.layers=this.layers,this.add(r);const n=new ta(ea,1,t,e);n.layers=this.layers,this.add(n);const a=new ta(ea,1,t,e);a.layers=this.layers,this.add(a);const o=new ta(ea,1,t,e);o.layers=this.layers,this.add(o);const h=new ta(ea,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,s,r,n,a,o]=e;for(const t of e)this.remove(t);if(t===Ei)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.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(t!==Pi)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.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)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,n,a,o,h,l]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,r),t.setRenderTarget(i,1,s),t.render(e,n),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,l),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class sa extends Ts{constructor(t=[],e=301,i,s,r,n,a,o,h,l){super(t,e,i,s,r,n,a,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ra extends Cs{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},s=[i,i,i,i,i,i];this.texture=new sa(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},s=new Hn(5,5,5),r=new Zn({name:"CubemapFromEquirect",uniforms:qn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const n=new Un(s,r),a=e.minFilter;e.minFilter===_t&&(e.minFilter=wt);return new ia(1,10,this).update(t,n),e.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(t,e=!0,i=!0,s=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(r)}}class na extends Pr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const aa={type:"move"};class oa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new na,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new na,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Qi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Qi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new na,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Qi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Qi),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let s=null,r=null,n=null;const a=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){n=!0;for(const s of t.hand.values()){const t=e.getJointPose(s,i),r=this._getHandJoint(h,s);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const s=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=s.position.distanceTo(r.position),o=.02,l=.005;h.inputState.pinching&&a>o+l?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&a<=o-l&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(s=e.getPose(t.targetRaySpace,i),null===s&&null!==r&&(s=r),null!==s&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(aa)))}return null!==a&&(a.visible=null!==s),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==n),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new na;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class ha{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Kr(t),this.density=e}clone(){return new ha(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class la{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new Kr(t),this.near=e,this.far=i}clone(){return new la(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ca extends Pr{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 fr,this.environmentIntensity=1,this.environmentRotation=new fr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ua{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Mi,this.updateRanges=[],this.version=0,this.uuid=Di()}onUploadCallback(){}set needsUpdate(t){!0===t&&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,i){t*=this.stride,i*=e.stride;for(let s=0,r=this.stride;st.far||e.push({distance:o,point:ga.clone(),uv:Yr.getInterpolation(ga,Ma,Sa,_a,Aa,Ta,za,new Gi),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ca(t,e,i,s,r,n){ba.subVectors(t,i).addScalar(.5).multiply(s),void 0!==r?(va.x=n*ba.x-r*ba.y,va.y=r*ba.x+n*ba.y):va.copy(ba),t.copy(e),t.x+=va.x,t.y+=va.y,t.applyMatrix4(wa)}const Ba=new Qi,ka=new Qi;class Ra extends Pr{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,i=e.length;t0){let i,s;for(i=1,s=e.length;i0){Ba.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(Ba);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Ba.setFromMatrixPosition(t.matrixWorld),ka.setFromMatrixPosition(this.matrixWorld);const i=Ba.distanceTo(ka)/t.zoom;let s,r;for(e[0].object.visible=!0,s=1,r=e.length;s=t))break;e[s-1].object.visible=!1,e[s].object.visible=!0}for(this._currentLevel=s-1;s1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||no.getNormalMatrix(t),s=this.coplanarPoint(so).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),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)}}const oo=new Qs,ho=new Qi;class lo{constructor(t=new ao,e=new ao,i=new ao,s=new ao,r=new ao,n=new ao){this.planes=[t,e,i,s,r,n]}set(t,e,i,s,r,n){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(n),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,s=t.elements,r=s[0],n=s[1],a=s[2],o=s[3],h=s[4],l=s[5],c=s[6],u=s[7],d=s[8],p=s[9],m=s[10],y=s[11],g=s[12],f=s[13],x=s[14],b=s[15];if(i[0].setComponents(o-r,u-h,y-d,b-g).normalize(),i[1].setComponents(o+r,u+h,y+d,b+g).normalize(),i[2].setComponents(o+n,u+l,y+p,b+f).normalize(),i[3].setComponents(o-n,u-l,y-p,b-f).normalize(),i[4].setComponents(o-a,u-c,y-m,b-x).normalize(),e===Ei)i[5].setComponents(o+a,u+c,y+m,b+x).normalize();else{if(e!==Pi)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(a,c,m,x).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),oo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),oo.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(oo)}intersectsSprite(t){return oo.center.set(0,0,0),oo.radius=.7071067811865476,oo.applyMatrix4(t.matrixWorld),this.intersectsSphere(oo)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,ho.y=s.normal.y>0?t.max.y:t.min.y,ho.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ho)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const co=new or,uo=new lo;class po{constructor(){this.coordinateSystem=Ei}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];n.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}}const xo=new or,bo=new Kr(1,1,1),vo=new lo,wo=new po,Mo=new Ps,So=new Qs,_o=new Qi,Ao=new Qi,To=new Qi,zo=new fo,Io=new Un,Co=[];function Bo(t,e,i=0){const s=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let n=0;n65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new pn(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(!t.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const s=t.getAttribute(i),r=e.getAttribute(i);if(s.itemSize!==r.itemSize||s.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ps);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(mo),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=e):(i=this._instanceInfo.length,this._instanceInfo.push(e));const s=this._matricesTexture;xo.identity().toArray(s.image.data,16*i),s.needsUpdate=!0;const r=this._colorsTexture;return r&&(bo.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,i=-1){this._initializeGeometry(t),this._validateGeometry(t);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const n=t.getIndex();if(null!==n&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=-1===i?n.count:i),-1!==s.indexStart&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(mo),a=this._availableGeometryIds.shift(),r[a]=s):(a=this._geometryCount,this._geometryCount++,r.push(s)),this.setGeometryAt(a,t),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,s=null!==i.getIndex(),r=i.getIndex(),n=e.getIndex(),a=this._geometryInfo[t];if(s&&n.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,h=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in i.attributes){const s=e.getAttribute(t),r=i.getAttribute(t);Bo(s,r,o);const n=s.itemSize;for(let t=s.count,e=h;t=e.length||!1===e[t].active)return this;const i=this._instanceInfo;for(let e=0,s=i.length;ee)).sort(((t,e)=>i[t].vertexStart-i[e].vertexStart)),r=this.geometry;for(let n=0,a=i.length;n=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingBox){const t=new Ps,e=i.index,r=i.attributes.position;for(let i=s.start,n=s.start+s.count;i=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingSphere){const e=new Qs;this.getBoundingBoxAt(t,Mo),Mo.getCenter(e.center);const r=i.index,n=i.attributes.position;let a=0;for(let t=s.start,i=s.start+s.count;tt.active));if(Math.max(...i.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...i.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Bn,this._initializeGeometry(s));const r=this.geometry;s.index&&ko(s.index.array,r.index.array);for(const t in s.attributes)ko(s.attributes[t].array,r.attributes[t].array)}raycast(t,e){const i=this._instanceInfo,s=this._geometryInfo,r=this.matrixWorld,n=this.geometry;Io.material=this.material,Io.geometry.index=n.index,Io.geometry.attributes=n.attributes,null===Io.geometry.boundingBox&&(Io.geometry.boundingBox=new Ps),null===Io.geometry.boundingSphere&&(Io.geometry.boundingSphere=new Qs);for(let n=0,a=i.length;n({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,i,s,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const n=s.getIndex(),a=null===n?1:n.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,c=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,m=i.isArrayCamera?wo:vo;u&&!i.isArrayCamera&&(xo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vo.setFromProjectionMatrix(xo,t.coordinateSystem));let y=0;if(this.sortObjects){xo.copy(this.matrixWorld).invert(),_o.setFromMatrixPosition(i.matrixWorld).applyMatrix4(xo),Ao.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(xo);for(let t=0,e=o.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ts)return;Lo.applyMatrix4(t.matrixWorld);const h=e.ray.origin.distanceTo(Lo);return he.far?void 0:{distance:h,point:jo.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const Do=new Qi,Ho=new Qi;class qo extends Wo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,s=e.count;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class th extends Ts{constructor(t,e,i,s,r=1006,n=1006,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isVideoTexture=!0,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){l.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class eh extends th{constructor(t,e,i,s,r,n,a,o){super({},t,e,i,s,r,n,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class ih extends Ts{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gt,this.minFilter=gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class sh extends Ts{constructor(t,e,i,s,r,n,a,o,h,l,c,u){super(null,n,a,o,h,l,s,r,c,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rh extends sh{constructor(t,e,i,s,r,n){super(t,e,i,r,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=mt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class nh extends sh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ht),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ah extends Ts{constructor(t,e,i,s,r,n,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class oh extends Ts{constructor(t,e,i=1014,s,r,n,a=1003,o=1003,h,l=1026,c=1){if(l!==Wt&&1027!==l)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},s,r,n,a,o,l,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ms(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class hh extends Bn{constructor(t=1,e=1,i=4,s=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:i,radialSegments:s,heightSegments:r},e=Math.max(0,e),i=Math.max(1,Math.floor(i)),s=Math.max(3,Math.floor(s)),r=Math.max(1,Math.floor(r));const n=[],a=[],o=[],h=[],l=e/2,c=Math.PI/2*t,u=e,d=2*c+u,p=2*i+r,m=s+1,y=new Qi,g=new Qi;for(let f=0;f<=p;f++){let x=0,b=0,v=0,w=0;if(f<=i){const e=f/i,s=e*Math.PI/2;b=-l-t*Math.cos(s),v=t*Math.sin(s),w=-t*Math.cos(s),x=e*c}else if(f<=i+r){const s=(f-i)/r;b=s*e-l,v=t,w=0,x=c+s*u}else{const e=(f-i-r)/i,s=e*Math.PI/2;b=l+t*Math.sin(s),v=t*Math.cos(s),w=t*Math.sin(s),x=c+u+e*c}const M=Math.max(0,Math.min(1,x/d));let S=0;0===f?S=.5/s:f===p&&(S=-.5/s);for(let t=0;t<=s;t++){const e=t/s,i=e*Math.PI*2,r=Math.sin(i),n=Math.cos(i);g.x=-v*n,g.y=b,g.z=v*r,a.push(g.x,g.y,g.z),y.set(-v*n,w,v*r),y.normalize(),o.push(y.x,y.y,y.z),h.push(e+S,M)}if(f>0){const t=(f-1)*m;for(let e=0;e0||0!==s)&&(l.push(n,a,h),x+=3),(e>0||s!==r-1)&&(l.push(a,o,h),x+=3)}h.addGroup(g,x,0),g+=x}(),!1===n&&(t>0&&f(!0),e>0&&f(!1)),this.setIndex(l),this.setAttribute("position",new Mn(c,3)),this.setAttribute("normal",new Mn(u,3)),this.setAttribute("uv",new Mn(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ch(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class uh extends ch{constructor(t=1,e=1,i=32,s=1,r=!1,n=0,a=2*Math.PI){super(0,t,e,i,s,r,n,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:n,thetaLength:a}}static fromJSON(t){return new uh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class dh extends Bn{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const r=[],n=[];function a(t,e,i,s){const r=s+1,n=[];for(let s=0;s<=r;s++){n[s]=[];const a=t.clone().lerp(i,s/r),o=e.clone().lerp(i,s/r),h=r-s;for(let t=0;t<=h;t++)n[s][t]=0===t&&s===r?a:a.clone().lerp(o,t/h)}for(let t=0;t.9&&a<.1&&(e<.2&&(n[t+0]+=1),i<.2&&(n[t+2]+=1),s<.2&&(n[t+4]+=1))}}()}(),this.setAttribute("position",new Mn(r,3)),this.setAttribute("normal",new Mn(r.slice(),3)),this.setAttribute("uv",new Mn(n,2)),0===s?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dh(t.vertices,t.indices,t.radius,t.details)}}class ph extends dh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ph(t.radius,t.detail)}}const mh=new Qi,yh=new Qi,gh=new Qi,fh=new Yr;class xh extends Bn{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,s=Math.pow(10,i),r=Math.cos(Wi*e),n=t.getIndex(),a=t.getAttribute("position"),o=n?n.count:a.count,h=[0,0,0],l=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t0)){h=s;break}h=s-1}if(s=h,i[s]===n)return s/(r-1);const l=i[s];return(s+(n-l)/(i[s+1]-l))/(r-1)}getTangent(t,e){const i=1e-4;let s=t-i,r=t+i;s<0&&(s=0),r>1&&(r=1);const n=this.getPoint(s),a=this.getPoint(r),o=e||(n.isVector2?new Gi:new Qi);return o.copy(a).sub(n).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){const i=new Qi,s=[],r=[],n=[],a=new Qi,o=new or;for(let e=0;e<=t;e++){const i=e/t;s[e]=this.getTangentAt(i,new Qi)}r[0]=new Qi,n[0]=new Qi;let h=Number.MAX_VALUE;const l=Math.abs(s[0].x),c=Math.abs(s[0].y),u=Math.abs(s[0].z);l<=h&&(h=l,i.set(1,0,0)),c<=h&&(h=c,i.set(0,1,0)),u<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],a),n[0].crossVectors(s[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),n[e]=n[e-1].clone(),a.crossVectors(s[e-1],s[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Hi(s[e-1].dot(s[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}n[e].crossVectors(s[e],r[e])}if(!0===e){let e=Math.acos(Hi(r[0].dot(r[t]),-1,1));e/=t,s[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(s[i],e*i)),n[i].crossVectors(s[i],r[i])}return{tangents:s,normals:r,binormals:n}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class vh extends bh{constructor(t=0,e=0,i=1,s=1,r=0,n=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new Gi){const i=e,s=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const n=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?a=s[(h-1)%r]:(Sh.subVectors(s[0],s[1]).add(s[0]),a=Sh);const c=s[h%r],u=s[(h+1)%r];if(this.closed||h+2s.length-2?s.length-1:n+1],c=s[n>s.length-3?s.length-1:n+2];return i.set(Ih(a,o.x,h.x,l.x,c.x),Ih(a,o.y,h.y,l.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){const t=s[r]-i,n=this.curves[r],a=n.getLength(),o=0===a?0:1-t/a;return n.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,s=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){const t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Wh extends jh{constructor(t){super(t),this.uuid=Di(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,s=this.holes.length;i80*i){o=1/0,h=1/0;let e=-1/0,s=-1/0;for(let n=i;ne&&(e=i),r>s&&(s=r)}l=Math.max(e-o,s-h),l=0!==l?32767/l:0}return qh(n,a,i,o,h,l,0),a}function Dh(t,e,i,s,r){let n;if(r===function(t,e,i,s){let r=0;for(let n=e,a=i-s;n0)for(let r=e;r=e;r-=s)n=ul(r/s|0,t[r],t[r+1],n);return n&&nl(n,n.next)&&(dl(n),n=n.next),n}function Hh(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!nl(s,s.next)&&0!==rl(s.prev,s,s.next))s=s.next;else{if(dl(s),s=e=s.prev,s===s.next)break;i=!0}}while(i||s!==e);return e}function qh(t,e,i,s,r,n,a){if(!t)return;!a&&n&&function(t,e,i,s){let r=t;do{0===r.z&&(r.z=Kh(r.x,r.y,e,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let s,r=t;t=null;let n=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t0||h>0&&a;)0!==o&&(0===h||!a||r.z<=a.z)?(s=r,r=r.nextZ,o--):(s=a,a=a.nextZ,h--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=a}n.nextZ=null,i*=2}while(e>1)}(r)}(t,s,r,n);let o=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(n?Xh(t,s,r,n):Jh(t))e.push(h.i,t.i,l.i),dl(t),t=l.next,o=l.next;else if((t=l)===o){a?1===a?qh(t=Yh(Hh(t),e),e,i,s,r,n,2):2===a&&Zh(t,e,i,s,r,n):qh(Hh(t),e,i,s,r,n,1);break}}}function Jh(t){const e=t.prev,i=t,s=t.next;if(rl(e,i,s)>=0)return!1;const r=e.x,n=i.x,a=s.x,o=e.y,h=i.y,l=s.y,c=Math.min(r,n,a),u=Math.min(o,h,l),d=Math.max(r,n,a),p=Math.max(o,h,l);let m=s.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&il(r,o,n,h,a,l,m.x,m.y)&&rl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Xh(t,e,i,s){const r=t.prev,n=t,a=t.next;if(rl(r,n,a)>=0)return!1;const o=r.x,h=n.x,l=a.x,c=r.y,u=n.y,d=a.y,p=Math.min(o,h,l),m=Math.min(c,u,d),y=Math.max(o,h,l),g=Math.max(c,u,d),f=Kh(p,m,e,i,s),x=Kh(y,g,e,i,s);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=f&&v&&v.z<=x;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&rl(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&rl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=f;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&rl(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&rl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Yh(t,e){let i=t;do{const s=i.prev,r=i.next.next;!nl(s,r)&&al(s,i,i.next,r)&&ll(s,r)&&ll(r,s)&&(e.push(s.i,i.i,r.i),dl(i),dl(i.next),i=t=r),i=i.next}while(i!==t);return Hh(i)}function Zh(t,e,i,s,r,n){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&sl(a,t)){let o=cl(a,t);return a=Hh(a,a.next),o=Hh(o,o.next),qh(a,e,i,s,r,n,0),void qh(o,e,i,s,r,n,0)}t=t.next}a=a.next}while(a!==t)}function Gh(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function $h(t,e){const i=function(t,e){let i=e;const s=t.x,r=t.y;let n,a=-1/0;if(nl(t,i))return i;do{if(nl(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>a&&(a=t,n=i.x=i.x&&i.x>=h&&s!==i.x&&el(rn.x||i.x===n.x&&Qh(n,i)))&&(n=i,c=e)}i=i.next}while(i!==o);return n}(t,e);if(!i)return e;const s=cl(i,t);return Hh(s,s.next),Hh(i,i.next)}function Qh(t,e){return rl(t.prev,t,e.prev)<0&&rl(e.next,t,t.next)<0}function Kh(t,e,i,s,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function tl(t){let e=t,i=t;do{(e.x=(t-a)*(n-o)&&(t-a)*(s-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(r-a)*(s-o)}function il(t,e,i,s,r,n,a,o){return!(t===a&&e===o)&&el(t,e,i,s,r,n,a,o)}function sl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&al(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(ll(t,e)&&ll(e,t)&&function(t,e){let i=t,s=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(rl(t.prev,t,e.prev)||rl(t,e.prev,e))||nl(t,e)&&rl(t.prev,t,t.next)>0&&rl(e.prev,e,e.next)>0)}function rl(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function nl(t,e){return t.x===e.x&&t.y===e.y}function al(t,e,i,s){const r=hl(rl(t,e,i)),n=hl(rl(t,e,s)),a=hl(rl(i,s,t)),o=hl(rl(i,s,e));return r!==n&&a!==o||(!(0!==r||!ol(t,i,e))||(!(0!==n||!ol(t,s,e))||(!(0!==a||!ol(i,t,s))||!(0!==o||!ol(i,e,s)))))}function ol(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hl(t){return t>0?1:t<0?-1:0}function ll(t,e){return rl(t.prev,t,t.next)<0?rl(t,e,t.next)>=0&&rl(t,t.prev,e)>=0:rl(t,e,t.prev)<0||rl(t,t.next,e)<0}function cl(t,e){const i=pl(t.i,t.x,t.y),s=pl(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function ul(t,e,i,s){const r=pl(t,e,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function dl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function pl(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ml{static triangulate(t,e,i=2){return Uh(t,e,i)}}class yl{static area(t){const e=t.length;let i=0;for(let s=e-1,r=0;r2&&t[e-1].equals(t[0])&&t.pop()}function fl(t,e){for(let i=0;iNumber.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(h*h+l*l),p=e.x-o/u,m=e.y+a/u,y=((i.x-l/d-p)*l-(i.y+h/d-m)*h)/(a*l-o*h);s=p+a*y-t.x,r=m+o*y-t.y;const g=s*s+r*r;if(g<=2)return new Gi(s,r);n=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?h>Number.EPSILON&&(t=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(l)&&(t=!0),t?(s=-o,r=a,n=Math.sqrt(c)):(s=a,r=o,n=Math.sqrt(c/2))}return new Gi(s/n,r/n)}const k=[];for(let t=0,e=z.length,i=e-1,s=t+1;t=0;t--){const e=t/p,i=c*Math.cos(e*Math.PI/2),s=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=z.length;t=0;){const s=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=o+2*p;t0)&&d.push(e,r,h),(t!==i-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Vl extends sn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Kr(16777215),this.specular=new Kr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,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.flatShading=t.flatShading,this.fog=t.fog,this}}class Ll extends sn{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class jl extends sn{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Wl extends sn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Kr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,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(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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,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.flatShading=t.flatShading,this.fog=t.fog,this}}class Ul extends sn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Dl extends sn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Hl extends sn{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Kr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ql extends Eo{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Jl(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Xl(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Yl(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i}function Zl(t,e,i){const s=t.length,r=new t.constructor(s);for(let n=0,a=0;a!==s;++n){const s=i[n]*e;for(let i=0;i!==e;++i)r[a++]=t[s+i]}return r}function Gl(t,e,i,s){let r=1,n=t[0];for(;void 0!==n&&void 0===n[s];)n=t[r++];if(void 0===n)return;let a=n[s];if(void 0!==a)if(Array.isArray(a))do{a=n[s],void 0!==a&&(e.push(n.time),i.push(...a)),n=t[r++]}while(void 0!==n);else if(void 0!==a.toArray)do{a=n[s],void 0!==a&&(e.push(n.time),a.toArray(i,i.length)),n=t[r++]}while(void 0!==n);else do{a=n[s],void 0!==a&&(e.push(n.time),i.push(a)),n=t[r++]}while(void 0!==n)}class $l{static convertArray(t,e){return Jl(t,e)}static isTypedArray(t){return Xl(t)}static getKeyframeOrder(t){return Yl(t)}static sortedArray(t,e,i){return Zl(t,e,i)}static flattenJSON(t,e,i,s){Gl(t,e,i,s)}static subclip(t,e,i,s,r=30){return function(t,e,i,s,r=30){const n=t.clone();n.name=e;const a=[];for(let t=0;t=s)){h.push(e.times[t]);for(let i=0;in.tracks[t].times[0]&&(o=n.tracks[t].times[0]);for(let t=0;t=s.times[u]){const t=u*h+o,e=t+h-o;d=s.values.slice(t,e)}else{const t=s.createInterpolant(),e=o,i=h-o;t.evaluate(n),d=t.resultBuffer.slice(e,i)}"quaternion"===r&&(new $i).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}n=i,i=0}}for(;i>>1;te;)--n;if(++n,0!==r||n!==s){r>=n&&(n=Math.max(n,1),r=n-1);const t=this.getValueSize();this.times=i.slice(r,n),this.values=this.values.slice(r*t,n*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,s=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let n=null;for(let e=0;e!==r;e++){const s=i[e];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,s),t=!1;break}if(null!==n&&n>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,s,n),t=!1;break}n=s}if(void 0!==s&&Xl(s))for(let e=0,i=s.length;e!==i;++e){const i=s[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===Re,r=t.length-1;let n=1;for(let a=1;a0){t[n]=t[r];for(let t=r*i,s=n*i,a=0;a!==i;++a)e[s+a]=e[t+a];++n}return n!==t.length?(this.times=t.slice(0,n),this.values=e.slice(0,n*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ic.prototype.ValueTypeName="",ic.prototype.TimeBufferType=Float32Array,ic.prototype.ValueBufferType=Float32Array,ic.prototype.DefaultInterpolation=ke;class sc extends ic{constructor(t,e,i){super(t,e,i)}}sc.prototype.ValueTypeName="bool",sc.prototype.ValueBufferType=Array,sc.prototype.DefaultInterpolation=Be,sc.prototype.InterpolantFactoryMethodLinear=void 0,sc.prototype.InterpolantFactoryMethodSmooth=void 0;class rc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}rc.prototype.ValueTypeName="color";class nc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}nc.prototype.ValueTypeName="number";class ac extends Ql{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e);let h=t*a;for(let t=h+a;h!==t;h+=4)$i.slerpFlat(r,0,n,h-a,n,h,o);return r}}class oc extends ic{constructor(t,e,i,s){super(t,e,i,s)}InterpolantFactoryMethodLinear(t){return new ac(this.times,this.values,this.getValueSize(),t)}}oc.prototype.ValueTypeName="quaternion",oc.prototype.InterpolantFactoryMethodSmooth=void 0;class hc extends ic{constructor(t,e,i){super(t,e,i)}}hc.prototype.ValueTypeName="string",hc.prototype.ValueBufferType=Array,hc.prototype.DefaultInterpolation=Be,hc.prototype.InterpolantFactoryMethodLinear=void 0,hc.prototype.InterpolantFactoryMethodSmooth=void 0;class lc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}lc.prototype.ValueTypeName="vector";class cc{constructor(t="",e=-1,i=[],s=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=Di(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,s=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(uc(i[t]).scale(s));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,s=i.length;t!==s;++t)e.push(ic.toJSON(i[t]));return s}static CreateFromMorphTargetSequence(t,e,i,s){const r=e.length,n=[];for(let t=0;t1){const t=n[1];let e=s[t];e||(s[t]=e=[]),e.push(i)}}const n=[];for(const t in s)n.push(this.CreateFromMorphTargetSequence(t,s[t],e,i));return n}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,s,r){if(0!==i.length){const n=[],a=[];Gl(i,n,a,s),0!==n.length&&r.push(new t(e,n,a))}},s=[],r=t.name||"default",n=t.fps||30,a=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==gc[t])return void gc[t].push({onLoad:e,onProgress:i,onError:s});gc[t]=[],gc[t].push({onLoad:e,onProgress:i,onError:s});const n=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=gc[t],s=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),n=r?parseInt(r):0,a=0!==n;let o=0;const h=new ReadableStream({start(t){!function e(){s.read().then((({done:s,value:r})=>{if(s)t.close();else{o+=r.byteLength;const s=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:n});for(let t=0,e=i.length;t{t.error(e)}))}()}});return new Response(h)}throw new fc(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(""===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,s=new TextDecoder(i);return t.arrayBuffer().then((t=>s.decode(t)))}}})).then((e=>{dc.add(t,e);const i=gc[t];delete gc[t];for(let t=0,s=i.length;t{const i=gc[t];if(void 0===i)throw this.manager.itemError(t),e;delete gc[t];for(let t=0,s=i.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class bc extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):console.error(e),r.manager.itemError(t)}}),i,s)}parse(t){const e=[];for(let i=0;i0:s.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(s.uniforms[e]={},r.type){case"t":s.uniforms[e].value=i(r.value);break;case"c":s.uniforms[e].value=(new Kr).setHex(r.value);break;case"v2":s.uniforms[e].value=(new Gi).fromArray(r.value);break;case"v3":s.uniforms[e].value=(new Qi).fromArray(r.value);break;case"v4":s.uniforms[e].value=(new zs).fromArray(r.value);break;case"m3":s.uniforms[e].value=(new es).fromArray(r.value);break;case"m4":s.uniforms[e].value=(new or).fromArray(r.value);break;default:s.uniforms[e].value=r.value}}if(void 0!==t.defines&&(s.defines=t.defines),void 0!==t.vertexShader&&(s.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(s.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(s.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)s.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(s.lights=t.lights),void 0!==t.clipping&&(s.clipping=t.clipping),void 0!==t.size&&(s.size=t.size),void 0!==t.sizeAttenuation&&(s.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(s.map=i(t.map)),void 0!==t.matcap&&(s.matcap=i(t.matcap)),void 0!==t.alphaMap&&(s.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(s.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(s.bumpScale=t.bumpScale),void 0!==t.normalMap&&(s.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(s.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),s.normalScale=(new Gi).fromArray(e)}return void 0!==t.displacementMap&&(s.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(s.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(s.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(s.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(s.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(s.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(s.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(s.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(s.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(s.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(s.envMap=i(t.envMap)),void 0!==t.envMapRotation&&s.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(s.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(s.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(s.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(s.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(s.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(s.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(s.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(s.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(s.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(s.clearcoatNormalScale=(new Gi).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(s.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(s.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(s.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(s.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(s.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return qc.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Pl,SpriteMaterial:ma,RawShaderMaterial:Ol,ShaderMaterial:Zn,PointsMaterial:Xo,MeshPhysicalMaterial:Fl,MeshStandardMaterial:Nl,MeshPhongMaterial:Vl,MeshToonMaterial:Ll,MeshNormalMaterial:jl,MeshLambertMaterial:Wl,MeshDepthMaterial:Ul,MeshDistanceMaterial:Dl,MeshBasicMaterial:rn,MeshMatcapMaterial:Hl,LineDashedMaterial:ql,LineBasicMaterial:Eo,Material:sn}[t]}}class Jc{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Xc extends Bn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Yc extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):console.error(e),r.manager.itemError(t)}}),i,s)}parse(t){const e={},i={};function s(t,s){if(void 0!==e[s])return e[s];const r=t.interleavedBuffers[s],n=function(t,e){if(void 0!==i[e])return i[e];const s=t.arrayBuffers,r=s[e],n=new Uint32Array(r).buffer;return i[e]=n,n}(t,r.buffer),a=ns(r.type,n),o=new ua(a,r.stride);return o.uuid=r.uuid,e[s]=o,o}const r=t.isInstancedBufferGeometry?new Xc:new Bn,n=t.data.index;if(void 0!==n){const t=ns(n.type,n.array);r.setIndex(new pn(t,1))}const a=t.data.attributes;for(const e in a){const i=a[e];let n;if(i.isInterleavedBufferAttribute){const e=s(t.data,i.data);n=new pa(e,i.itemSize,i.offset,i.normalized)}else{const t=ns(i.type,i.array);n=new(i.isInstancedBufferAttribute?Ya:pn)(t,i.itemSize,i.normalized)}void 0!==i.name&&(n.name=i.name),void 0!==i.usage&&n.setUsage(i.usage),r.setAttribute(e,n)}const o=t.data.morphAttributes;if(o)for(const e in o){const i=o[e],n=[];for(let e=0,r=i.length;e0){const i=new pc(e);r=new wc(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){s=new wc(this.manager),s.setCrossOrigin(this.crossOrigin);for(let e=0,s=t.length;e{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Ps).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new Qs).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}})),n._instanceInfo=t.instanceInfo,n._availableInstanceIds=t._availableInstanceIds,n._availableGeometryIds=t._availableGeometryIds,n._nextIndexStart=t.nextIndexStart,n._nextVertexStart=t.nextVertexStart,n._geometryCount=t.geometryCount,n._maxInstanceCount=t.maxInstanceCount,n._maxVertexCount=t.maxVertexCount,n._maxIndexCount=t.maxIndexCount,n._geometryInitialized=t.geometryInitialized,n._matricesTexture=c(t.matricesTexture.uuid),n._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(n._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(n.boundingSphere=(new Qs).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(n.boundingBox=(new Ps).fromJSON(t.boundingBox));break;case"LOD":n=new Ra;break;case"Line":n=new Wo(h(t.geometry),l(t.material));break;case"LineLoop":n=new Jo(h(t.geometry),l(t.material));break;case"LineSegments":n=new qo(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":n=new Qo(h(t.geometry),l(t.material));break;case"Sprite":n=new Ia(l(t.material));break;case"Group":n=new na;break;case"Bone":n=new Da;break;default:n=new Pr}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.up&&n.up.fromArray(t.up),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(n.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(n.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{if(!0!==Kc.has(n))return e&&e(i),r.manager.itemEnd(t),i;s&&s(Kc.get(n)),r.manager.itemError(t),r.manager.itemEnd(t)})):(setTimeout((function(){e&&e(n),r.manager.itemEnd(t)}),0),n);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){return dc.add(t,i),e&&e(i),r.manager.itemEnd(t),i})).catch((function(e){s&&s(e),Kc.set(o,e),dc.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));dc.add(t,o),r.manager.itemStart(t)}}let eu;class iu{static getContext(){return void 0===eu&&(eu=new(window.AudioContext||window.webkitAudioContext)),eu}static setContext(t){eu=t}}class su extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(this.manager);function a(e){s?s(e):console.error(e),r.manager.itemError(t)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,(function(t){try{const i=t.slice(0);iu.getContext().decodeAudioData(i,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),i,s)}}const ru=new or,nu=new or,au=new or;class ou{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ta,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ta,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,au.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,r=e.near*Math.tan(Wi*e.fov*.5)/e.zoom;let n,a;nu.elements[12]=-i,ru.elements[12]=i,n=-r*e.aspect+s,a=r*e.aspect+s,au.elements[0]=2*e.near/(a-n),au.elements[8]=(a+n)/(a-n),this.cameraL.projectionMatrix.copy(au),n=-r*e.aspect-s,a=r*e.aspect-s,au.elements[0]=2*e.near/(a-n),au.elements[8]=(a+n)/(a-n),this.cameraR.projectionMatrix.copy(au)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(nu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(ru)}}class hu extends ta{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class lu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=cu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=cu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function cu(){return performance.now()}const uu=new Qi,du=new $i,pu=new Qi,mu=new Qi,yu=new Qi;class gu extends Pr{constructor(){super(),this.type="AudioListener",this.context=iu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new lu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(uu,du,pu),mu.set(0,0,-1).applyQuaternion(du),yu.set(0,1,0).applyQuaternion(du),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(uu.x,t),e.positionY.linearRampToValueAtTime(uu.y,t),e.positionZ.linearRampToValueAtTime(uu.z,t),e.forwardX.linearRampToValueAtTime(mu.x,t),e.forwardY.linearRampToValueAtTime(mu.y,t),e.forwardZ.linearRampToValueAtTime(mu.z,t),e.upX.linearRampToValueAtTime(yu.x,t),e.upY.linearRampToValueAtTime(yu.y,t),e.upZ.linearRampToValueAtTime(yu.z,t)}else e.setPosition(uu.x,uu.y,uu.z),e.setOrientation(mu.x,mu.y,mu.z,yu.x,yu.y,yu.z)}}class fu extends Pr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,s);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let t=i,r=s;t!==r;++t)e[t]=e[s+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let s=0;s!==r;++s)t[e+s]=t[i+s]}_slerp(t,e,i,s){$i.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,r){const n=this._workIndex*r;$i.multiplyQuaternionsFlat(t,n,t,e,t,i),$i.slerpFlat(t,e,t,e,t,n,s)}_lerp(t,e,i,s,r){const n=1-s;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*n+t[i+a]*s}}_lerpAdditive(t,e,i,s,r){for(let n=0;n!==r;++n){const r=e+n;t[r]=t[r]+t[i+n]*s}}}const Au="\\[\\]\\.:\\/",Tu=new RegExp("["+Au+"]","g"),zu="[^"+Au+"]",Iu="[^"+Au.replace("\\.","")+"]",Cu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",zu)+/(WCOD+)?/.source.replace("WCOD",Iu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",zu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",zu)+"$"),Bu=["material","materials","bones","map"];class ku{constructor(t,e,i){this.path=e,this.parsedPath=i||ku.parseTrackName(e),this.node=ku.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new ku.Composite(t,e,i):new ku(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Tu,"")}static parseTrackName(t){const e=Cu.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){const t=i.nodeName.substring(s+1);-1!==Bu.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let s=0;s=r){const n=r++,l=t[n];e[l.uuid]=h,t[h]=l,e[o]=n,t[n]=a;for(let t=0,e=s;t!==e;++t){const e=i[t],s=e[n],r=e[h];e[h]=s,e[n]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length;let r=this.nCachedObjects_,n=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=s;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let s=i[t];const r=this._bindings;if(void 0!==s)return r[s];const n=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);s=r.length,i[t]=s,n.push(t),a.push(e),r.push(c);for(let i=l,s=o.length;i!==s;++i){const s=o[i];c[i]=new ku(s,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const s=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length-1,o=n[a];e[t[a]]=i,n[i]=o,n.pop(),r[i]=r[a],r.pop(),s[i]=s[a],s.pop()}}}class Eu{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const r=e.tracks,n=r.length,a=new Array(n),o={endingStart:Ee,endingEnd:Ee};for(let t=0;t!==n;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),!0===i){const i=this._clip.duration,s=t._clip.duration,r=s/i,n=i/s;t.warp(1,r,e),this.warp(n,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const s=this._mixer,r=s.time,n=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=t/n,h[1]=e/n,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const s=(t-r)*i;s<0||0===i?e=0:(this._startTime=null,e=i*s)}e*=this._updateTimeScale(t);const n=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Fe)for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(n),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(n),e[i].accumulate(s,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let s=this.time+t,r=this._loopCount;const n=2202===i;if(0===t)return-1===r||!n||1&~r?s:e-s;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else{if(!(s<0)){this.time=s;break t}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),s>=e||s<0){const i=Math.floor(s/e);s-=e*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=s;if(n&&!(1&~r))return e-s}return s}_setEndings(t,e,i){const s=this._interpolantSettings;i?(s.endingStart=Pe,s.endingEnd=Pe):(s.endingStart=t?this.zeroSlopeAtStart?Pe:Ee:Oe,s.endingEnd=e?this.zeroSlopeAtEnd?Pe:Ee:Oe)}_scheduleFading(t,e,i){const s=this._mixer,r=s.time;let n=this._weightInterpolant;null===n&&(n=s._lendControlInterpolant(),this._weightInterpolant=n);const a=n.parameterPositions,o=n.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}const Pu=new Float32Array(1);class Ou extends Vi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,s=t._clip.tracks,r=s.length,n=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=s[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,n[t]=c;else{if(c=n[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const s=e&&e._propertyBindings[t].binding.parsedPath;c=new _u(ku.create(i,h,s),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),n[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,s=this.time+=t,r=Math.sign(t),n=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(s,t,r,n)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(n);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}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}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Zu).distanceTo(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}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)}}const $u=new Qi,Qu=new Qi;class Ku{constructor(t=new Qi,e=new Qi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){$u.subVectors(t,this.start),Qu.subVectors(this.end,this.start);const i=Qu.dot(Qu);let s=Qu.dot($u)/i;return e&&(s=Hi(s,0,1)),s}closestPointToPoint(t,e,i){const s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const td=new Qi;class ed extends Pr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Bn,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t1)for(let i=0;i.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Td.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Td,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Bd extends qo{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Bn;i.setAttribute("position",new Mn(e,3)),i.setAttribute("color",new Mn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new Eo({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const s=new Kr,r=this.geometry.attributes.color.array;return s.set(t),s.toArray(r,0),s.toArray(r,3),s.set(e),s.toArray(r,6),s.toArray(r,9),s.set(i),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class kd{constructor(){this.type="ShapePath",this.color=new Kr,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new jh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,r,n){return this.currentPath.bezierCurveTo(t,e,i,s,r,n),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let s=!1;for(let r=i-1,n=0;nNumber.EPSILON){if(h<0&&(i=e[n],o=-o,a=e[r],h=-h),t.ya.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;s=!s}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return s}const i=yl.isClockWise,s=this.subPaths;if(0===s.length)return[];let r,n,a;const o=[];if(1===s.length)return n=s[0],a=new Wh,a.curves=n.curves,o.push(a),o;let h=!i(s[0].getPoints());h=t?!h:h;const l=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=s.length;e1){let t=!1,i=0;for(let t=0,e=c.length;t0&&!1===t&&(p=l)}for(let t=0,e=c.length;te?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,s){return Ed(t,e,i,s)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);export{et as ACESFilmicToneMapping,v as AddEquation,G as AddOperation,Fe as AdditiveAnimationBlendMode,g as AdditiveBlending,st as AgXToneMapping,Vt as AlphaFormat,wi as AlwaysCompare,W as AlwaysDepth,pi as AlwaysStencilFunc,Wc as AmbientLight,Eu as AnimationAction,cc as AnimationClip,bc as AnimationLoader,Ou as AnimationMixer,Ru as AnimationObjectGroup,$l as AnimationUtils,wh as ArcCurve,hu as ArrayCamera,Cd as ArrowHelper,nt as AttachedBindMode,fu as Audio,Su as AudioAnalyser,iu as AudioContext,gu as AudioListener,su as AudioLoader,Bd as AxesHelper,d as BackSide,We as BasicDepthPacking,o as BasicShadowMap,Ro as BatchedMesh,Da as Bone,sc as BooleanKeyframeTrack,Gu as Box2,Ps as Box3,_d as Box3Helper,Hn as BoxGeometry,Sd as BoxHelper,pn as BufferAttribute,Bn as BufferGeometry,Yc as BufferGeometryLoader,zt as ByteType,dc as Cache,Gn as Camera,vd as CameraHelper,ah as CanvasTexture,hh as CapsuleGeometry,zh as CatmullRomCurve3,tt as CineonToneMapping,lh as CircleGeometry,mt as ClampToEdgeWrapping,lu as Clock,Kr as Color,rc as ColorKeyframeTrack,gs as ColorManagement,rh as CompressedArrayTexture,nh as CompressedCubeTexture,sh as CompressedTexture,vc as CompressedTextureLoader,uh as ConeGeometry,V as ConstantAlphaFactor,N as ConstantColorFactor,Rd as Controls,ia as CubeCamera,ht as CubeReflectionMapping,lt as CubeRefractionMapping,sa as CubeTexture,Mc as CubeTextureLoader,dt as CubeUVReflectionMapping,kh as CubicBezierCurve,Rh as CubicBezierCurve3,Kl as CubicInterpolant,r as CullFaceBack,n as CullFaceFront,a as CullFaceFrontBack,s as CullFaceNone,bh as Curve,Lh as CurvePath,b as CustomBlending,it as CustomToneMapping,ch as CylinderGeometry,Xu as Cylindrical,Rs as Data3DTexture,Bs as DataArrayTexture,Ha as DataTexture,Sc as DataTextureLoader,ln as DataUtils,ii as DecrementStencilOp,ri as DecrementWrapStencilOp,mc as DefaultLoadingManager,Wt as DepthFormat,Ut as DepthStencilFormat,oh as DepthTexture,at as DetachedBindMode,jc as DirectionalLight,fd as DirectionalLightHelper,ec as DiscreteInterpolant,ph as DodecahedronGeometry,p as DoubleSide,k as DstAlphaFactor,E as DstColorFactor,Ci as DynamicCopyUsage,Si as DynamicDrawUsage,Ti as DynamicReadUsage,xh as EdgesGeometry,vh as EllipseCurve,gi as EqualCompare,H as EqualDepth,hi as EqualStencilFunc,ct as EquirectangularReflectionMapping,ut as EquirectangularRefractionMapping,fr as Euler,Vi as EventDispatcher,xl as ExtrudeGeometry,xc as FileLoader,wn as Float16BufferAttribute,Mn as Float32BufferAttribute,Rt as FloatType,la as Fog,ha as FogExp2,ih as FramebufferTexture,u as FrontSide,lo as Frustum,po as FrustumArray,Wu as GLBufferAttribute,ki as GLSL1,Ri as GLSL3,xi as GreaterCompare,J as GreaterDepth,vi as GreaterEqualCompare,q as GreaterEqualDepth,di as GreaterEqualStencilFunc,ci as GreaterStencilFunc,dd as GridHelper,na as Group,Et as HalfFloatType,Tc as HemisphereLight,ud as HemisphereLightHelper,vl as IcosahedronGeometry,tu as ImageBitmapLoader,wc as ImageLoader,vs as ImageUtils,ei as IncrementStencilOp,si as IncrementWrapStencilOp,Ya as InstancedBufferAttribute,Xc as InstancedBufferGeometry,ju as InstancedInterleavedBuffer,io as InstancedMesh,fn as Int16BufferAttribute,bn as Int32BufferAttribute,mn as Int8BufferAttribute,Bt as IntType,ua as InterleavedBuffer,pa as InterleavedBufferAttribute,Ql as Interpolant,Be as InterpolateDiscrete,ke as InterpolateLinear,Re as InterpolateSmooth,Fi as InterpolationSamplingMode,Ni as InterpolationSamplingType,ni as InvertStencilOp,Ke as KeepStencilOp,ic as KeyframeTrack,Ra as LOD,wl as LatheGeometry,xr as Layers,yi as LessCompare,U as LessDepth,fi as LessEqualCompare,D as LessEqualDepth,li as LessEqualStencilFunc,oi as LessStencilFunc,Ac as Light,Hc as LightProbe,Wo as Line,Ku as Line3,Eo as LineBasicMaterial,Eh as LineCurve,Ph as LineCurve3,ql as LineDashedMaterial,Jo as LineLoop,qo as LineSegments,wt as LinearFilter,tc as LinearInterpolant,At as LinearMipMapLinearFilter,St as LinearMipMapNearestFilter,_t as LinearMipmapLinearFilter,Mt as LinearMipmapNearestFilter,Ze as LinearSRGBColorSpace,Q as LinearToneMapping,Ge as LinearTransfer,yc as Loader,Jc as LoaderUtils,pc as LoadingManager,ze as LoopOnce,Ce as LoopPingPong,Ie as LoopRepeat,e as MOUSE,sn as Material,qc as MaterialLoader,Zi as MathUtils,Yu as Matrix2,es as Matrix3,or as Matrix4,_ as MaxEquation,Un as Mesh,rn as MeshBasicMaterial,Ul as MeshDepthMaterial,Dl as MeshDistanceMaterial,Wl as MeshLambertMaterial,Hl as MeshMatcapMaterial,jl as MeshNormalMaterial,Vl as MeshPhongMaterial,Fl as MeshPhysicalMaterial,Nl as MeshStandardMaterial,Ll as MeshToonMaterial,S as MinEquation,yt as MirroredRepeatWrapping,Z as MixOperation,x as MultiplyBlending,Y as MultiplyOperation,gt as NearestFilter,vt as NearestMipMapLinearFilter,xt as NearestMipMapNearestFilter,bt as NearestMipmapLinearFilter,ft as NearestMipmapNearestFilter,rt as NeutralToneMapping,mi as NeverCompare,j as NeverDepth,ai as NeverStencilFunc,m as NoBlending,Xe as NoColorSpace,$ as NoToneMapping,Ne as NormalAnimationBlendMode,y as NormalBlending,bi as NotEqualCompare,X as NotEqualDepth,ui as NotEqualStencilFunc,nc as NumberKeyframeTrack,Pr as Object3D,Zc as ObjectLoader,Je as ObjectSpaceNormalMap,Ml as OctahedronGeometry,T as OneFactor,L as OneMinusConstantAlphaFactor,F as OneMinusConstantColorFactor,R as OneMinusDstAlphaFactor,P as OneMinusDstColorFactor,B as OneMinusSrcAlphaFactor,I as OneMinusSrcColorFactor,Vc as OrthographicCamera,h as PCFShadowMap,l as PCFSoftShadowMap,jh as Path,ta as PerspectiveCamera,ao as Plane,Sl as PlaneGeometry,Ad as PlaneHelper,Fc as PointLight,od as PointLightHelper,Qo as Points,Xo as PointsMaterial,pd as PolarGridHelper,dh as PolyhedronGeometry,Mu as PositionalAudio,ku as PropertyBinding,_u as PropertyMixer,Oh as QuadraticBezierCurve,Nh as QuadraticBezierCurve3,$i as Quaternion,oc as QuaternionKeyframeTrack,ac as QuaternionLinearInterpolant,Ui as RAD2DEG,Ae as RED_GREEN_RGTC2_Format,Se as RED_RGTC1_Format,t as REVISION,Ue as RGBADepthPacking,jt as RGBAFormat,Yt as RGBAIntegerFormat,fe as RGBA_ASTC_10x10_Format,me as RGBA_ASTC_10x5_Format,ye as RGBA_ASTC_10x6_Format,ge as RGBA_ASTC_10x8_Format,xe as RGBA_ASTC_12x10_Format,be as RGBA_ASTC_12x12_Format,ae as RGBA_ASTC_4x4_Format,oe as RGBA_ASTC_5x4_Format,he as RGBA_ASTC_5x5_Format,le as RGBA_ASTC_6x5_Format,ce as RGBA_ASTC_6x6_Format,ue as RGBA_ASTC_8x5_Format,de as RGBA_ASTC_8x6_Format,pe as RGBA_ASTC_8x8_Format,ve as RGBA_BPTC_Format,ne as RGBA_ETC2_EAC_Format,ie as RGBA_PVRTC_2BPPV1_Format,ee as RGBA_PVRTC_4BPPV1_Format,Gt as RGBA_S3TC_DXT1_Format,$t as RGBA_S3TC_DXT3_Format,Qt as RGBA_S3TC_DXT5_Format,De as RGBDepthPacking,Lt as RGBFormat,Xt as RGBIntegerFormat,we as RGB_BPTC_SIGNED_Format,Me as RGB_BPTC_UNSIGNED_Format,se as RGB_ETC1_Format,re as RGB_ETC2_Format,te as RGB_PVRTC_2BPPV1_Format,Kt as RGB_PVRTC_4BPPV1_Format,Zt as RGB_S3TC_DXT1_Format,He as RGDepthPacking,qt as RGFormat,Jt as RGIntegerFormat,Ol as RawShaderMaterial,ar as Ray,Du as Raycaster,Uc as RectAreaLight,Dt as RedFormat,Ht as RedIntegerFormat,K as ReinhardToneMapping,Is as RenderTarget,Nu as RenderTarget3D,pt as RepeatWrapping,ti as ReplaceStencilOp,M as ReverseSubtractEquation,_l as RingGeometry,Te as SIGNED_RED_GREEN_RGTC2_Format,_e as SIGNED_RED_RGTC1_Format,Ye as SRGBColorSpace,$e as SRGBTransfer,ca as Scene,Zn as ShaderMaterial,Pl as ShadowMaterial,Wh as Shape,Al as ShapeGeometry,kd as ShapePath,yl as ShapeUtils,It as ShortType,Xa as Skeleton,nd as SkeletonHelper,Ua as SkinnedMesh,Ms as Source,Qs as Sphere,Tl as SphereGeometry,Ju as Spherical,Dc as SphericalHarmonics3,Fh as SplineCurve,Rc as SpotLight,ed as SpotLightHelper,Ia as Sprite,ma as SpriteMaterial,C as SrcAlphaFactor,O as SrcAlphaSaturateFactor,z as SrcColorFactor,Ii as StaticCopyUsage,Mi as StaticDrawUsage,Ai as StaticReadUsage,ou as StereoCamera,Bi as StreamCopyUsage,_i as StreamDrawUsage,zi as StreamReadUsage,hc as StringKeyframeTrack,w as SubtractEquation,f as SubtractiveBlending,i as TOUCH,qe as TangentSpaceNormalMap,zl as TetrahedronGeometry,Ts as Texture,_c as TextureLoader,Pd as TextureUtils,Oi as TimestampQuery,Il as TorusGeometry,Cl as TorusKnotGeometry,Yr as Triangle,je as TriangleFanDrawMode,Le as TriangleStripDrawMode,Ve as TrianglesDrawMode,Bl as TubeGeometry,ot as UVMapping,xn as Uint16BufferAttribute,vn as Uint32BufferAttribute,yn as Uint8BufferAttribute,gn as Uint8ClampedBufferAttribute,Fu as Uniform,Lu as UniformsGroup,Yn as UniformsUtils,Tt as UnsignedByteType,Nt as UnsignedInt248Type,Ft as UnsignedInt5999Type,kt as UnsignedIntType,Pt as UnsignedShort4444Type,Ot as UnsignedShort5551Type,Ct as UnsignedShortType,c as VSMShadowMap,Gi as Vector2,Qi as Vector3,zs as Vector4,lc as VectorKeyframeTrack,eh as VideoFrameTexture,th as VideoTexture,Es as WebGL3DRenderTarget,ks as WebGLArrayRenderTarget,Ei as WebGLCoordinateSystem,ra as WebGLCubeRenderTarget,Cs as WebGLRenderTarget,Pi as WebGPUCoordinateSystem,oa as WebXRController,kl as WireframeGeometry,Oe as WrapAroundEnding,Ee as ZeroCurvatureEnding,A as ZeroFactor,Pe as ZeroSlopeEnding,Qe as ZeroStencilOp,ss as arrayNeedsUint32,qn as cloneUniforms,os as createCanvasElement,as as createElementNS,Ed as getByteLength,Xn as getUnlitUniformColorSpace,Jn as mergeUniforms,cs as probeAsync,us as toNormalizedProjectionMatrix,ds as toReversedProjectionMatrix,ls as warnOnce}; +const t="178dev",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},s=0,r=1,n=2,a=3,o=0,h=1,l=2,c=3,u=0,d=1,p=2,m=0,y=1,g=2,f=3,x=4,b=5,v=100,w=101,M=102,S=103,_=104,A=200,T=201,z=202,I=203,C=204,B=205,k=206,R=207,E=208,P=209,O=210,N=211,F=212,V=213,L=214,j=0,W=1,U=2,D=3,H=4,q=5,J=6,X=7,Y=0,Z=1,G=2,$=0,Q=1,K=2,tt=3,et=4,it=5,st=6,rt=7,nt="attached",at="detached",ot=300,ht=301,lt=302,ct=303,ut=304,dt=306,pt=1e3,mt=1001,yt=1002,gt=1003,ft=1004,xt=1004,bt=1005,vt=1005,wt=1006,Mt=1007,St=1007,_t=1008,At=1008,Tt=1009,zt=1010,It=1011,Ct=1012,Bt=1013,kt=1014,Rt=1015,Et=1016,Pt=1017,Ot=1018,Nt=1020,Ft=35902,Vt=1021,Lt=1022,jt=1023,Wt=1026,Ut=1027,Dt=1028,Ht=1029,qt=1030,Jt=1031,Xt=1032,Yt=1033,Zt=33776,Gt=33777,$t=33778,Qt=33779,Kt=35840,te=35841,ee=35842,ie=35843,se=36196,re=37492,ne=37496,ae=37808,oe=37809,he=37810,le=37811,ce=37812,ue=37813,de=37814,pe=37815,me=37816,ye=37817,ge=37818,fe=37819,xe=37820,be=37821,ve=36492,we=36494,Me=36495,Se=36283,_e=36284,Ae=36285,Te=36286,ze=2200,Ie=2201,Ce=2202,Be=2300,ke=2301,Re=2302,Ee=2400,Pe=2401,Oe=2402,Ne=2500,Fe=2501,Ve=0,Le=1,je=2,We=3200,Ue=3201,De=3202,He=3203,qe=0,Je=1,Xe="",Ye="srgb",Ze="srgb-linear",Ge="linear",$e="srgb",Qe=0,Ke=7680,ti=7681,ei=7682,ii=7683,si=34055,ri=34056,ni=5386,ai=512,oi=513,hi=514,li=515,ci=516,ui=517,di=518,pi=519,mi=512,yi=513,gi=514,fi=515,xi=516,bi=517,vi=518,wi=519,Mi=35044,Si=35048,_i=35040,Ai=35045,Ti=35049,zi=35041,Ii=35046,Ci=35050,Bi=35042,ki="100",Ri="300 es",Ei=2e3,Pi=2001,Oi={COMPUTE:"compute",RENDER:"render"},Ni={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Fi={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};class Vi{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const s=i[t];if(void 0!==s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,s=e.length;i>8&255]+Li[t>>16&255]+Li[t>>24&255]+"-"+Li[255&e]+Li[e>>8&255]+"-"+Li[e>>16&15|64]+Li[e>>24&255]+"-"+Li[63&i|128]+Li[i>>8&255]+"-"+Li[i>>16&255]+Li[i>>24&255]+Li[255&s]+Li[s>>8&255]+Li[s>>16&255]+Li[s>>24&255]).toLowerCase()}function Hi(t,e,i){return Math.max(e,Math.min(i,t))}function qi(t,e){return(t%e+e)%e}function Ji(t,e,i){return(1-i)*t+i*e}function Xi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Yi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Zi={DEG2RAD:Wi,RAD2DEG:Ui,generateUUID:Di,clamp:Hi,euclideanModulo:qi,mapLinear:function(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:Ji,damp:function(t,e,i,s){return Ji(t,e,1-Math.exp(-i*s))},pingpong:function(t,e=1){return e-Math.abs(qi(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(ji=t);let e=ji+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Wi},radToDeg:function(t){return t*Ui},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,s,r){const n=Math.cos,a=Math.sin,o=n(i/2),h=a(i/2),l=n((e+s)/2),c=a((e+s)/2),u=n((e-s)/2),d=a((e-s)/2),p=n((s-e)/2),m=a((s-e)/2);switch(r){case"XYX":t.set(o*c,h*u,h*d,o*l);break;case"YZY":t.set(h*d,o*c,h*u,o*l);break;case"ZXZ":t.set(h*u,h*d,o*c,o*l);break;case"XZX":t.set(o*c,h*m,h*p,o*l);break;case"YXY":t.set(h*p,o*c,h*m,o*l);break;case"ZYZ":t.set(h*m,h*p,o*c,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Yi,denormalize:Xi};class Gi{constructor(t=0,e=0){Gi.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,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[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=Hi(this.x,t.x,e.x),this.y=Hi(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Hi(this.x,t,e),this.y=Hi(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Hi(i,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(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Hi(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class $i{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,a){let o=i[s+0],h=i[s+1],l=i[s+2],c=i[s+3];const u=r[n+0],d=r[n+1],p=r[n+2],m=r[n+3];if(0===a)return t[e+0]=o,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||h!==d||l!==p){let t=1-a;const e=o*u+h*d+l*p+c*m,i=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const r=Math.sqrt(s),n=Math.atan2(r,e*i);t=Math.sin(t*n)/r,a=Math.sin(a*n)/r}const r=a*i;if(o=o*t+u*r,h=h*t+d*r,l=l*t+p*r,c=c*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=t,h*=t,l*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,s,r,n){const a=i[s],o=i[s+1],h=i[s+2],l=i[s+3],c=r[n],u=r[n+1],d=r[n+2],p=r[n+3];return t[e]=a*p+l*c+o*d-h*u,t[e+1]=o*p+l*u+h*c-a*d,t[e+2]=h*p+l*d+a*u-o*c,t[e+3]=l*p-a*c-o*u-h*d,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,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,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 i=t._x,s=t._y,r=t._z,n=t._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(s/2),c=a(r/2),u=o(i/2),d=o(s/2),p=o(r/2);switch(n){case"XYZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"YXZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"ZXY":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"ZYX":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"YZX":this._x=u*l*c+h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c-u*d*p;break;case"XZY":this._x=u*l*c-h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],a=e[5],o=e[9],h=e[2],l=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(l-o)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(o+l)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Hi(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const s=Math.min(1,e/i);return this.slerp(t,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(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 0===t?(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 i=t._x,s=t._y,r=t._z,n=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+n*a+s*h-r*o,this._y=s*l+n*o+r*a-i*h,this._z=r*l+n*h+i*o-s*a,this._w=n*l-i*a-s*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,s=this._y,r=this._z,n=this._w;let a=n*t._w+i*t._x+s*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=n,this._x=i,this._y=s,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*n+e*this._w,this._x=t*i+e*this._x,this._y=t*s+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(o),l=Math.atan2(h,a),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=n*c+this._w*u,this._x=i*c+this._x*u,this._y=s*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*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 Qi{constructor(t=0,e=0,i=0){Qi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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(ts.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ts.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,a=t.z,o=t.w,h=2*(n*s-a*i),l=2*(a*e-r*s),c=2*(r*i-n*e);return this.x=e+o*h+n*c-a*l,this.y=i+o*l+a*h-r*c,this.z=s+o*c+r*l-n*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,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,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=Hi(this.x,t.x,e.x),this.y=Hi(this.y,t.y,e.y),this.z=Hi(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Hi(this.x,t,e),this.y=Hi(this.y,t,e),this.z=Hi(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Hi(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,r=t.z,n=e.x,a=e.y,o=e.z;return this.x=s*o-r*a,this.y=r*n-i*o,this.z=i*a-s*n,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Ki.copy(this).projectOnVector(t),this.sub(Ki)}reflect(t){return this.sub(Ki.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Hi(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}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,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}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=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ki=new Qi,ts=new $i;class es{constructor(t,e,i,s,r,n,a,o,h){es.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h)}set(t,e,i,s,r,n,a,o,h){const l=this.elements;return l[0]=t,l[1]=s,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[3],o=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],p=i[8],m=s[0],y=s[3],g=s[6],f=s[1],x=s[4],b=s[7],v=s[2],w=s[5],M=s[8];return r[0]=n*m+a*f+o*v,r[3]=n*y+a*x+o*w,r[6]=n*g+a*b+o*M,r[1]=h*m+l*f+c*v,r[4]=h*y+l*x+c*w,r[7]=h*g+l*b+c*M,r[2]=u*m+d*f+p*v,r[5]=u*y+d*x+p*w,r[8]=u*g+d*b+p*M,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],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*n*l-e*a*h-i*r*l+i*a*o+s*r*h-s*n*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=l*n-a*h,u=a*o-l*r,d=h*r-n*o,p=e*c+i*u+s*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(s*h-l*i)*m,t[2]=(a*i-s*n)*m,t[3]=u*m,t[4]=(l*e-s*o)*m,t[5]=(s*r-a*e)*m,t[6]=d*m,t[7]=(i*o-h*e)*m,t[8]=(n*e-i*r)*m,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,i,s,r,n,a){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*n+h*a)+n+t,-s*h,s*o,-s*(-h*n+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(is.makeScale(t,e)),this}rotate(t){return this.premultiply(is.makeRotation(-t)),this}translate(t,e){return this.premultiply(is.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const is=new es;function ss(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const rs={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ns(t,e){return new rs[t](e)}function as(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function os(){const t=as("canvas");return t.style.display="block",t}const hs={};function ls(t){t in hs||(hs[t]=!0,console.warn(t))}function cs(t,e,i){return new Promise((function(s,r){setTimeout((function n(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(n,i);break;default:s()}}),i)}))}function us(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function ds(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}const ps=(new es).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ms=(new es).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ys(){const t={enabled:!0,workingColorSpace:Ze,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===$e&&(t.r=fs(t.r),t.g=fs(t.g),t.b=fs(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===$e&&(t.r=xs(t.r),t.g=xs(t.g),t.b=xs(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?Ge:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return ls("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return ls("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],s=[.3127,.329];return t.define({[Ze]:{primaries:e,whitePoint:s,transfer:Ge,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:Ye},outputColorSpaceConfig:{drawingBufferColorSpace:Ye}},[Ye]:{primaries:e,whitePoint:s,transfer:$e,toXYZ:ps,fromXYZ:ms,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:Ye}}}),t}const gs=ys();function fs(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function xs(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let bs;class vs{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===bs&&(bs=as("canvas")),bs.width=t.width,bs.height=t.height;const e=bs.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=bs}return i.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=as("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),r=s.data;for(let t=0;t1),this.pmremVersion=0}get width(){return this.source.getSize(As).x}get height(){return this.source.getSize(As).y}get depth(){return this.source.getSize(As).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 i=t[e];if(void 0===i){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[e]=i:console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ot)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case pt:t.x=t.x-Math.floor(t.x);break;case mt:t.x=t.x<0?0:1;break;case yt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case pt:t.y=t.y-Math.floor(t.y);break;case mt:t.y=t.y<0?0:1;break;case yt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ts.DEFAULT_IMAGE=null,Ts.DEFAULT_MAPPING=ot,Ts.DEFAULT_ANISOTROPY=1;class zs{constructor(t=0,e=0,i=0,s=1){zs.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}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,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,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=void 0!==t.w?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,i=this.y,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,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,i,s,r;const n=.01,a=.1,o=t.elements,h=o[0],l=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],y=o[6],g=o[10];if(Math.abs(l-u)o&&t>f?tf?o1;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,i=t.textures.length;e=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,Ns),Ns.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Hs),qs.subVectors(this.max,Hs),Vs.subVectors(t.a,Hs),Ls.subVectors(t.b,Hs),js.subVectors(t.c,Hs),Ws.subVectors(Ls,Vs),Us.subVectors(js,Ls),Ds.subVectors(Vs,js);let e=[0,-Ws.z,Ws.y,0,-Us.z,Us.y,0,-Ds.z,Ds.y,Ws.z,0,-Ws.x,Us.z,0,-Us.x,Ds.z,0,-Ds.x,-Ws.y,Ws.x,0,-Us.y,Us.x,0,-Ds.y,Ds.x,0];return!!Ys(e,Vs,Ls,js,qs)&&(e=[1,0,0,0,1,0,0,0,1],!!Ys(e,Vs,Ls,js,qs)&&(Js.crossVectors(Ws,Us),e=[Js.x,Js.y,Js.z],Ys(e,Vs,Ls,js,qs)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ns).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Ns).length()),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()||(Os[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Os[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Os[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Os[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Os[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Os[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Os[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Os[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Os)),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 Os=[new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi],Ns=new Qi,Fs=new Ps,Vs=new Qi,Ls=new Qi,js=new Qi,Ws=new Qi,Us=new Qi,Ds=new Qi,Hs=new Qi,qs=new Qi,Js=new Qi,Xs=new Qi;function Ys(t,e,i,s,r){for(let n=0,a=t.length-3;n<=a;n+=3){Xs.fromArray(t,n);const a=r.x*Math.abs(Xs.x)+r.y*Math.abs(Xs.y)+r.z*Math.abs(Xs.z),o=e.dot(Xs),h=i.dot(Xs),l=s.dot(Xs);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>a)return!1}return!0}const Zs=new Ps,Gs=new Qi,$s=new Qi;class Qs{constructor(t=new Qi,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 i=this.center;void 0!==e?i.copy(e):Zs.setFromPoints(t).getCenter(i);let s=0;for(let e=0,r=t.length;ethis.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;Gs.subVectors(t,this.center);const e=Gs.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Gs,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):($s.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gs.copy(t.center).add($s)),this.expandByPoint(Gs.copy(t.center).sub($s))),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 Ks=new Qi,tr=new Qi,er=new Qi,ir=new Qi,sr=new Qi,rr=new Qi,nr=new Qi;class ar{constructor(t=new Qi,e=new Qi(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,Ks)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ks.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ks.copy(this.origin).addScaledVector(this.direction,e),Ks.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){tr.copy(t).add(e).multiplyScalar(.5),er.copy(e).sub(t).normalize(),ir.copy(this.origin).sub(tr);const r=.5*t.distanceTo(e),n=-this.direction.dot(er),a=ir.dot(this.direction),o=-ir.dot(er),h=ir.lengthSq(),l=Math.abs(1-n*n);let c,u,d,p;if(l>0)if(c=n*o-a,u=n*a-o,p=r*l,c>=0)if(u>=-p)if(u<=p){const t=1/l;c*=t,u*=t,d=c*(c+n*u+2*a)+u*(n*c+u+2*o)+h}else u=r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u=-r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u<=-p?(c=Math.max(0,-(-n*r+a)),u=c>0?-r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h):u<=p?(c=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+h):(c=Math.max(0,-(n*r+a)),u=c>0?r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h);else u=n>0?-r:r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,c),s&&s.copy(tr).addScaledVector(er,u),d}intersectSphere(t,e){Ks.subVectors(t.center,this.origin);const i=Ks.dot(this.direction),s=Ks.dot(Ks)-i*i,r=t.radius*t.radius;if(s>r)return null;const n=Math.sqrt(r-s),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,r,n,a,o;const h=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return h>=0?(i=(t.min.x-u.x)*h,s=(t.max.x-u.x)*h):(i=(t.max.x-u.x)*h,s=(t.min.x-u.x)*h),l>=0?(r=(t.min.y-u.y)*l,n=(t.max.y-u.y)*l):(r=(t.max.y-u.y)*l,n=(t.min.y-u.y)*l),i>n||r>s?null:((r>i||isNaN(i))&&(i=r),(n=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),i>o||a>s?null:((a>i||i!=i)&&(i=a),(o=0?i:s,e)))}intersectsBox(t){return null!==this.intersectBox(t,Ks)}intersectTriangle(t,e,i,s,r){sr.subVectors(e,t),rr.subVectors(i,t),nr.crossVectors(sr,rr);let n,a=this.direction.dot(nr);if(a>0){if(s)return null;n=1}else{if(!(a<0))return null;n=-1,a=-a}ir.subVectors(this.origin,t);const o=n*this.direction.dot(rr.crossVectors(ir,rr));if(o<0)return null;const h=n*this.direction.dot(sr.cross(ir));if(h<0)return null;if(o+h>a)return null;const l=-n*ir.dot(nr);return l<0?null:this.at(l/a,r)}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 or{constructor(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y){or.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y)}set(t,e,i,s,r,n,a,o,h,l,c,u,d,p,m,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=r,g[5]=n,g[9]=a,g[13]=o,g[2]=h,g[6]=l,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=y,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 or).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/hr.setFromMatrixColumn(t,0).length(),r=1/hr.setFromMatrixColumn(t,1).length(),n=1/hr.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,r=t.z,n=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=n*l,i=n*c,s=a*l,r=a*c;e[0]=o*l,e[4]=-o*c,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-a*o,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*o}else if("YXZ"===t.order){const t=o*l,i=o*c,s=h*l,r=h*c;e[0]=t+r*a,e[4]=s*a-i,e[8]=n*h,e[1]=n*c,e[5]=n*l,e[9]=-a,e[2]=i*a-s,e[6]=r+t*a,e[10]=n*o}else if("ZXY"===t.order){const t=o*l,i=o*c,s=h*l,r=h*c;e[0]=t-r*a,e[4]=-n*c,e[8]=s+i*a,e[1]=i+s*a,e[5]=n*l,e[9]=r-t*a,e[2]=-n*h,e[6]=a,e[10]=n*o}else if("ZYX"===t.order){const t=n*l,i=n*c,s=a*l,r=a*c;e[0]=o*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=o*c,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=a*o,e[10]=n*o}else if("YZX"===t.order){const t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=r-t*c,e[8]=s*c+i,e[1]=c,e[5]=n*l,e[9]=-a*l,e[2]=-h*l,e[6]=i*c+s,e[10]=t-r*c}else if("XZY"===t.order){const t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=n*l,e[9]=i*c-s,e[2]=s*c-i,e[6]=a*l,e[10]=r*c+t}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(cr,t,ur)}lookAt(t,e,i){const s=this.elements;return mr.subVectors(t,e),0===mr.lengthSq()&&(mr.z=1),mr.normalize(),dr.crossVectors(i,mr),0===dr.lengthSq()&&(1===Math.abs(i.z)?mr.x+=1e-4:mr.z+=1e-4,mr.normalize(),dr.crossVectors(i,mr)),dr.normalize(),pr.crossVectors(mr,dr),s[0]=dr.x,s[4]=pr.x,s[8]=mr.x,s[1]=dr.y,s[5]=pr.y,s[9]=mr.y,s[2]=dr.z,s[6]=pr.z,s[10]=mr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[4],o=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],p=i[2],m=i[6],y=i[10],g=i[14],f=i[3],x=i[7],b=i[11],v=i[15],w=s[0],M=s[4],S=s[8],_=s[12],A=s[1],T=s[5],z=s[9],I=s[13],C=s[2],B=s[6],k=s[10],R=s[14],E=s[3],P=s[7],O=s[11],N=s[15];return r[0]=n*w+a*A+o*C+h*E,r[4]=n*M+a*T+o*B+h*P,r[8]=n*S+a*z+o*k+h*O,r[12]=n*_+a*I+o*R+h*N,r[1]=l*w+c*A+u*C+d*E,r[5]=l*M+c*T+u*B+d*P,r[9]=l*S+c*z+u*k+d*O,r[13]=l*_+c*I+u*R+d*N,r[2]=p*w+m*A+y*C+g*E,r[6]=p*M+m*T+y*B+g*P,r[10]=p*S+m*z+y*k+g*O,r[14]=p*_+m*I+y*R+g*N,r[3]=f*w+x*A+b*C+v*E,r[7]=f*M+x*T+b*B+v*P,r[11]=f*S+x*z+b*k+v*O,r[15]=f*_+x*I+b*R+v*N,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],i=t[4],s=t[8],r=t[12],n=t[1],a=t[5],o=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*o*c-s*h*c-r*a*u+i*h*u+s*a*d-i*o*d)+t[7]*(+e*o*d-e*h*u+r*n*u-s*n*d+s*h*l-r*o*l)+t[11]*(+e*h*c-e*a*d-r*n*c+i*n*d+r*a*l-i*h*l)+t[15]*(-s*a*l-e*o*c+e*a*u+s*n*c-i*n*u+i*o*l)}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,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],y=t[14],g=t[15],f=c*y*h-m*u*h+m*o*d-a*y*d-c*o*g+a*u*g,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s))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),r=1-i,n=t.x,a=t.y,o=t.z,h=r*n,l=r*a;return this.set(h*n+i,h*a-s*o,h*o+s*a,0,h*a+s*o,l*a+i,l*o-s*n,0,h*o-s*a,l*o+s*n,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,r=e._x,n=e._y,a=e._z,o=e._w,h=r+r,l=n+n,c=a+a,u=r*h,d=r*l,p=r*c,m=n*l,y=n*c,g=a*c,f=o*h,x=o*l,b=o*c,v=i.x,w=i.y,M=i.z;return s[0]=(1-(m+g))*v,s[1]=(d+b)*v,s[2]=(p-x)*v,s[3]=0,s[4]=(d-b)*w,s[5]=(1-(u+g))*w,s[6]=(y+f)*w,s[7]=0,s[8]=(p+x)*M,s[9]=(y-f)*M,s[10]=(1-(u+m))*M,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let r=hr.set(s[0],s[1],s[2]).length();const n=hr.set(s[4],s[5],s[6]).length(),a=hr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],lr.copy(this);const o=1/r,h=1/n,l=1/a;return lr.elements[0]*=o,lr.elements[1]*=o,lr.elements[2]*=o,lr.elements[4]*=h,lr.elements[5]*=h,lr.elements[6]*=h,lr.elements[8]*=l,lr.elements[9]*=l,lr.elements[10]*=l,e.setFromRotationMatrix(lr),i.x=r,i.y=n,i.z=a,this}makePerspective(t,e,i,s,r,n,a=2e3){const o=this.elements,h=2*r/(e-t),l=2*r/(i-s),c=(e+t)/(e-t),u=(i+s)/(i-s);let d,p;if(a===Ei)d=-(n+r)/(n-r),p=-2*n*r/(n-r);else{if(a!==Pi)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-n/(n-r),p=-n*r/(n-r)}return o[0]=h,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,r,n,a=2e3){const o=this.elements,h=1/(e-t),l=1/(i-s),c=1/(n-r),u=(e+t)*h,d=(i+s)*l;let p,m;if(a===Ei)p=(n+r)*c,m=-2*c;else{if(a!==Pi)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*c,m=-1*c}return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const hr=new Qi,lr=new or,cr=new Qi(0,0,0),ur=new Qi(1,1,1),dr=new Qi,pr=new Qi,mr=new Qi,yr=new or,gr=new $i;class fr{constructor(t=0,e=0,i=0,s=fr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}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,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,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,i=!0){const s=t.elements,r=s[0],n=s[4],a=s[8],o=s[1],h=s[5],l=s[9],c=s[2],u=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(Hi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Hi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(Hi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Hi(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(Hi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Hi(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return yr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(yr,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return gr.setFromEuler(this),this.setFromQuaternion(gr,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],void 0!==t[3]&&(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}}fr.DEFAULT_ORDER="XYZ";class xr{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map((t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0}))),s.instanceInfo=this._instanceInfo.map((t=>({...t}))),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(s.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,s=i.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(i.geometries=e),s.length>0&&(i.materials=s),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l),c.length>0&&(i.nodes=c)}return i.object=s,i;function n(t){const e=[];for(const i in t){const s=t[i];delete s.metadata,e.push(s)}return e}}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)),!0===e)for(let e=0;e0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,i,s,r){Or.subVectors(s,e),Nr.subVectors(i,e),Fr.subVectors(t,e);const n=Or.dot(Or),a=Or.dot(Nr),o=Or.dot(Fr),h=Nr.dot(Nr),l=Nr.dot(Fr),c=n*h-a*a;if(0===c)return r.set(0,0,0),null;const u=1/c,d=(h*o-a*l)*u,p=(n*l-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,s){return null!==this.getBarycoord(t,e,i,s,Vr)&&(Vr.x>=0&&Vr.y>=0&&Vr.x+Vr.y<=1)}static getInterpolation(t,e,i,s,r,n,a,o){return null===this.getBarycoord(t,e,i,s,Vr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Vr.x),o.addScaledVector(n,Vr.y),o.addScaledVector(a,Vr.z),o)}static getInterpolatedAttribute(t,e,i,s,r,n){return qr.setScalar(0),Jr.setScalar(0),Xr.setScalar(0),qr.fromBufferAttribute(t,e),Jr.fromBufferAttribute(t,i),Xr.fromBufferAttribute(t,s),n.setScalar(0),n.addScaledVector(qr,r.x),n.addScaledVector(Jr,r.y),n.addScaledVector(Xr,r.z),n}static isFrontFacing(t,e,i,s){return Or.subVectors(i,e),Nr.subVectors(t,e),Or.cross(Nr).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),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 Or.subVectors(this.c,this.b),Nr.subVectors(this.a,this.b),.5*Or.cross(Nr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Yr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Yr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,r){return Yr.getInterpolation(t,this.a,this.b,this.c,e,i,s,r)}containsPoint(t){return Yr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Yr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,r=this.c;let n,a;Lr.subVectors(s,i),jr.subVectors(r,i),Ur.subVectors(t,i);const o=Lr.dot(Ur),h=jr.dot(Ur);if(o<=0&&h<=0)return e.copy(i);Dr.subVectors(t,s);const l=Lr.dot(Dr),c=jr.dot(Dr);if(l>=0&&c<=l)return e.copy(s);const u=o*c-l*h;if(u<=0&&o>=0&&l<=0)return n=o/(o-l),e.copy(i).addScaledVector(Lr,n);Hr.subVectors(t,r);const d=Lr.dot(Hr),p=jr.dot(Hr);if(p>=0&&d<=p)return e.copy(r);const m=d*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(i).addScaledVector(jr,a);const y=l*p-d*c;if(y<=0&&c-l>=0&&d-p>=0)return Wr.subVectors(r,s),a=(c-l)/(c-l+(d-p)),e.copy(s).addScaledVector(Wr,a);const g=1/(y+m+u);return n=m*g,a=u*g,e.copy(i).addScaledVector(Lr,n).addScaledVector(jr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Zr={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},Gr={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Qr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class Kr{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ye){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,gs.colorSpaceToWorking(this,e),this}setRGB(t,e,i,s=gs.workingColorSpace){return this.r=t,this.g=e,this.b=i,gs.colorSpaceToWorking(this,s),this}setHSL(t,e,i,s=gs.workingColorSpace){if(t=qi(t,1),e=Hi(e,0,1),i=Hi(i,0,1),0===e)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=Qr(r,s,t+1/3),this.g=Qr(r,s,t),this.b=Qr(r,s,t-1/3)}return gs.colorSpaceToWorking(this,s),this}setStyle(t,e=Ye){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=s[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,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=Ye){const i=Zr[t.toLowerCase()];return void 0!==i?this.setHex(i,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=fs(t.r),this.g=fs(t.g),this.b=fs(t.b),this}copyLinearToSRGB(t){return this.r=xs(t.r),this.g=xs(t.g),this.b=xs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ye){return gs.workingToColorSpace(tn.copy(this),t),65536*Math.round(Hi(255*tn.r,0,255))+256*Math.round(Hi(255*tn.g,0,255))+Math.round(Hi(255*tn.b,0,255))}getHexString(t=Ye){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=gs.workingColorSpace){gs.workingToColorSpace(tn.copy(this),e);const i=tn.r,s=tn.g,r=tn.b,n=Math.max(i,s,r),a=Math.min(i,s,r);let o,h;const l=(a+n)/2;if(a===n)o=0,h=0;else{const t=n-a;switch(h=l<=.5?t/(n+a):t/(2-n-a),n){case i:o=(s-r)/t+(s0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];void 0!==s?s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function s(t){const e=[];for(const i in t){const s=t[i];delete s.metadata,e.push(s)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ke&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ke&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ke&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=s(t.textures),r=s(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let s=0;s!==t;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,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){!0===t&&this.version++}}class rn extends sn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kr(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 fr,this.combine=0,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 nn=an();function an(){const t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),s=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(s[t]=0,s[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(s[t]=1024>>-e-14,s[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(s[t]=e+15<<10,s[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(s[t]=31744,s[256|t]=64512,r[t]=24,r[256|t]=24):(s[t]=31744,s[256|t]=64512,r[t]=13,r[256|t]=13)}const n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;!(8388608&e);)e<<=1,i-=8388608;e&=-8388609,i+=947912704,n[t]=e|i}for(let t=1024;t<2048;++t)n[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:s,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function on(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=Hi(t,-65504,65504),nn.floatView[0]=t;const e=nn.uint32View[0],i=e>>23&511;return nn.baseTable[i]+((8388607&e)>>nn.shiftTable[i])}function hn(t){const e=t>>10;return nn.uint32View[0]=nn.mantissaTable[nn.offsetTable[e]+(1023&t)]+nn.exponentTable[e],nn.floatView[0]}class ln{static toHalfFloat(t){return on(t)}static fromHalfFloat(t){return hn(t)}}const cn=new Qi,un=new Gi;let dn=0;class pn{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:dn++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=Mi,this.updateRanges=[],this.gpuType=Rt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&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,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,r=this.itemSize;se.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(){null===this.boundingBox&&(this.boundingBox=new Ps);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Qi(-1/0,-1/0,-1/0),new Qi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const s=i[e];t.data.attributes[e]=s.toJSON(t.data)}const s={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],n=[];for(let e=0,s=i.length;e0&&(s[e]=n,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const n=this.groups;n.length>0&&(t.data.groups=JSON.parse(JSON.stringify(n)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.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 i=t.index;null!==i&&this.setIndex(i.clone());const s=t.attributes;for(const t in s){const i=s[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],s=r[t];for(let t=0,r=s.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)return}kn.copy(r).invert(),Rn.copy(t.ray).applyMatrix4(kn),null!==i.boundingBox&&!1===Rn.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Rn)}}_computeIntersections(t,e,i){let s;const r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,o=u.length;ri.far?null:{distance:l,point:Wn.clone(),object:t}}(t,e,i,s,On,Nn,Fn,jn);if(c){const t=new Qi;Yr.getBarycoord(jn,On,Nn,Fn,t),r&&(c.uv=Yr.getInterpolatedAttribute(r,o,h,l,t,new Gi)),n&&(c.uv1=Yr.getInterpolatedAttribute(n,o,h,l,t,new Gi)),a&&(c.normal=Yr.getInterpolatedAttribute(a,o,h,l,t,new Qi),c.normal.dot(s.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:h,c:l,normal:new Qi,materialIndex:0};Yr.getNormal(On,Nn,Fn,e.normal),c.face=e,c.barycoord=t}return c}class Hn extends Bn{constructor(t=1,e=1,i=1,s=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:r,depthSegments:n};const a=this;s=Math.floor(s),r=Math.floor(r),n=Math.floor(n);const o=[],h=[],l=[],c=[];let u=0,d=0;function p(t,e,i,s,r,n,p,m,y,g,f){const x=n/y,b=p/g,v=n/2,w=p/2,M=m/2,S=y+1,_=g+1;let A=0,T=0;const z=new Qi;for(let n=0;n<_;n++){const a=n*b-w;for(let o=0;o0?1:-1,l.push(z.x,z.y,z.z),c.push(o/y),c.push(1-n/g),A+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class Gn extends Pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new or,this.projectionMatrix=new or,this.projectionMatrixInverse=new or,this.coordinateSystem=Ei}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 $n=new Qi,Qn=new Gi,Kn=new Gi;class ta extends Gn{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,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=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ui*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Wi*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ui*Math.atan(Math.tan(.5*Wi*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,i){$n.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set($n.x,$n.y).multiplyScalar(-t/$n.z),$n.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set($n.x,$n.y).multiplyScalar(-t/$n.z)}getViewSize(t,e){return this.getViewBounds(t,Qn,Kn),e.subVectors(Kn,Qn)}setViewOffset(t,e,i,s,r,n){this.aspect=t/e,null===this.view&&(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=i,this.view.offsetY=s,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Wi*this.fov)/this.zoom,i=2*e,s=this.aspect*i,r=-.5*s;const n=this.view;if(null!==this.view&&this.view.enabled){const t=n.fullWidth,a=n.fullHeight;r+=n.offsetX*s/t,e-=n.offsetY*i/a,s*=n.width/t,i*=n.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-i,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,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ea=-90;class ia extends Pr{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new ta(ea,1,t,e);s.layers=this.layers,this.add(s);const r=new ta(ea,1,t,e);r.layers=this.layers,this.add(r);const n=new ta(ea,1,t,e);n.layers=this.layers,this.add(n);const a=new ta(ea,1,t,e);a.layers=this.layers,this.add(a);const o=new ta(ea,1,t,e);o.layers=this.layers,this.add(o);const h=new ta(ea,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,s,r,n,a,o]=e;for(const t of e)this.remove(t);if(t===Ei)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.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(t!==Pi)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.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)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,n,a,o,h,l]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,r),t.setRenderTarget(i,1,s),t.render(e,n),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,l),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class sa extends Ts{constructor(t=[],e=301,i,s,r,n,a,o,h,l){super(t,e,i,s,r,n,a,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ra extends Cs{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},s=[i,i,i,i,i,i];this.texture=new sa(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},s=new Hn(5,5,5),r=new Zn({name:"CubemapFromEquirect",uniforms:qn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const n=new Un(s,r),a=e.minFilter;e.minFilter===_t&&(e.minFilter=wt);return new ia(1,10,this).update(t,n),e.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(t,e=!0,i=!0,s=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(r)}}class na extends Pr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const aa={type:"move"};class oa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new na,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new na,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Qi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Qi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new na,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Qi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Qi),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let s=null,r=null,n=null;const a=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){n=!0;for(const s of t.hand.values()){const t=e.getJointPose(s,i),r=this._getHandJoint(h,s);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const s=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=s.position.distanceTo(r.position),o=.02,l=.005;h.inputState.pinching&&a>o+l?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&a<=o-l&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(s=e.getPose(t.targetRaySpace,i),null===s&&null!==r&&(s=r),null!==s&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(aa)))}return null!==a&&(a.visible=null!==s),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==n),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new na;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class ha{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Kr(t),this.density=e}clone(){return new ha(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class la{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new Kr(t),this.near=e,this.far=i}clone(){return new la(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ca extends Pr{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 fr,this.environmentIntensity=1,this.environmentRotation=new fr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ua{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Mi,this.updateRanges=[],this.version=0,this.uuid=Di()}onUploadCallback(){}set needsUpdate(t){!0===t&&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,i){t*=this.stride,i*=e.stride;for(let s=0,r=this.stride;st.far||e.push({distance:o,point:ga.clone(),uv:Yr.getInterpolation(ga,Ma,Sa,_a,Aa,Ta,za,new Gi),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ca(t,e,i,s,r,n){ba.subVectors(t,i).addScalar(.5).multiply(s),void 0!==r?(va.x=n*ba.x-r*ba.y,va.y=r*ba.x+n*ba.y):va.copy(ba),t.copy(e),t.x+=va.x,t.y+=va.y,t.applyMatrix4(wa)}const Ba=new Qi,ka=new Qi;class Ra extends Pr{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,i=e.length;t0){let i,s;for(i=1,s=e.length;i0){Ba.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(Ba);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Ba.setFromMatrixPosition(t.matrixWorld),ka.setFromMatrixPosition(this.matrixWorld);const i=Ba.distanceTo(ka)/t.zoom;let s,r;for(e[0].object.visible=!0,s=1,r=e.length;s=t))break;e[s-1].object.visible=!1,e[s].object.visible=!0}for(this._currentLevel=s-1;s1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||no.getNormalMatrix(t),s=this.coplanarPoint(so).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),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)}}const oo=new Qs,ho=new Qi;class lo{constructor(t=new ao,e=new ao,i=new ao,s=new ao,r=new ao,n=new ao){this.planes=[t,e,i,s,r,n]}set(t,e,i,s,r,n){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(n),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,s=t.elements,r=s[0],n=s[1],a=s[2],o=s[3],h=s[4],l=s[5],c=s[6],u=s[7],d=s[8],p=s[9],m=s[10],y=s[11],g=s[12],f=s[13],x=s[14],b=s[15];if(i[0].setComponents(o-r,u-h,y-d,b-g).normalize(),i[1].setComponents(o+r,u+h,y+d,b+g).normalize(),i[2].setComponents(o+n,u+l,y+p,b+f).normalize(),i[3].setComponents(o-n,u-l,y-p,b-f).normalize(),i[4].setComponents(o-a,u-c,y-m,b-x).normalize(),e===Ei)i[5].setComponents(o+a,u+c,y+m,b+x).normalize();else{if(e!==Pi)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(a,c,m,x).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),oo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),oo.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(oo)}intersectsSprite(t){return oo.center.set(0,0,0),oo.radius=.7071067811865476,oo.applyMatrix4(t.matrixWorld),this.intersectsSphere(oo)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,ho.y=s.normal.y>0?t.max.y:t.min.y,ho.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ho)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const co=new or,uo=new lo;class po{constructor(){this.coordinateSystem=Ei}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];n.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}}const xo=new or,bo=new Kr(1,1,1),vo=new lo,wo=new po,Mo=new Ps,So=new Qs,_o=new Qi,Ao=new Qi,To=new Qi,zo=new fo,Io=new Un,Co=[];function Bo(t,e,i=0){const s=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let n=0;n65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new pn(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(!t.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const s=t.getAttribute(i),r=e.getAttribute(i);if(s.itemSize!==r.itemSize||s.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ps);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(mo),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=e):(i=this._instanceInfo.length,this._instanceInfo.push(e));const s=this._matricesTexture;xo.identity().toArray(s.image.data,16*i),s.needsUpdate=!0;const r=this._colorsTexture;return r&&(bo.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,i=-1){this._initializeGeometry(t),this._validateGeometry(t);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const n=t.getIndex();if(null!==n&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=-1===i?n.count:i),-1!==s.indexStart&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(mo),a=this._availableGeometryIds.shift(),r[a]=s):(a=this._geometryCount,this._geometryCount++,r.push(s)),this.setGeometryAt(a,t),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,s=null!==i.getIndex(),r=i.getIndex(),n=e.getIndex(),a=this._geometryInfo[t];if(s&&n.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,h=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in i.attributes){const s=e.getAttribute(t),r=i.getAttribute(t);Bo(s,r,o);const n=s.itemSize;for(let t=s.count,e=h;t=e.length||!1===e[t].active)return this;const i=this._instanceInfo;for(let e=0,s=i.length;ee)).sort(((t,e)=>i[t].vertexStart-i[e].vertexStart)),r=this.geometry;for(let n=0,a=i.length;n=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingBox){const t=new Ps,e=i.index,r=i.attributes.position;for(let i=s.start,n=s.start+s.count;i=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingSphere){const e=new Qs;this.getBoundingBoxAt(t,Mo),Mo.getCenter(e.center);const r=i.index,n=i.attributes.position;let a=0;for(let t=s.start,i=s.start+s.count;tt.active));if(Math.max(...i.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...i.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Bn,this._initializeGeometry(s));const r=this.geometry;s.index&&ko(s.index.array,r.index.array);for(const t in s.attributes)ko(s.attributes[t].array,r.attributes[t].array)}raycast(t,e){const i=this._instanceInfo,s=this._geometryInfo,r=this.matrixWorld,n=this.geometry;Io.material=this.material,Io.geometry.index=n.index,Io.geometry.attributes=n.attributes,null===Io.geometry.boundingBox&&(Io.geometry.boundingBox=new Ps),null===Io.geometry.boundingSphere&&(Io.geometry.boundingSphere=new Qs);for(let n=0,a=i.length;n({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,i,s,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const n=s.getIndex(),a=null===n?1:n.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,c=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,m=i.isArrayCamera?wo:vo;u&&!i.isArrayCamera&&(xo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vo.setFromProjectionMatrix(xo,t.coordinateSystem));let y=0;if(this.sortObjects){xo.copy(this.matrixWorld).invert(),_o.setFromMatrixPosition(i.matrixWorld).applyMatrix4(xo),Ao.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(xo);for(let t=0,e=o.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ts)return;Lo.applyMatrix4(t.matrixWorld);const h=e.ray.origin.distanceTo(Lo);return he.far?void 0:{distance:h,point:jo.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const Do=new Qi,Ho=new Qi;class qo extends Wo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,s=e.count;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class th extends Ts{constructor(t,e,i,s,r=1006,n=1006,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isVideoTexture=!0,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){l.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class eh extends th{constructor(t,e,i,s,r,n,a,o){super({},t,e,i,s,r,n,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class ih extends Ts{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gt,this.minFilter=gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class sh extends Ts{constructor(t,e,i,s,r,n,a,o,h,l,c,u){super(null,n,a,o,h,l,s,r,c,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rh extends sh{constructor(t,e,i,s,r,n){super(t,e,i,r,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=mt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class nh extends sh{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,ht),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ah extends Ts{constructor(t,e,i,s,r,n,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class oh extends Ts{constructor(t,e,i=1014,s,r,n,a=1003,o=1003,h,l=1026,c=1){if(l!==Wt&&1027!==l)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},s,r,n,a,o,l,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ms(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class hh extends Bn{constructor(t=1,e=1,i=4,s=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:i,radialSegments:s,heightSegments:r},e=Math.max(0,e),i=Math.max(1,Math.floor(i)),s=Math.max(3,Math.floor(s)),r=Math.max(1,Math.floor(r));const n=[],a=[],o=[],h=[],l=e/2,c=Math.PI/2*t,u=e,d=2*c+u,p=2*i+r,m=s+1,y=new Qi,g=new Qi;for(let f=0;f<=p;f++){let x=0,b=0,v=0,w=0;if(f<=i){const e=f/i,s=e*Math.PI/2;b=-l-t*Math.cos(s),v=t*Math.sin(s),w=-t*Math.cos(s),x=e*c}else if(f<=i+r){const s=(f-i)/r;b=s*e-l,v=t,w=0,x=c+s*u}else{const e=(f-i-r)/i,s=e*Math.PI/2;b=l+t*Math.sin(s),v=t*Math.cos(s),w=t*Math.sin(s),x=c+u+e*c}const M=Math.max(0,Math.min(1,x/d));let S=0;0===f?S=.5/s:f===p&&(S=-.5/s);for(let t=0;t<=s;t++){const e=t/s,i=e*Math.PI*2,r=Math.sin(i),n=Math.cos(i);g.x=-v*n,g.y=b,g.z=v*r,a.push(g.x,g.y,g.z),y.set(-v*n,w,v*r),y.normalize(),o.push(y.x,y.y,y.z),h.push(e+S,M)}if(f>0){const t=(f-1)*m;for(let e=0;e0||0!==s)&&(l.push(n,a,h),x+=3),(e>0||s!==r-1)&&(l.push(a,o,h),x+=3)}h.addGroup(g,x,0),g+=x}(),!1===n&&(t>0&&f(!0),e>0&&f(!1)),this.setIndex(l),this.setAttribute("position",new Mn(c,3)),this.setAttribute("normal",new Mn(u,3)),this.setAttribute("uv",new Mn(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ch(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class uh extends ch{constructor(t=1,e=1,i=32,s=1,r=!1,n=0,a=2*Math.PI){super(0,t,e,i,s,r,n,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:n,thetaLength:a}}static fromJSON(t){return new uh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class dh extends Bn{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const r=[],n=[];function a(t,e,i,s){const r=s+1,n=[];for(let s=0;s<=r;s++){n[s]=[];const a=t.clone().lerp(i,s/r),o=e.clone().lerp(i,s/r),h=r-s;for(let t=0;t<=h;t++)n[s][t]=0===t&&s===r?a:a.clone().lerp(o,t/h)}for(let t=0;t.9&&a<.1&&(e<.2&&(n[t+0]+=1),i<.2&&(n[t+2]+=1),s<.2&&(n[t+4]+=1))}}()}(),this.setAttribute("position",new Mn(r,3)),this.setAttribute("normal",new Mn(r.slice(),3)),this.setAttribute("uv",new Mn(n,2)),0===s?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new dh(t.vertices,t.indices,t.radius,t.details)}}class ph extends dh{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ph(t.radius,t.detail)}}const mh=new Qi,yh=new Qi,gh=new Qi,fh=new Yr;class xh extends Bn{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,s=Math.pow(10,i),r=Math.cos(Wi*e),n=t.getIndex(),a=t.getAttribute("position"),o=n?n.count:a.count,h=[0,0,0],l=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t0)){h=s;break}h=s-1}if(s=h,i[s]===n)return s/(r-1);const l=i[s];return(s+(n-l)/(i[s+1]-l))/(r-1)}getTangent(t,e){const i=1e-4;let s=t-i,r=t+i;s<0&&(s=0),r>1&&(r=1);const n=this.getPoint(s),a=this.getPoint(r),o=e||(n.isVector2?new Gi:new Qi);return o.copy(a).sub(n).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){const i=new Qi,s=[],r=[],n=[],a=new Qi,o=new or;for(let e=0;e<=t;e++){const i=e/t;s[e]=this.getTangentAt(i,new Qi)}r[0]=new Qi,n[0]=new Qi;let h=Number.MAX_VALUE;const l=Math.abs(s[0].x),c=Math.abs(s[0].y),u=Math.abs(s[0].z);l<=h&&(h=l,i.set(1,0,0)),c<=h&&(h=c,i.set(0,1,0)),u<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],a),n[0].crossVectors(s[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),n[e]=n[e-1].clone(),a.crossVectors(s[e-1],s[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Hi(s[e-1].dot(s[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}n[e].crossVectors(s[e],r[e])}if(!0===e){let e=Math.acos(Hi(r[0].dot(r[t]),-1,1));e/=t,s[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(s[i],e*i)),n[i].crossVectors(s[i],r[i])}return{tangents:s,normals:r,binormals:n}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class vh extends bh{constructor(t=0,e=0,i=1,s=1,r=0,n=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new Gi){const i=e,s=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const n=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?a=s[(h-1)%r]:(Sh.subVectors(s[0],s[1]).add(s[0]),a=Sh);const c=s[h%r],u=s[(h+1)%r];if(this.closed||h+2s.length-2?s.length-1:n+1],c=s[n>s.length-3?s.length-1:n+2];return i.set(Ih(a,o.x,h.x,l.x,c.x),Ih(a,o.y,h.y,l.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){const t=s[r]-i,n=this.curves[r],a=n.getLength(),o=0===a?0:1-t/a;return n.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,s=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){const t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Wh extends jh{constructor(t){super(t),this.uuid=Di(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,s=this.holes.length;i80*i){o=1/0,h=1/0;let e=-1/0,s=-1/0;for(let n=i;ne&&(e=i),r>s&&(s=r)}l=Math.max(e-o,s-h),l=0!==l?32767/l:0}return qh(n,a,i,o,h,l,0),a}function Dh(t,e,i,s,r){let n;if(r===function(t,e,i,s){let r=0;for(let n=e,a=i-s;n0)for(let r=e;r=e;r-=s)n=ul(r/s|0,t[r],t[r+1],n);return n&&nl(n,n.next)&&(dl(n),n=n.next),n}function Hh(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!nl(s,s.next)&&0!==rl(s.prev,s,s.next))s=s.next;else{if(dl(s),s=e=s.prev,s===s.next)break;i=!0}}while(i||s!==e);return e}function qh(t,e,i,s,r,n,a){if(!t)return;!a&&n&&function(t,e,i,s){let r=t;do{0===r.z&&(r.z=Kh(r.x,r.y,e,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let s,r=t;t=null;let n=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t0||h>0&&a;)0!==o&&(0===h||!a||r.z<=a.z)?(s=r,r=r.nextZ,o--):(s=a,a=a.nextZ,h--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=a}n.nextZ=null,i*=2}while(e>1)}(r)}(t,s,r,n);let o=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(n?Xh(t,s,r,n):Jh(t))e.push(h.i,t.i,l.i),dl(t),t=l.next,o=l.next;else if((t=l)===o){a?1===a?qh(t=Yh(Hh(t),e),e,i,s,r,n,2):2===a&&Zh(t,e,i,s,r,n):qh(Hh(t),e,i,s,r,n,1);break}}}function Jh(t){const e=t.prev,i=t,s=t.next;if(rl(e,i,s)>=0)return!1;const r=e.x,n=i.x,a=s.x,o=e.y,h=i.y,l=s.y,c=Math.min(r,n,a),u=Math.min(o,h,l),d=Math.max(r,n,a),p=Math.max(o,h,l);let m=s.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&il(r,o,n,h,a,l,m.x,m.y)&&rl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Xh(t,e,i,s){const r=t.prev,n=t,a=t.next;if(rl(r,n,a)>=0)return!1;const o=r.x,h=n.x,l=a.x,c=r.y,u=n.y,d=a.y,p=Math.min(o,h,l),m=Math.min(c,u,d),y=Math.max(o,h,l),g=Math.max(c,u,d),f=Kh(p,m,e,i,s),x=Kh(y,g,e,i,s);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=f&&v&&v.z<=x;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&rl(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&rl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=f;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&rl(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&rl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Yh(t,e){let i=t;do{const s=i.prev,r=i.next.next;!nl(s,r)&&al(s,i,i.next,r)&&ll(s,r)&&ll(r,s)&&(e.push(s.i,i.i,r.i),dl(i),dl(i.next),i=t=r),i=i.next}while(i!==t);return Hh(i)}function Zh(t,e,i,s,r,n){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&sl(a,t)){let o=cl(a,t);return a=Hh(a,a.next),o=Hh(o,o.next),qh(a,e,i,s,r,n,0),void qh(o,e,i,s,r,n,0)}t=t.next}a=a.next}while(a!==t)}function Gh(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function $h(t,e){const i=function(t,e){let i=e;const s=t.x,r=t.y;let n,a=-1/0;if(nl(t,i))return i;do{if(nl(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>a&&(a=t,n=i.x=i.x&&i.x>=h&&s!==i.x&&el(rn.x||i.x===n.x&&Qh(n,i)))&&(n=i,c=e)}i=i.next}while(i!==o);return n}(t,e);if(!i)return e;const s=cl(i,t);return Hh(s,s.next),Hh(i,i.next)}function Qh(t,e){return rl(t.prev,t,e.prev)<0&&rl(e.next,t,t.next)<0}function Kh(t,e,i,s,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function tl(t){let e=t,i=t;do{(e.x=(t-a)*(n-o)&&(t-a)*(s-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(r-a)*(s-o)}function il(t,e,i,s,r,n,a,o){return!(t===a&&e===o)&&el(t,e,i,s,r,n,a,o)}function sl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&al(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(ll(t,e)&&ll(e,t)&&function(t,e){let i=t,s=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(rl(t.prev,t,e.prev)||rl(t,e.prev,e))||nl(t,e)&&rl(t.prev,t,t.next)>0&&rl(e.prev,e,e.next)>0)}function rl(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function nl(t,e){return t.x===e.x&&t.y===e.y}function al(t,e,i,s){const r=hl(rl(t,e,i)),n=hl(rl(t,e,s)),a=hl(rl(i,s,t)),o=hl(rl(i,s,e));return r!==n&&a!==o||(!(0!==r||!ol(t,i,e))||(!(0!==n||!ol(t,s,e))||(!(0!==a||!ol(i,t,s))||!(0!==o||!ol(i,e,s)))))}function ol(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hl(t){return t>0?1:t<0?-1:0}function ll(t,e){return rl(t.prev,t,t.next)<0?rl(t,e,t.next)>=0&&rl(t,t.prev,e)>=0:rl(t,e,t.prev)<0||rl(t,t.next,e)<0}function cl(t,e){const i=pl(t.i,t.x,t.y),s=pl(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function ul(t,e,i,s){const r=pl(t,e,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function dl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function pl(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ml{static triangulate(t,e,i=2){return Uh(t,e,i)}}class yl{static area(t){const e=t.length;let i=0;for(let s=e-1,r=0;r2&&t[e-1].equals(t[0])&&t.pop()}function fl(t,e){for(let i=0;iNumber.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(h*h+l*l),p=e.x-o/u,m=e.y+a/u,y=((i.x-l/d-p)*l-(i.y+h/d-m)*h)/(a*l-o*h);s=p+a*y-t.x,r=m+o*y-t.y;const g=s*s+r*r;if(g<=2)return new Gi(s,r);n=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?h>Number.EPSILON&&(t=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(l)&&(t=!0),t?(s=-o,r=a,n=Math.sqrt(c)):(s=a,r=o,n=Math.sqrt(c/2))}return new Gi(s/n,r/n)}const k=[];for(let t=0,e=z.length,i=e-1,s=t+1;t=0;t--){const e=t/p,i=c*Math.cos(e*Math.PI/2),s=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=z.length;t=0;){const s=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=o+2*p;t0)&&d.push(e,r,h),(t!==i-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Vl extends sn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Kr(16777215),this.specular=new Kr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,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.flatShading=t.flatShading,this.fog=t.fog,this}}class Ll extends sn{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class jl extends sn{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Wl extends sn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Kr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,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(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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,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.flatShading=t.flatShading,this.fog=t.fog,this}}class Ul extends sn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Dl extends sn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Hl extends sn{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Kr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ql extends Eo{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Jl(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Xl(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Yl(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i}function Zl(t,e,i){const s=t.length,r=new t.constructor(s);for(let n=0,a=0;a!==s;++n){const s=i[n]*e;for(let i=0;i!==e;++i)r[a++]=t[s+i]}return r}function Gl(t,e,i,s){let r=1,n=t[0];for(;void 0!==n&&void 0===n[s];)n=t[r++];if(void 0===n)return;let a=n[s];if(void 0!==a)if(Array.isArray(a))do{a=n[s],void 0!==a&&(e.push(n.time),i.push(...a)),n=t[r++]}while(void 0!==n);else if(void 0!==a.toArray)do{a=n[s],void 0!==a&&(e.push(n.time),a.toArray(i,i.length)),n=t[r++]}while(void 0!==n);else do{a=n[s],void 0!==a&&(e.push(n.time),i.push(a)),n=t[r++]}while(void 0!==n)}class $l{static convertArray(t,e){return Jl(t,e)}static isTypedArray(t){return Xl(t)}static getKeyframeOrder(t){return Yl(t)}static sortedArray(t,e,i){return Zl(t,e,i)}static flattenJSON(t,e,i,s){Gl(t,e,i,s)}static subclip(t,e,i,s,r=30){return function(t,e,i,s,r=30){const n=t.clone();n.name=e;const a=[];for(let t=0;t=s)){h.push(e.times[t]);for(let i=0;in.tracks[t].times[0]&&(o=n.tracks[t].times[0]);for(let t=0;t=s.times[u]){const t=u*h+o,e=t+h-o;d=s.values.slice(t,e)}else{const t=s.createInterpolant(),e=o,i=h-o;t.evaluate(n),d=t.resultBuffer.slice(e,i)}"quaternion"===r&&(new $i).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}n=i,i=0}}for(;i>>1;te;)--n;if(++n,0!==r||n!==s){r>=n&&(n=Math.max(n,1),r=n-1);const t=this.getValueSize();this.times=i.slice(r,n),this.values=this.values.slice(r*t,n*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,s=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let n=null;for(let e=0;e!==r;e++){const s=i[e];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,s),t=!1;break}if(null!==n&&n>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,s,n),t=!1;break}n=s}if(void 0!==s&&Xl(s))for(let e=0,i=s.length;e!==i;++e){const i=s[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===Re,r=t.length-1;let n=1;for(let a=1;a0){t[n]=t[r];for(let t=r*i,s=n*i,a=0;a!==i;++a)e[s+a]=e[t+a];++n}return n!==t.length?(this.times=t.slice(0,n),this.values=e.slice(0,n*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ic.prototype.ValueTypeName="",ic.prototype.TimeBufferType=Float32Array,ic.prototype.ValueBufferType=Float32Array,ic.prototype.DefaultInterpolation=ke;class sc extends ic{constructor(t,e,i){super(t,e,i)}}sc.prototype.ValueTypeName="bool",sc.prototype.ValueBufferType=Array,sc.prototype.DefaultInterpolation=Be,sc.prototype.InterpolantFactoryMethodLinear=void 0,sc.prototype.InterpolantFactoryMethodSmooth=void 0;class rc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}rc.prototype.ValueTypeName="color";class nc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}nc.prototype.ValueTypeName="number";class ac extends Ql{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e);let h=t*a;for(let t=h+a;h!==t;h+=4)$i.slerpFlat(r,0,n,h-a,n,h,o);return r}}class oc extends ic{constructor(t,e,i,s){super(t,e,i,s)}InterpolantFactoryMethodLinear(t){return new ac(this.times,this.values,this.getValueSize(),t)}}oc.prototype.ValueTypeName="quaternion",oc.prototype.InterpolantFactoryMethodSmooth=void 0;class hc extends ic{constructor(t,e,i){super(t,e,i)}}hc.prototype.ValueTypeName="string",hc.prototype.ValueBufferType=Array,hc.prototype.DefaultInterpolation=Be,hc.prototype.InterpolantFactoryMethodLinear=void 0,hc.prototype.InterpolantFactoryMethodSmooth=void 0;class lc extends ic{constructor(t,e,i,s){super(t,e,i,s)}}lc.prototype.ValueTypeName="vector";class cc{constructor(t="",e=-1,i=[],s=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=Di(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,s=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(uc(i[t]).scale(s));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,s=i.length;t!==s;++t)e.push(ic.toJSON(i[t]));return s}static CreateFromMorphTargetSequence(t,e,i,s){const r=e.length,n=[];for(let t=0;t1){const t=n[1];let e=s[t];e||(s[t]=e=[]),e.push(i)}}const n=[];for(const t in s)n.push(this.CreateFromMorphTargetSequence(t,s[t],e,i));return n}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,s,r){if(0!==i.length){const n=[],a=[];Gl(i,n,a,s),0!==n.length&&r.push(new t(e,n,a))}},s=[],r=t.name||"default",n=t.fps||30,a=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==gc[t])return void gc[t].push({onLoad:e,onProgress:i,onError:s});gc[t]=[],gc[t].push({onLoad:e,onProgress:i,onError:s});const n=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=gc[t],s=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),n=r?parseInt(r):0,a=0!==n;let o=0;const h=new ReadableStream({start(t){!function e(){s.read().then((({done:s,value:r})=>{if(s)t.close();else{o+=r.byteLength;const s=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:n});for(let t=0,e=i.length;t{t.error(e)}))}()}});return new Response(h)}throw new fc(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(""===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,s=new TextDecoder(i);return t.arrayBuffer().then((t=>s.decode(t)))}}})).then((e=>{dc.add(t,e);const i=gc[t];delete gc[t];for(let t=0,s=i.length;t{const i=gc[t];if(void 0===i)throw this.manager.itemError(t),e;delete gc[t];for(let t=0,s=i.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class bc extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):console.error(e),r.manager.itemError(t)}}),i,s)}parse(t){const e=[];for(let i=0;i0:s.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(s.uniforms[e]={},r.type){case"t":s.uniforms[e].value=i(r.value);break;case"c":s.uniforms[e].value=(new Kr).setHex(r.value);break;case"v2":s.uniforms[e].value=(new Gi).fromArray(r.value);break;case"v3":s.uniforms[e].value=(new Qi).fromArray(r.value);break;case"v4":s.uniforms[e].value=(new zs).fromArray(r.value);break;case"m3":s.uniforms[e].value=(new es).fromArray(r.value);break;case"m4":s.uniforms[e].value=(new or).fromArray(r.value);break;default:s.uniforms[e].value=r.value}}if(void 0!==t.defines&&(s.defines=t.defines),void 0!==t.vertexShader&&(s.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(s.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(s.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)s.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(s.lights=t.lights),void 0!==t.clipping&&(s.clipping=t.clipping),void 0!==t.size&&(s.size=t.size),void 0!==t.sizeAttenuation&&(s.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(s.map=i(t.map)),void 0!==t.matcap&&(s.matcap=i(t.matcap)),void 0!==t.alphaMap&&(s.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(s.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(s.bumpScale=t.bumpScale),void 0!==t.normalMap&&(s.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(s.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),s.normalScale=(new Gi).fromArray(e)}return void 0!==t.displacementMap&&(s.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(s.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(s.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(s.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(s.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(s.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(s.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(s.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(s.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(s.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(s.envMap=i(t.envMap)),void 0!==t.envMapRotation&&s.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(s.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(s.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(s.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(s.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(s.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(s.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(s.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(s.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(s.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(s.clearcoatNormalScale=(new Gi).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(s.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(s.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(s.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(s.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(s.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return qc.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Pl,SpriteMaterial:ma,RawShaderMaterial:Ol,ShaderMaterial:Zn,PointsMaterial:Xo,MeshPhysicalMaterial:Fl,MeshStandardMaterial:Nl,MeshPhongMaterial:Vl,MeshToonMaterial:Ll,MeshNormalMaterial:jl,MeshLambertMaterial:Wl,MeshDepthMaterial:Ul,MeshDistanceMaterial:Dl,MeshBasicMaterial:rn,MeshMatcapMaterial:Hl,LineDashedMaterial:ql,LineBasicMaterial:Eo,Material:sn}[t]}}class Jc{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Xc extends Bn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Yc extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):console.error(e),r.manager.itemError(t)}}),i,s)}parse(t){const e={},i={};function s(t,s){if(void 0!==e[s])return e[s];const r=t.interleavedBuffers[s],n=function(t,e){if(void 0!==i[e])return i[e];const s=t.arrayBuffers,r=s[e],n=new Uint32Array(r).buffer;return i[e]=n,n}(t,r.buffer),a=ns(r.type,n),o=new ua(a,r.stride);return o.uuid=r.uuid,e[s]=o,o}const r=t.isInstancedBufferGeometry?new Xc:new Bn,n=t.data.index;if(void 0!==n){const t=ns(n.type,n.array);r.setIndex(new pn(t,1))}const a=t.data.attributes;for(const e in a){const i=a[e];let n;if(i.isInterleavedBufferAttribute){const e=s(t.data,i.data);n=new pa(e,i.itemSize,i.offset,i.normalized)}else{const t=ns(i.type,i.array);n=new(i.isInstancedBufferAttribute?Ya:pn)(t,i.itemSize,i.normalized)}void 0!==i.name&&(n.name=i.name),void 0!==i.usage&&n.setUsage(i.usage),r.setAttribute(e,n)}const o=t.data.morphAttributes;if(o)for(const e in o){const i=o[e],n=[];for(let e=0,r=i.length;e0){const i=new pc(e);r=new wc(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){s=new wc(this.manager),s.setCrossOrigin(this.crossOrigin);for(let e=0,s=t.length;e{let e=null,i=null;return void 0!==t.boundingBox&&(e=(new Ps).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=(new Qs).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}})),n._instanceInfo=t.instanceInfo,n._availableInstanceIds=t._availableInstanceIds,n._availableGeometryIds=t._availableGeometryIds,n._nextIndexStart=t.nextIndexStart,n._nextVertexStart=t.nextVertexStart,n._geometryCount=t.geometryCount,n._maxInstanceCount=t.maxInstanceCount,n._maxVertexCount=t.maxVertexCount,n._maxIndexCount=t.maxIndexCount,n._geometryInitialized=t.geometryInitialized,n._matricesTexture=c(t.matricesTexture.uuid),n._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(n._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(n.boundingSphere=(new Qs).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(n.boundingBox=(new Ps).fromJSON(t.boundingBox));break;case"LOD":n=new Ra;break;case"Line":n=new Wo(h(t.geometry),l(t.material));break;case"LineLoop":n=new Jo(h(t.geometry),l(t.material));break;case"LineSegments":n=new qo(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":n=new Qo(h(t.geometry),l(t.material));break;case"Sprite":n=new Ia(l(t.material));break;case"Group":n=new na;break;case"Bone":n=new Da;break;default:n=new Pr}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.up&&n.up.fromArray(t.up),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(n.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(n.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{if(!0!==Kc.has(n))return e&&e(i),r.manager.itemEnd(t),i;s&&s(Kc.get(n)),r.manager.itemError(t),r.manager.itemEnd(t)})):(setTimeout((function(){e&&e(n),r.manager.itemEnd(t)}),0),n);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){return dc.add(t,i),e&&e(i),r.manager.itemEnd(t),i})).catch((function(e){s&&s(e),Kc.set(o,e),dc.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));dc.add(t,o),r.manager.itemStart(t)}}let eu;class iu{static getContext(){return void 0===eu&&(eu=new(window.AudioContext||window.webkitAudioContext)),eu}static setContext(t){eu=t}}class su extends yc{constructor(t){super(t)}load(t,e,i,s){const r=this,n=new xc(this.manager);function a(e){s?s(e):console.error(e),r.manager.itemError(t)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,(function(t){try{const i=t.slice(0);iu.getContext().decodeAudioData(i,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),i,s)}}const ru=new or,nu=new or,au=new or;class ou{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ta,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ta,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,au.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,r=e.near*Math.tan(Wi*e.fov*.5)/e.zoom;let n,a;nu.elements[12]=-i,ru.elements[12]=i,n=-r*e.aspect+s,a=r*e.aspect+s,au.elements[0]=2*e.near/(a-n),au.elements[8]=(a+n)/(a-n),this.cameraL.projectionMatrix.copy(au),n=-r*e.aspect-s,a=r*e.aspect-s,au.elements[0]=2*e.near/(a-n),au.elements[8]=(a+n)/(a-n),this.cameraR.projectionMatrix.copy(au)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(nu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(ru)}}class hu extends ta{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class lu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=cu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=cu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function cu(){return performance.now()}const uu=new Qi,du=new $i,pu=new Qi,mu=new Qi,yu=new Qi;class gu extends Pr{constructor(){super(),this.type="AudioListener",this.context=iu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new lu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(uu,du,pu),mu.set(0,0,-1).applyQuaternion(du),yu.set(0,1,0).applyQuaternion(du),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(uu.x,t),e.positionY.linearRampToValueAtTime(uu.y,t),e.positionZ.linearRampToValueAtTime(uu.z,t),e.forwardX.linearRampToValueAtTime(mu.x,t),e.forwardY.linearRampToValueAtTime(mu.y,t),e.forwardZ.linearRampToValueAtTime(mu.z,t),e.upX.linearRampToValueAtTime(yu.x,t),e.upY.linearRampToValueAtTime(yu.y,t),e.upZ.linearRampToValueAtTime(yu.z,t)}else e.setPosition(uu.x,uu.y,uu.z),e.setOrientation(mu.x,mu.y,mu.z,yu.x,yu.y,yu.z)}}class fu extends Pr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,s);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let t=i,r=s;t!==r;++t)e[t]=e[s+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let s=0;s!==r;++s)t[e+s]=t[i+s]}_slerp(t,e,i,s){$i.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,r){const n=this._workIndex*r;$i.multiplyQuaternionsFlat(t,n,t,e,t,i),$i.slerpFlat(t,e,t,e,t,n,s)}_lerp(t,e,i,s,r){const n=1-s;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*n+t[i+a]*s}}_lerpAdditive(t,e,i,s,r){for(let n=0;n!==r;++n){const r=e+n;t[r]=t[r]+t[i+n]*s}}}const Au="\\[\\]\\.:\\/",Tu=new RegExp("["+Au+"]","g"),zu="[^"+Au+"]",Iu="[^"+Au.replace("\\.","")+"]",Cu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",zu)+/(WCOD+)?/.source.replace("WCOD",Iu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",zu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",zu)+"$"),Bu=["material","materials","bones","map"];class ku{constructor(t,e,i){this.path=e,this.parsedPath=i||ku.parseTrackName(e),this.node=ku.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new ku.Composite(t,e,i):new ku(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Tu,"")}static parseTrackName(t){const e=Cu.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){const t=i.nodeName.substring(s+1);-1!==Bu.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let s=0;s=r){const n=r++,l=t[n];e[l.uuid]=h,t[h]=l,e[o]=n,t[n]=a;for(let t=0,e=s;t!==e;++t){const e=i[t],s=e[n],r=e[h];e[h]=s,e[n]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length;let r=this.nCachedObjects_,n=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=s;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let s=i[t];const r=this._bindings;if(void 0!==s)return r[s];const n=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);s=r.length,i[t]=s,n.push(t),a.push(e),r.push(c);for(let i=l,s=o.length;i!==s;++i){const s=o[i];c[i]=new ku(s,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const s=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length-1,o=n[a];e[t[a]]=i,n[i]=o,n.pop(),r[i]=r[a],r.pop(),s[i]=s[a],s.pop()}}}class Eu{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const r=e.tracks,n=r.length,a=new Array(n),o={endingStart:Ee,endingEnd:Ee};for(let t=0;t!==n;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),!0===i){const i=this._clip.duration,s=t._clip.duration,r=s/i,n=i/s;t.warp(1,r,e),this.warp(n,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const s=this._mixer,r=s.time,n=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=t/n,h[1]=e/n,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const s=(t-r)*i;s<0||0===i?e=0:(this._startTime=null,e=i*s)}e*=this._updateTimeScale(t);const n=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Fe)for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(n),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(n),e[i].accumulate(s,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let s=this.time+t,r=this._loopCount;const n=2202===i;if(0===t)return-1===r||!n||1&~r?s:e-s;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else{if(!(s<0)){this.time=s;break t}s=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),s>=e||s<0){const i=Math.floor(s/e);s-=e*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=s;if(n&&!(1&~r))return e-s}return s}_setEndings(t,e,i){const s=this._interpolantSettings;i?(s.endingStart=Pe,s.endingEnd=Pe):(s.endingStart=t?this.zeroSlopeAtStart?Pe:Ee:Oe,s.endingEnd=e?this.zeroSlopeAtEnd?Pe:Ee:Oe)}_scheduleFading(t,e,i){const s=this._mixer,r=s.time;let n=this._weightInterpolant;null===n&&(n=s._lendControlInterpolant(),this._weightInterpolant=n);const a=n.parameterPositions,o=n.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}const Pu=new Float32Array(1);class Ou extends Vi{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,s=t._clip.tracks,r=s.length,n=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=s[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,n[t]=c;else{if(c=n[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const s=e&&e._propertyBindings[t].binding.parsedPath;c=new _u(ku.create(i,h,s),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),n[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,s=this.time+=t,r=Math.sign(t),n=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(s,t,r,n)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(n);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}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}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Zu).distanceTo(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}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)}}const $u=new Qi,Qu=new Qi;class Ku{constructor(t=new Qi,e=new Qi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){$u.subVectors(t,this.start),Qu.subVectors(this.end,this.start);const i=Qu.dot(Qu);let s=Qu.dot($u)/i;return e&&(s=Hi(s,0,1)),s}closestPointToPoint(t,e,i){const s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const td=new Qi;class ed extends Pr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new Bn,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t1)for(let i=0;i.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Td.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Td,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Bd extends qo{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Bn;i.setAttribute("position",new Mn(e,3)),i.setAttribute("color",new Mn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new Eo({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){const s=new Kr,r=this.geometry.attributes.color.array;return s.set(t),s.toArray(r,0),s.toArray(r,3),s.set(e),s.toArray(r,6),s.toArray(r,9),s.set(i),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class kd{constructor(){this.type="ShapePath",this.color=new Kr,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new jh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,r,n){return this.currentPath.bezierCurveTo(t,e,i,s,r,n),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const i=e.length;let s=!1;for(let r=i-1,n=0;nNumber.EPSILON){if(h<0&&(i=e[n],o=-o,a=e[r],h=-h),t.ya.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;s=!s}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return s}const i=yl.isClockWise,s=this.subPaths;if(0===s.length)return[];let r,n,a;const o=[];if(1===s.length)return n=s[0],a=new Wh,a.curves=n.curves,o.push(a),o;let h=!i(s[0].getPoints());h=t?!h:h;const l=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=s.length;e1){let t=!1,i=0;for(let t=0,e=c.length;t0&&!1===t&&(p=l)}for(let t=0,e=c.length;te?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const i=t.image&&t.image.width?t.image.width/t.image.height:1;return i>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,i,s){return Ed(t,e,i,s)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);export{et as ACESFilmicToneMapping,v as AddEquation,G as AddOperation,Fe as AdditiveAnimationBlendMode,g as AdditiveBlending,st as AgXToneMapping,Vt as AlphaFormat,wi as AlwaysCompare,W as AlwaysDepth,pi as AlwaysStencilFunc,Wc as AmbientLight,Eu as AnimationAction,cc as AnimationClip,bc as AnimationLoader,Ou as AnimationMixer,Ru as AnimationObjectGroup,$l as AnimationUtils,wh as ArcCurve,hu as ArrayCamera,Cd as ArrowHelper,nt as AttachedBindMode,fu as Audio,Su as AudioAnalyser,iu as AudioContext,gu as AudioListener,su as AudioLoader,Bd as AxesHelper,d as BackSide,We as BasicDepthPacking,o as BasicShadowMap,Ro as BatchedMesh,Da as Bone,sc as BooleanKeyframeTrack,Gu as Box2,Ps as Box3,_d as Box3Helper,Hn as BoxGeometry,Sd as BoxHelper,pn as BufferAttribute,Bn as BufferGeometry,Yc as BufferGeometryLoader,zt as ByteType,dc as Cache,Gn as Camera,vd as CameraHelper,ah as CanvasTexture,hh as CapsuleGeometry,zh as CatmullRomCurve3,tt as CineonToneMapping,lh as CircleGeometry,mt as ClampToEdgeWrapping,lu as Clock,Kr as Color,rc as ColorKeyframeTrack,gs as ColorManagement,rh as CompressedArrayTexture,nh as CompressedCubeTexture,sh as CompressedTexture,vc as CompressedTextureLoader,uh as ConeGeometry,V as ConstantAlphaFactor,N as ConstantColorFactor,Rd as Controls,ia as CubeCamera,ht as CubeReflectionMapping,lt as CubeRefractionMapping,sa as CubeTexture,Mc as CubeTextureLoader,dt as CubeUVReflectionMapping,kh as CubicBezierCurve,Rh as CubicBezierCurve3,Kl as CubicInterpolant,r as CullFaceBack,n as CullFaceFront,a as CullFaceFrontBack,s as CullFaceNone,bh as Curve,Lh as CurvePath,b as CustomBlending,it as CustomToneMapping,ch as CylinderGeometry,Xu as Cylindrical,Rs as Data3DTexture,Bs as DataArrayTexture,Ha as DataTexture,Sc as DataTextureLoader,ln as DataUtils,ii as DecrementStencilOp,ri as DecrementWrapStencilOp,mc as DefaultLoadingManager,Wt as DepthFormat,Ut as DepthStencilFormat,oh as DepthTexture,at as DetachedBindMode,jc as DirectionalLight,fd as DirectionalLightHelper,ec as DiscreteInterpolant,ph as DodecahedronGeometry,p as DoubleSide,k as DstAlphaFactor,E as DstColorFactor,Ci as DynamicCopyUsage,Si as DynamicDrawUsage,Ti as DynamicReadUsage,xh as EdgesGeometry,vh as EllipseCurve,gi as EqualCompare,H as EqualDepth,hi as EqualStencilFunc,ct as EquirectangularReflectionMapping,ut as EquirectangularRefractionMapping,fr as Euler,Vi as EventDispatcher,xl as ExtrudeGeometry,xc as FileLoader,wn as Float16BufferAttribute,Mn as Float32BufferAttribute,Rt as FloatType,la as Fog,ha as FogExp2,ih as FramebufferTexture,u as FrontSide,lo as Frustum,po as FrustumArray,Wu as GLBufferAttribute,ki as GLSL1,Ri as GLSL3,xi as GreaterCompare,J as GreaterDepth,vi as GreaterEqualCompare,q as GreaterEqualDepth,di as GreaterEqualStencilFunc,ci as GreaterStencilFunc,dd as GridHelper,na as Group,Et as HalfFloatType,Tc as HemisphereLight,ud as HemisphereLightHelper,vl as IcosahedronGeometry,tu as ImageBitmapLoader,wc as ImageLoader,vs as ImageUtils,ei as IncrementStencilOp,si as IncrementWrapStencilOp,Ya as InstancedBufferAttribute,Xc as InstancedBufferGeometry,ju as InstancedInterleavedBuffer,io as InstancedMesh,fn as Int16BufferAttribute,bn as Int32BufferAttribute,mn as Int8BufferAttribute,Bt as IntType,ua as InterleavedBuffer,pa as InterleavedBufferAttribute,Ql as Interpolant,Be as InterpolateDiscrete,ke as InterpolateLinear,Re as InterpolateSmooth,Fi as InterpolationSamplingMode,Ni as InterpolationSamplingType,ni as InvertStencilOp,Ke as KeepStencilOp,ic as KeyframeTrack,Ra as LOD,wl as LatheGeometry,xr as Layers,yi as LessCompare,U as LessDepth,fi as LessEqualCompare,D as LessEqualDepth,li as LessEqualStencilFunc,oi as LessStencilFunc,Ac as Light,Hc as LightProbe,Wo as Line,Ku as Line3,Eo as LineBasicMaterial,Eh as LineCurve,Ph as LineCurve3,ql as LineDashedMaterial,Jo as LineLoop,qo as LineSegments,wt as LinearFilter,tc as LinearInterpolant,At as LinearMipMapLinearFilter,St as LinearMipMapNearestFilter,_t as LinearMipmapLinearFilter,Mt as LinearMipmapNearestFilter,Ze as LinearSRGBColorSpace,Q as LinearToneMapping,Ge as LinearTransfer,yc as Loader,Jc as LoaderUtils,pc as LoadingManager,ze as LoopOnce,Ce as LoopPingPong,Ie as LoopRepeat,e as MOUSE,sn as Material,qc as MaterialLoader,Zi as MathUtils,Yu as Matrix2,es as Matrix3,or as Matrix4,_ as MaxEquation,Un as Mesh,rn as MeshBasicMaterial,Ul as MeshDepthMaterial,Dl as MeshDistanceMaterial,Wl as MeshLambertMaterial,Hl as MeshMatcapMaterial,jl as MeshNormalMaterial,Vl as MeshPhongMaterial,Fl as MeshPhysicalMaterial,Nl as MeshStandardMaterial,Ll as MeshToonMaterial,S as MinEquation,yt as MirroredRepeatWrapping,Z as MixOperation,x as MultiplyBlending,Y as MultiplyOperation,gt as NearestFilter,vt as NearestMipMapLinearFilter,xt as NearestMipMapNearestFilter,bt as NearestMipmapLinearFilter,ft as NearestMipmapNearestFilter,rt as NeutralToneMapping,mi as NeverCompare,j as NeverDepth,ai as NeverStencilFunc,m as NoBlending,Xe as NoColorSpace,$ as NoToneMapping,Ne as NormalAnimationBlendMode,y as NormalBlending,bi as NotEqualCompare,X as NotEqualDepth,ui as NotEqualStencilFunc,nc as NumberKeyframeTrack,Pr as Object3D,Zc as ObjectLoader,Je as ObjectSpaceNormalMap,Ml as OctahedronGeometry,T as OneFactor,L as OneMinusConstantAlphaFactor,F as OneMinusConstantColorFactor,R as OneMinusDstAlphaFactor,P as OneMinusDstColorFactor,B as OneMinusSrcAlphaFactor,I as OneMinusSrcColorFactor,Vc as OrthographicCamera,h as PCFShadowMap,l as PCFSoftShadowMap,jh as Path,ta as PerspectiveCamera,ao as Plane,Sl as PlaneGeometry,Ad as PlaneHelper,Fc as PointLight,od as PointLightHelper,Qo as Points,Xo as PointsMaterial,pd as PolarGridHelper,dh as PolyhedronGeometry,Mu as PositionalAudio,ku as PropertyBinding,_u as PropertyMixer,Oh as QuadraticBezierCurve,Nh as QuadraticBezierCurve3,$i as Quaternion,oc as QuaternionKeyframeTrack,ac as QuaternionLinearInterpolant,Ui as RAD2DEG,Ae as RED_GREEN_RGTC2_Format,Se as RED_RGTC1_Format,t as REVISION,Ue as RGBADepthPacking,jt as RGBAFormat,Yt as RGBAIntegerFormat,fe as RGBA_ASTC_10x10_Format,me as RGBA_ASTC_10x5_Format,ye as RGBA_ASTC_10x6_Format,ge as RGBA_ASTC_10x8_Format,xe as RGBA_ASTC_12x10_Format,be as RGBA_ASTC_12x12_Format,ae as RGBA_ASTC_4x4_Format,oe as RGBA_ASTC_5x4_Format,he as RGBA_ASTC_5x5_Format,le as RGBA_ASTC_6x5_Format,ce as RGBA_ASTC_6x6_Format,ue as RGBA_ASTC_8x5_Format,de as RGBA_ASTC_8x6_Format,pe as RGBA_ASTC_8x8_Format,ve as RGBA_BPTC_Format,ne as RGBA_ETC2_EAC_Format,ie as RGBA_PVRTC_2BPPV1_Format,ee as RGBA_PVRTC_4BPPV1_Format,Gt as RGBA_S3TC_DXT1_Format,$t as RGBA_S3TC_DXT3_Format,Qt as RGBA_S3TC_DXT5_Format,De as RGBDepthPacking,Lt as RGBFormat,Xt as RGBIntegerFormat,we as RGB_BPTC_SIGNED_Format,Me as RGB_BPTC_UNSIGNED_Format,se as RGB_ETC1_Format,re as RGB_ETC2_Format,te as RGB_PVRTC_2BPPV1_Format,Kt as RGB_PVRTC_4BPPV1_Format,Zt as RGB_S3TC_DXT1_Format,He as RGDepthPacking,qt as RGFormat,Jt as RGIntegerFormat,Ol as RawShaderMaterial,ar as Ray,Du as Raycaster,Uc as RectAreaLight,Dt as RedFormat,Ht as RedIntegerFormat,K as ReinhardToneMapping,Is as RenderTarget,Nu as RenderTarget3D,pt as RepeatWrapping,ti as ReplaceStencilOp,M as ReverseSubtractEquation,_l as RingGeometry,Te as SIGNED_RED_GREEN_RGTC2_Format,_e as SIGNED_RED_RGTC1_Format,Ye as SRGBColorSpace,$e as SRGBTransfer,ca as Scene,Zn as ShaderMaterial,Pl as ShadowMaterial,Wh as Shape,Al as ShapeGeometry,kd as ShapePath,yl as ShapeUtils,It as ShortType,Xa as Skeleton,nd as SkeletonHelper,Ua as SkinnedMesh,Ms as Source,Qs as Sphere,Tl as SphereGeometry,Ju as Spherical,Dc as SphericalHarmonics3,Fh as SplineCurve,Rc as SpotLight,ed as SpotLightHelper,Ia as Sprite,ma as SpriteMaterial,C as SrcAlphaFactor,O as SrcAlphaSaturateFactor,z as SrcColorFactor,Ii as StaticCopyUsage,Mi as StaticDrawUsage,Ai as StaticReadUsage,ou as StereoCamera,Bi as StreamCopyUsage,_i as StreamDrawUsage,zi as StreamReadUsage,hc as StringKeyframeTrack,w as SubtractEquation,f as SubtractiveBlending,i as TOUCH,qe as TangentSpaceNormalMap,zl as TetrahedronGeometry,Ts as Texture,_c as TextureLoader,Pd as TextureUtils,Oi as TimestampQuery,Il as TorusGeometry,Cl as TorusKnotGeometry,Yr as Triangle,je as TriangleFanDrawMode,Le as TriangleStripDrawMode,Ve as TrianglesDrawMode,Bl as TubeGeometry,ot as UVMapping,xn as Uint16BufferAttribute,vn as Uint32BufferAttribute,yn as Uint8BufferAttribute,gn as Uint8ClampedBufferAttribute,Fu as Uniform,Lu as UniformsGroup,Yn as UniformsUtils,Tt as UnsignedByteType,Nt as UnsignedInt248Type,Ft as UnsignedInt5999Type,kt as UnsignedIntType,Pt as UnsignedShort4444Type,Ot as UnsignedShort5551Type,Ct as UnsignedShortType,c as VSMShadowMap,Gi as Vector2,Qi as Vector3,zs as Vector4,lc as VectorKeyframeTrack,eh as VideoFrameTexture,th as VideoTexture,Es as WebGL3DRenderTarget,ks as WebGLArrayRenderTarget,Ei as WebGLCoordinateSystem,ra as WebGLCubeRenderTarget,Cs as WebGLRenderTarget,Pi as WebGPUCoordinateSystem,oa as WebXRController,kl as WireframeGeometry,Oe as WrapAroundEnding,Ee as ZeroCurvatureEnding,A as ZeroFactor,Pe as ZeroSlopeEnding,Qe as ZeroStencilOp,ss as arrayNeedsUint32,qn as cloneUniforms,os as createCanvasElement,as as createElementNS,Ed as getByteLength,Xn as getUnlitUniformColorSpace,Jn as mergeUniforms,cs as probeAsync,us as toNormalizedProjectionMatrix,ds as toReversedProjectionMatrix,ls as warnOnce}; diff --git a/build/three.webgpu.js b/build/three.webgpu.js index 1a029644bd4102..f92e38fb5cbebc 100644 --- a/build/three.webgpu.js +++ b/build/three.webgpu.js @@ -3196,7 +3196,7 @@ const ShaderNodeObject = function ( obj, altType = null ) { } else if ( type === 'shader' ) { - return Fn( obj ); + return obj.isFn ? obj : Fn( obj ); } @@ -3673,6 +3673,8 @@ const Fn = ( jsFunc, layout = null ) => { fn.shaderNode = shaderNode; fn.id = shaderNode.id; + fn.isFn = true; + fn.getNodeType = ( ...params ) => shaderNode.getNodeType( ...params ); fn.getCacheKey = ( ...params ) => shaderNode.getCacheKey( ...params ); @@ -11685,7 +11687,7 @@ const objectViewPosition = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.V * @tsl * @function * @param {?Object3D} [object3d] - The 3D object. - * @returns {Object3DNode} + * @returns {Object3DNode} */ const objectRadius = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.RADIUS ).setParameterLength( 1 ); @@ -49178,10 +49180,11 @@ class XRRenderTarget extends RenderTarget { * are defined by external textures. This flag is * set to `true` when using the WebXR Layers API. * + * @private * @type {boolean} * @default false */ - this.hasExternalTextures = false; + this._hasExternalTextures = false; /** * Whether a depth buffer should automatically be allocated @@ -49194,10 +49197,25 @@ class XRRenderTarget extends RenderTarget { * * Reference: {@link https://www.w3.org/TR/webxrlayers-1/#dom-xrprojectionlayer-ignoredepthvalues}. * + * @private * @type {boolean} * @default true */ - this.autoAllocateDepthBuffer = true; + this._autoAllocateDepthBuffer = true; + + /** + * Whether this render target is associated with a XRWebGLLayer. + * + * A XRWebGLLayer points to an opaque framebuffer. Basically, + * this means that you don't have access to its bound color, + * stencil and depth buffers. We need to handle this framebuffer + * differently since its textures are always bound. + * + * @private + * @type {boolean} + * @default false + * */ + this._isOpaqueFramebuffer = false; } @@ -49205,8 +49223,9 @@ class XRRenderTarget extends RenderTarget { super.copy( source ); - this.hasExternalTextures = source.hasExternalTextures; - this.autoAllocateDepthBuffer = source.autoAllocateDepthBuffer; + this._hasExternalTextures = source._hasExternalTextures; + this._autoAllocateDepthBuffer = source._autoAllocateDepthBuffer; + this._isOpaqueFramebuffer = source._isOpaqueFramebuffer; return this; @@ -49839,7 +49858,7 @@ class XRManager extends EventDispatcher { resolveStencilBuffer: false } ); - renderTarget.autoAllocateDepthBuffer = true; + renderTarget._autoAllocateDepthBuffer = true; const material = new MeshBasicMaterial( { color: 0xffffff, side: FrontSide } ); material.map = renderTarget.texture; @@ -49930,7 +49949,7 @@ class XRManager extends EventDispatcher { resolveStencilBuffer: false } ); - renderTarget.autoAllocateDepthBuffer = true; + renderTarget._autoAllocateDepthBuffer = true; const material = new MeshBasicMaterial( { color: 0xffffff, side: BackSide } ); material.map = renderTarget.texture; @@ -50004,7 +50023,7 @@ class XRManager extends EventDispatcher { for ( const layer of this._layers ) { layer.renderTarget.isXRRenderTarget = this._session !== null; - layer.renderTarget.hasExternalTextures = layer.renderTarget.isXRRenderTarget; + layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget; if ( layer.renderTarget.isXRRenderTarget && this._supportsLayers ) { @@ -50172,7 +50191,7 @@ class XRManager extends EventDispatcher { multiview: this._useMultiview } ); - this._xrRenderTarget.hasExternalTextures = true; + this._xrRenderTarget._hasExternalTextures = true; this._xrRenderTarget.depth = this._useMultiview ? 2 : 1; this._supportsLayers = session.enabledFeatures.includes( 'layers' ); @@ -50234,6 +50253,7 @@ class XRManager extends EventDispatcher { } ); + this._xrRenderTarget._isOpaqueFramebuffer = true; this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() ); } @@ -52061,7 +52081,7 @@ class Renderer { frameBufferTarget.scissorTest = this._scissorTest; frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false; frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true; - frameBufferTarget.autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.autoAllocateDepthBuffer : false; + frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false; return frameBufferTarget; @@ -54913,9 +54933,7 @@ const interpolationTypeMap = { }; const interpolationModeMap = { - 'centroid': 'centroid', - 'flat first': 'flat', - 'flat either': 'flat' + 'centroid': 'centroid' }; const defaultPrecisions = ` @@ -60982,13 +61000,13 @@ class WebGLBackend extends Backend { // The multisample_render_to_texture extension doesn't work properly if there // are midframe flushes and an external depth texture. - if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget.autoAllocateDepthBuffer === true && renderTarget.multiview === false ) { + if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget._autoAllocateDepthBuffer === true && renderTarget.multiview === false ) { console.warn( 'THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided' ); } - renderTarget.autoAllocateDepthBuffer = false; + renderTarget._autoAllocateDepthBuffer = false; } @@ -61161,18 +61179,24 @@ class WebGLBackend extends Backend { } this._currentContext = previousContext; + const renderTarget = renderContext.renderTarget; - if ( renderContext.textures !== null && renderContext.renderTarget ) { - - const renderTargetContextData = this.get( renderContext.renderTarget ); + if ( renderContext.textures !== null && renderTarget ) { - const { resolveDepthBuffer, samples } = renderContext.renderTarget; + const renderTargetContextData = this.get( renderTarget ); - if ( samples > 0 && this._useMultisampledExtension( renderContext.renderTarget ) === false ) { + if ( renderTarget.samples > 0 && this._useMultisampledExtension( renderTarget ) === false ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; - const mask = gl.COLOR_BUFFER_BIT; + let mask = gl.COLOR_BUFFER_BIT; + + if ( renderTarget.resolveDepthBuffer ) { + + if ( renderTarget.depthBuffer ) mask |= gl.DEPTH_BUFFER_BIT; + if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= gl.STENCIL_BUFFER_BIT; + + } const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer; @@ -61213,7 +61237,7 @@ class WebGLBackend extends Backend { } - } else if ( resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { + } else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb ); @@ -62620,7 +62644,7 @@ class WebGLBackend extends Backend { const isRenderTarget3D = renderTarget.isRenderTarget3D === true; const isRenderTargetArray = renderTarget.depth > 1; const isXRRenderTarget = renderTarget.isXRRenderTarget === true; - const hasExternalTextures = ( isXRRenderTarget === true && renderTarget.hasExternalTextures === true ); + const _hasExternalTextures = ( isXRRenderTarget === true && renderTarget._hasExternalTextures === true ); let msaaFb = renderTargetContextData.msaaFrameBuffer; let depthRenderbuffer = renderTargetContextData.depthRenderbuffer; @@ -62637,7 +62661,7 @@ class WebGLBackend extends Backend { fb = renderTargetContextData.cubeFramebuffers[ cacheKey ]; - } else if ( isXRRenderTarget && hasExternalTextures === false ) { + } else if ( isXRRenderTarget && _hasExternalTextures === false ) { fb = this._xrFramebuffer; @@ -62713,7 +62737,7 @@ class WebGLBackend extends Backend { const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; - if ( renderTarget.autoAllocateDepthBuffer === true ) { + if ( renderTarget._autoAllocateDepthBuffer === true ) { const renderbuffer = gl.createRenderbuffer(); this.textureUtils.setupRenderBufferStorage( renderbuffer, descriptor, 0, useMultisampledRTT ); @@ -62738,7 +62762,7 @@ class WebGLBackend extends Backend { multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, samples, 0, 2 ); - } else if ( hasExternalTextures && useMultisampledRTT ) { + } else if ( _hasExternalTextures && useMultisampledRTT ) { multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0, samples ); @@ -62789,7 +62813,7 @@ class WebGLBackend extends Backend { // rebind external XR textures - if ( isXRRenderTarget || useMultisampledRTT || renderTarget.multiview ) { + if ( ( isXRRenderTarget || useMultisampledRTT || renderTarget.multiview ) && ( renderTarget._isOpaqueFramebuffer !== true ) ) { state.bindFramebuffer( gl.FRAMEBUFFER, fb ); @@ -62815,7 +62839,7 @@ class WebGLBackend extends Backend { const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; - if ( renderTarget.autoAllocateDepthBuffer === true ) { + if ( renderTarget._autoAllocateDepthBuffer === true ) { const renderbuffer = renderTargetContextData.xrDepthRenderbuffer; gl.bindRenderbuffer( gl.RENDERBUFFER, renderbuffer ); @@ -63146,7 +63170,7 @@ class WebGLBackend extends Backend { } - return renderTarget.samples > 0 && this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTarget.autoAllocateDepthBuffer !== false; + return renderTarget.samples > 0 && this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTarget._autoAllocateDepthBuffer !== false; } diff --git a/build/three.webgpu.min.js b/build/three.webgpu.min.js index 9869aa977a29d5..e1e98dde5549d9 100644 --- a/build/three.webgpu.min.js +++ b/build/three.webgpu.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -import{Color as e,Vector2 as t,Vector3 as r,Vector4 as s,Matrix2 as i,Matrix3 as n,Matrix4 as a,EventDispatcher as o,MathUtils as u,WebGLCoordinateSystem as l,WebGPUCoordinateSystem as d,ColorManagement as c,SRGBTransfer as h,NoToneMapping as p,StaticDrawUsage as g,InterleavedBuffer as m,InterleavedBufferAttribute as f,DynamicDrawUsage as y,NoColorSpace as x,Texture as b,UnsignedIntType as T,IntType as _,NearestFilter as v,Sphere as N,BackSide as S,Euler as w,CubeTexture as E,CubeReflectionMapping as A,CubeRefractionMapping as R,TangentSpaceNormalMap as C,ObjectSpaceNormalMap as M,InstancedInterleavedBuffer as P,InstancedBufferAttribute as L,DataArrayTexture as F,FloatType as B,FramebufferTexture as I,LinearMipmapLinearFilter as D,DepthTexture as V,Material as U,NormalBlending as O,LineBasicMaterial as k,LineDashedMaterial as G,NoBlending as z,MeshNormalMaterial as H,SRGBColorSpace as $,WebGLCubeRenderTarget as W,BoxGeometry as j,Mesh as q,Scene as X,LinearFilter as K,CubeCamera as Y,EquirectangularReflectionMapping as Q,EquirectangularRefractionMapping as Z,AddOperation as J,MixOperation as ee,MultiplyOperation as te,MeshBasicMaterial as re,MeshLambertMaterial as se,MeshPhongMaterial as ie,OrthographicCamera as ne,PerspectiveCamera as ae,RenderTarget as oe,LinearSRGBColorSpace as ue,RGBAFormat as le,HalfFloatType as de,CubeUVReflectionMapping as ce,BufferGeometry as he,BufferAttribute as pe,MeshStandardMaterial as ge,MeshPhysicalMaterial as me,MeshToonMaterial as fe,MeshMatcapMaterial as ye,SpriteMaterial as xe,PointsMaterial as be,ShadowMaterial as Te,Uint32BufferAttribute as _e,Uint16BufferAttribute as ve,arrayNeedsUint32 as Ne,DoubleSide as Se,Camera as we,DepthStencilFormat as Ee,DepthFormat as Ae,UnsignedInt248Type as Re,UnsignedByteType as Ce,Plane as Me,Object3D as Pe,LinearMipMapLinearFilter as Le,Float32BufferAttribute as Fe,UVMapping as Be,VSMShadowMap as Ie,LessCompare as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as ke,NearestMipmapLinearFilter as Ge,Float16BufferAttribute as ze,REVISION as He,ArrayCamera as $e,PlaneGeometry as We,FrontSide as je,CustomBlending as qe,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,Quaternion as Qe,WebXRController as Ze,RAD2DEG as Je,PCFShadowMap as et,FrustumArray as tt,Frustum as rt,DataTexture as st,RedIntegerFormat as it,RedFormat as nt,ShortType as at,ByteType as ot,UnsignedShortType as ut,RGIntegerFormat as lt,RGBIntegerFormat as dt,RGBFormat as ct,RGBAIntegerFormat as ht,warnOnce as pt,createCanvasElement as gt,ReverseSubtractEquation as mt,SubtractEquation as ft,OneMinusDstAlphaFactor as yt,OneMinusDstColorFactor as xt,OneMinusSrcAlphaFactor as bt,OneMinusSrcColorFactor as Tt,DstAlphaFactor as _t,DstColorFactor as vt,SrcAlphaSaturateFactor as Nt,SrcAlphaFactor as St,SrcColorFactor as wt,OneFactor as Et,CullFaceNone as At,CullFaceBack as Rt,CullFaceFront as Ct,MultiplyBlending as Mt,SubtractiveBlending as Pt,AdditiveBlending as Lt,NotEqualDepth as Ft,GreaterDepth as Bt,GreaterEqualDepth as It,EqualDepth as Dt,LessEqualDepth as Vt,LessDepth as Ut,AlwaysDepth as Ot,NeverDepth as kt,UnsignedShort4444Type as Gt,UnsignedShort5551Type as zt,UnsignedInt5999Type as Ht,AlphaFormat as $t,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as jt,RGBA_S3TC_DXT3_Format as qt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Kt,RGB_PVRTC_2BPPV1_Format as Yt,RGBA_PVRTC_4BPPV1_Format as Qt,RGBA_PVRTC_2BPPV1_Format as Zt,RGB_ETC1_Format as Jt,RGB_ETC2_Format as er,RGBA_ETC2_EAC_Format as tr,RGBA_ASTC_4x4_Format as rr,RGBA_ASTC_5x4_Format as sr,RGBA_ASTC_5x5_Format as ir,RGBA_ASTC_6x5_Format as nr,RGBA_ASTC_6x6_Format as ar,RGBA_ASTC_8x5_Format as or,RGBA_ASTC_8x6_Format as ur,RGBA_ASTC_8x8_Format as lr,RGBA_ASTC_10x5_Format as dr,RGBA_ASTC_10x6_Format as cr,RGBA_ASTC_10x8_Format as hr,RGBA_ASTC_10x10_Format as pr,RGBA_ASTC_12x10_Format as gr,RGBA_ASTC_12x12_Format as mr,RGBA_BPTC_Format as fr,RED_RGTC1_Format as yr,SIGNED_RED_RGTC1_Format as xr,RED_GREEN_RGTC2_Format as br,SIGNED_RED_GREEN_RGTC2_Format as Tr,MirroredRepeatWrapping as _r,ClampToEdgeWrapping as vr,RepeatWrapping as Nr,NearestMipmapNearestFilter as Sr,NotEqualCompare as wr,GreaterCompare as Er,GreaterEqualCompare as Ar,EqualCompare as Rr,LessEqualCompare as Cr,AlwaysCompare as Mr,NeverCompare as Pr,LinearTransfer as Lr,NotEqualStencilFunc as Fr,GreaterStencilFunc as Br,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as kr,DecrementWrapStencilOp as Gr,IncrementWrapStencilOp as zr,DecrementStencilOp as Hr,IncrementStencilOp as $r,InvertStencilOp as Wr,ReplaceStencilOp as jr,ZeroStencilOp as qr,KeepStencilOp as Xr,MaxEquation as Kr,MinEquation as Yr,SpotLight as Qr,PointLight as Zr,DirectionalLight as Jr,RectAreaLight as es,AmbientLight as ts,HemisphereLight as rs,LightProbe as ss,LinearToneMapping as is,ReinhardToneMapping as ns,CineonToneMapping as as,ACESFilmicToneMapping as os,AgXToneMapping as us,NeutralToneMapping as ls,Group as ds,Loader as cs,FileLoader as hs,MaterialLoader as ps,ObjectLoader as gs}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,ConstantAlphaFactor,ConstantColorFactor,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CustomToneMapping,Cylindrical,Data3DTexture,DataTextureLoader,DataUtils,DefaultLoadingManager,DetachedBindMode,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,MeshDepthMaterial,MeshDistanceMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NormalAnimationBlendMode,NumberKeyframeTrack,OctahedronGeometry,OneMinusConstantAlphaFactor,OneMinusConstantColorFactor,PCFSoftShadowMap,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format,RGDepthPacking,RawShaderMaterial,Ray,Raycaster,RenderTarget3D,RingGeometry,ShaderMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Spherical,SphericalHarmonics3,SplineCurve,SpotLightHelper,Sprite,StaticCopyUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding}from"./three.core.min.js";const ms=["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 fs{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=ms,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const jd=Ui(Wd,Wd.ALPHA_TEST),qd=Ui(Wd,Wd.COLOR),Xd=Ui(Wd,Wd.SHININESS),Kd=Ui(Wd,Wd.EMISSIVE),Yd=Ui(Wd,Wd.OPACITY),Qd=Ui(Wd,Wd.SPECULAR),Zd=Ui(Wd,Wd.SPECULAR_INTENSITY),Jd=Ui(Wd,Wd.SPECULAR_COLOR),ec=Ui(Wd,Wd.SPECULAR_STRENGTH),tc=Ui(Wd,Wd.REFLECTIVITY),rc=Ui(Wd,Wd.ROUGHNESS),sc=Ui(Wd,Wd.METALNESS),ic=Ui(Wd,Wd.NORMAL),nc=Ui(Wd,Wd.CLEARCOAT),ac=Ui(Wd,Wd.CLEARCOAT_ROUGHNESS),oc=Ui(Wd,Wd.CLEARCOAT_NORMAL),uc=Ui(Wd,Wd.ROTATION),lc=Ui(Wd,Wd.SHEEN),dc=Ui(Wd,Wd.SHEEN_ROUGHNESS),cc=Ui(Wd,Wd.ANISOTROPY),hc=Ui(Wd,Wd.IRIDESCENCE),pc=Ui(Wd,Wd.IRIDESCENCE_IOR),gc=Ui(Wd,Wd.IRIDESCENCE_THICKNESS),mc=Ui(Wd,Wd.TRANSMISSION),fc=Ui(Wd,Wd.THICKNESS),yc=Ui(Wd,Wd.IOR),xc=Ui(Wd,Wd.ATTENUATION_DISTANCE),bc=Ui(Wd,Wd.ATTENUATION_COLOR),Tc=Ui(Wd,Wd.LINE_SCALE),_c=Ui(Wd,Wd.LINE_DASH_SIZE),vc=Ui(Wd,Wd.LINE_GAP_SIZE),Nc=Ui(Wd,Wd.LINE_WIDTH),Sc=Ui(Wd,Wd.LINE_DASH_OFFSET),wc=Ui(Wd,Wd.POINT_SIZE),Ec=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e.autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e.autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(e.renderTarget)){const i=s.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT,a=s.msaaFrameBuffer,o=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i.hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e.autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const jd=Ui(Wd,Wd.ALPHA_TEST),qd=Ui(Wd,Wd.COLOR),Xd=Ui(Wd,Wd.SHININESS),Kd=Ui(Wd,Wd.EMISSIVE),Yd=Ui(Wd,Wd.OPACITY),Qd=Ui(Wd,Wd.SPECULAR),Zd=Ui(Wd,Wd.SPECULAR_INTENSITY),Jd=Ui(Wd,Wd.SPECULAR_COLOR),ec=Ui(Wd,Wd.SPECULAR_STRENGTH),tc=Ui(Wd,Wd.REFLECTIVITY),rc=Ui(Wd,Wd.ROUGHNESS),sc=Ui(Wd,Wd.METALNESS),ic=Ui(Wd,Wd.NORMAL),nc=Ui(Wd,Wd.CLEARCOAT),ac=Ui(Wd,Wd.CLEARCOAT_ROUGHNESS),oc=Ui(Wd,Wd.CLEARCOAT_NORMAL),uc=Ui(Wd,Wd.ROTATION),lc=Ui(Wd,Wd.SHEEN),dc=Ui(Wd,Wd.SHEEN_ROUGHNESS),cc=Ui(Wd,Wd.ANISOTROPY),hc=Ui(Wd,Wd.IRIDESCENCE),pc=Ui(Wd,Wd.IRIDESCENCE_IOR),gc=Ui(Wd,Wd.IRIDESCENCE_THICKNESS),mc=Ui(Wd,Wd.TRANSMISSION),fc=Ui(Wd,Wd.THICKNESS),yc=Ui(Wd,Wd.IOR),xc=Ui(Wd,Wd.ATTENUATION_DISTANCE),bc=Ui(Wd,Wd.ATTENUATION_COLOR),Tc=Ui(Wd,Wd.LINE_SCALE),_c=Ui(Wd,Wd.LINE_DASH_SIZE),vc=Ui(Wd,Wd.LINE_GAP_SIZE),Nc=Ui(Wd,Wd.LINE_WIDTH),Sc=Ui(Wd,Wd.LINE_DASH_OFFSET),wc=Ui(Wd,Wd.POINT_SIZE),Ec=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t { fn.shaderNode = shaderNode; fn.id = shaderNode.id; + fn.isFn = true; + fn.getNodeType = ( ...params ) => shaderNode.getNodeType( ...params ); fn.getCacheKey = ( ...params ) => shaderNode.getCacheKey( ...params ); @@ -11685,7 +11687,7 @@ const objectViewPosition = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.V * @tsl * @function * @param {?Object3D} [object3d] - The 3D object. - * @returns {Object3DNode} + * @returns {Object3DNode} */ const objectRadius = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.RADIUS ).setParameterLength( 1 ); @@ -49178,10 +49180,11 @@ class XRRenderTarget extends RenderTarget { * are defined by external textures. This flag is * set to `true` when using the WebXR Layers API. * + * @private * @type {boolean} * @default false */ - this.hasExternalTextures = false; + this._hasExternalTextures = false; /** * Whether a depth buffer should automatically be allocated @@ -49194,10 +49197,25 @@ class XRRenderTarget extends RenderTarget { * * Reference: {@link https://www.w3.org/TR/webxrlayers-1/#dom-xrprojectionlayer-ignoredepthvalues}. * + * @private * @type {boolean} * @default true */ - this.autoAllocateDepthBuffer = true; + this._autoAllocateDepthBuffer = true; + + /** + * Whether this render target is associated with a XRWebGLLayer. + * + * A XRWebGLLayer points to an opaque framebuffer. Basically, + * this means that you don't have access to its bound color, + * stencil and depth buffers. We need to handle this framebuffer + * differently since its textures are always bound. + * + * @private + * @type {boolean} + * @default false + * */ + this._isOpaqueFramebuffer = false; } @@ -49205,8 +49223,9 @@ class XRRenderTarget extends RenderTarget { super.copy( source ); - this.hasExternalTextures = source.hasExternalTextures; - this.autoAllocateDepthBuffer = source.autoAllocateDepthBuffer; + this._hasExternalTextures = source._hasExternalTextures; + this._autoAllocateDepthBuffer = source._autoAllocateDepthBuffer; + this._isOpaqueFramebuffer = source._isOpaqueFramebuffer; return this; @@ -49839,7 +49858,7 @@ class XRManager extends EventDispatcher { resolveStencilBuffer: false } ); - renderTarget.autoAllocateDepthBuffer = true; + renderTarget._autoAllocateDepthBuffer = true; const material = new MeshBasicMaterial( { color: 0xffffff, side: FrontSide } ); material.map = renderTarget.texture; @@ -49930,7 +49949,7 @@ class XRManager extends EventDispatcher { resolveStencilBuffer: false } ); - renderTarget.autoAllocateDepthBuffer = true; + renderTarget._autoAllocateDepthBuffer = true; const material = new MeshBasicMaterial( { color: 0xffffff, side: BackSide } ); material.map = renderTarget.texture; @@ -50004,7 +50023,7 @@ class XRManager extends EventDispatcher { for ( const layer of this._layers ) { layer.renderTarget.isXRRenderTarget = this._session !== null; - layer.renderTarget.hasExternalTextures = layer.renderTarget.isXRRenderTarget; + layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget; if ( layer.renderTarget.isXRRenderTarget && this._supportsLayers ) { @@ -50172,7 +50191,7 @@ class XRManager extends EventDispatcher { multiview: this._useMultiview } ); - this._xrRenderTarget.hasExternalTextures = true; + this._xrRenderTarget._hasExternalTextures = true; this._xrRenderTarget.depth = this._useMultiview ? 2 : 1; this._supportsLayers = session.enabledFeatures.includes( 'layers' ); @@ -50234,6 +50253,7 @@ class XRManager extends EventDispatcher { } ); + this._xrRenderTarget._isOpaqueFramebuffer = true; this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() ); } @@ -52061,7 +52081,7 @@ class Renderer { frameBufferTarget.scissorTest = this._scissorTest; frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false; frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true; - frameBufferTarget.autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.autoAllocateDepthBuffer : false; + frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false; return frameBufferTarget; @@ -54913,9 +54933,7 @@ const interpolationTypeMap = { }; const interpolationModeMap = { - 'centroid': 'centroid', - 'flat first': 'flat', - 'flat either': 'flat' + 'centroid': 'centroid' }; const defaultPrecisions = ` @@ -60982,13 +61000,13 @@ class WebGLBackend extends Backend { // The multisample_render_to_texture extension doesn't work properly if there // are midframe flushes and an external depth texture. - if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget.autoAllocateDepthBuffer === true && renderTarget.multiview === false ) { + if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget._autoAllocateDepthBuffer === true && renderTarget.multiview === false ) { console.warn( 'THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided' ); } - renderTarget.autoAllocateDepthBuffer = false; + renderTarget._autoAllocateDepthBuffer = false; } @@ -61161,18 +61179,24 @@ class WebGLBackend extends Backend { } this._currentContext = previousContext; + const renderTarget = renderContext.renderTarget; - if ( renderContext.textures !== null && renderContext.renderTarget ) { - - const renderTargetContextData = this.get( renderContext.renderTarget ); + if ( renderContext.textures !== null && renderTarget ) { - const { resolveDepthBuffer, samples } = renderContext.renderTarget; + const renderTargetContextData = this.get( renderTarget ); - if ( samples > 0 && this._useMultisampledExtension( renderContext.renderTarget ) === false ) { + if ( renderTarget.samples > 0 && this._useMultisampledExtension( renderTarget ) === false ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; - const mask = gl.COLOR_BUFFER_BIT; + let mask = gl.COLOR_BUFFER_BIT; + + if ( renderTarget.resolveDepthBuffer ) { + + if ( renderTarget.depthBuffer ) mask |= gl.DEPTH_BUFFER_BIT; + if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= gl.STENCIL_BUFFER_BIT; + + } const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer; @@ -61213,7 +61237,7 @@ class WebGLBackend extends Backend { } - } else if ( resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { + } else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb ); @@ -62620,7 +62644,7 @@ class WebGLBackend extends Backend { const isRenderTarget3D = renderTarget.isRenderTarget3D === true; const isRenderTargetArray = renderTarget.depth > 1; const isXRRenderTarget = renderTarget.isXRRenderTarget === true; - const hasExternalTextures = ( isXRRenderTarget === true && renderTarget.hasExternalTextures === true ); + const _hasExternalTextures = ( isXRRenderTarget === true && renderTarget._hasExternalTextures === true ); let msaaFb = renderTargetContextData.msaaFrameBuffer; let depthRenderbuffer = renderTargetContextData.depthRenderbuffer; @@ -62637,7 +62661,7 @@ class WebGLBackend extends Backend { fb = renderTargetContextData.cubeFramebuffers[ cacheKey ]; - } else if ( isXRRenderTarget && hasExternalTextures === false ) { + } else if ( isXRRenderTarget && _hasExternalTextures === false ) { fb = this._xrFramebuffer; @@ -62713,7 +62737,7 @@ class WebGLBackend extends Backend { const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; - if ( renderTarget.autoAllocateDepthBuffer === true ) { + if ( renderTarget._autoAllocateDepthBuffer === true ) { const renderbuffer = gl.createRenderbuffer(); this.textureUtils.setupRenderBufferStorage( renderbuffer, descriptor, 0, useMultisampledRTT ); @@ -62738,7 +62762,7 @@ class WebGLBackend extends Backend { multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, samples, 0, 2 ); - } else if ( hasExternalTextures && useMultisampledRTT ) { + } else if ( _hasExternalTextures && useMultisampledRTT ) { multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0, samples ); @@ -62789,7 +62813,7 @@ class WebGLBackend extends Backend { // rebind external XR textures - if ( isXRRenderTarget || useMultisampledRTT || renderTarget.multiview ) { + if ( ( isXRRenderTarget || useMultisampledRTT || renderTarget.multiview ) && ( renderTarget._isOpaqueFramebuffer !== true ) ) { state.bindFramebuffer( gl.FRAMEBUFFER, fb ); @@ -62815,7 +62839,7 @@ class WebGLBackend extends Backend { const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; - if ( renderTarget.autoAllocateDepthBuffer === true ) { + if ( renderTarget._autoAllocateDepthBuffer === true ) { const renderbuffer = renderTargetContextData.xrDepthRenderbuffer; gl.bindRenderbuffer( gl.RENDERBUFFER, renderbuffer ); @@ -63146,7 +63170,7 @@ class WebGLBackend extends Backend { } - return renderTarget.samples > 0 && this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTarget.autoAllocateDepthBuffer !== false; + return renderTarget.samples > 0 && this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTarget._autoAllocateDepthBuffer !== false; } diff --git a/build/three.webgpu.nodes.min.js b/build/three.webgpu.nodes.min.js index 33a20ac6f806fa..8abde250a73ef5 100644 --- a/build/three.webgpu.nodes.min.js +++ b/build/three.webgpu.nodes.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -import{Color as e,Vector2 as t,Vector3 as r,Vector4 as s,Matrix2 as i,Matrix3 as n,Matrix4 as a,EventDispatcher as o,MathUtils as u,WebGLCoordinateSystem as l,WebGPUCoordinateSystem as d,ColorManagement as c,SRGBTransfer as h,NoToneMapping as p,StaticDrawUsage as g,InterleavedBuffer as m,InterleavedBufferAttribute as f,DynamicDrawUsage as y,NoColorSpace as x,Texture as b,UnsignedIntType as T,IntType as _,NearestFilter as v,Sphere as N,BackSide as S,Euler as w,CubeTexture as E,CubeReflectionMapping as A,CubeRefractionMapping as R,TangentSpaceNormalMap as C,ObjectSpaceNormalMap as M,InstancedInterleavedBuffer as P,InstancedBufferAttribute as L,DataArrayTexture as F,FloatType as B,FramebufferTexture as I,LinearMipmapLinearFilter as D,DepthTexture as V,Material as U,NormalBlending as O,LineBasicMaterial as k,LineDashedMaterial as G,NoBlending as z,MeshNormalMaterial as H,SRGBColorSpace as $,WebGLCubeRenderTarget as W,BoxGeometry as j,Mesh as q,Scene as X,LinearFilter as K,CubeCamera as Y,EquirectangularReflectionMapping as Q,EquirectangularRefractionMapping as Z,AddOperation as J,MixOperation as ee,MultiplyOperation as te,MeshBasicMaterial as re,MeshLambertMaterial as se,MeshPhongMaterial as ie,OrthographicCamera as ne,PerspectiveCamera as ae,RenderTarget as oe,LinearSRGBColorSpace as ue,RGBAFormat as le,HalfFloatType as de,CubeUVReflectionMapping as ce,BufferGeometry as he,BufferAttribute as pe,MeshStandardMaterial as ge,MeshPhysicalMaterial as me,MeshToonMaterial as fe,MeshMatcapMaterial as ye,SpriteMaterial as xe,PointsMaterial as be,ShadowMaterial as Te,Uint32BufferAttribute as _e,Uint16BufferAttribute as ve,arrayNeedsUint32 as Ne,DoubleSide as Se,Camera as we,DepthStencilFormat as Ee,DepthFormat as Ae,UnsignedInt248Type as Re,UnsignedByteType as Ce,Plane as Me,Object3D as Pe,LinearMipMapLinearFilter as Le,Float32BufferAttribute as Fe,UVMapping as Be,VSMShadowMap as Ie,LessCompare as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as ke,NearestMipmapLinearFilter as Ge,Float16BufferAttribute as ze,REVISION as He,ArrayCamera as $e,PlaneGeometry as We,FrontSide as je,CustomBlending as qe,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,Quaternion as Qe,WebXRController as Ze,RAD2DEG as Je,PCFShadowMap as et,FrustumArray as tt,Frustum as rt,DataTexture as st,RedIntegerFormat as it,RedFormat as nt,ShortType as at,ByteType as ot,UnsignedShortType as ut,RGIntegerFormat as lt,RGBIntegerFormat as dt,RGBFormat as ct,RGBAIntegerFormat as ht,warnOnce as pt,createCanvasElement as gt,ReverseSubtractEquation as mt,SubtractEquation as ft,OneMinusDstAlphaFactor as yt,OneMinusDstColorFactor as xt,OneMinusSrcAlphaFactor as bt,OneMinusSrcColorFactor as Tt,DstAlphaFactor as _t,DstColorFactor as vt,SrcAlphaSaturateFactor as Nt,SrcAlphaFactor as St,SrcColorFactor as wt,OneFactor as Et,CullFaceNone as At,CullFaceBack as Rt,CullFaceFront as Ct,MultiplyBlending as Mt,SubtractiveBlending as Pt,AdditiveBlending as Lt,NotEqualDepth as Ft,GreaterDepth as Bt,GreaterEqualDepth as It,EqualDepth as Dt,LessEqualDepth as Vt,LessDepth as Ut,AlwaysDepth as Ot,NeverDepth as kt,UnsignedShort4444Type as Gt,UnsignedShort5551Type as zt,UnsignedInt5999Type as Ht,AlphaFormat as $t,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as jt,RGBA_S3TC_DXT3_Format as qt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Kt,RGB_PVRTC_2BPPV1_Format as Yt,RGBA_PVRTC_4BPPV1_Format as Qt,RGBA_PVRTC_2BPPV1_Format as Zt,RGB_ETC1_Format as Jt,RGB_ETC2_Format as er,RGBA_ETC2_EAC_Format as tr,RGBA_ASTC_4x4_Format as rr,RGBA_ASTC_5x4_Format as sr,RGBA_ASTC_5x5_Format as ir,RGBA_ASTC_6x5_Format as nr,RGBA_ASTC_6x6_Format as ar,RGBA_ASTC_8x5_Format as or,RGBA_ASTC_8x6_Format as ur,RGBA_ASTC_8x8_Format as lr,RGBA_ASTC_10x5_Format as dr,RGBA_ASTC_10x6_Format as cr,RGBA_ASTC_10x8_Format as hr,RGBA_ASTC_10x10_Format as pr,RGBA_ASTC_12x10_Format as gr,RGBA_ASTC_12x12_Format as mr,RGBA_BPTC_Format as fr,RED_RGTC1_Format as yr,SIGNED_RED_RGTC1_Format as xr,RED_GREEN_RGTC2_Format as br,SIGNED_RED_GREEN_RGTC2_Format as Tr,MirroredRepeatWrapping as _r,ClampToEdgeWrapping as vr,RepeatWrapping as Nr,NearestMipmapNearestFilter as Sr,NotEqualCompare as wr,GreaterCompare as Er,GreaterEqualCompare as Ar,EqualCompare as Rr,LessEqualCompare as Cr,AlwaysCompare as Mr,NeverCompare as Pr,LinearTransfer as Lr,NotEqualStencilFunc as Fr,GreaterStencilFunc as Br,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as kr,DecrementWrapStencilOp as Gr,IncrementWrapStencilOp as zr,DecrementStencilOp as Hr,IncrementStencilOp as $r,InvertStencilOp as Wr,ReplaceStencilOp as jr,ZeroStencilOp as qr,KeepStencilOp as Xr,MaxEquation as Kr,MinEquation as Yr,SpotLight as Qr,PointLight as Zr,DirectionalLight as Jr,RectAreaLight as es,AmbientLight as ts,HemisphereLight as rs,LightProbe as ss,LinearToneMapping as is,ReinhardToneMapping as ns,CineonToneMapping as as,ACESFilmicToneMapping as os,AgXToneMapping as us,NeutralToneMapping as ls,Group as ds,Loader as cs,FileLoader as hs,MaterialLoader as ps,ObjectLoader as gs}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,ConstantAlphaFactor,ConstantColorFactor,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CustomToneMapping,Cylindrical,Data3DTexture,DataTextureLoader,DataUtils,DefaultLoadingManager,DetachedBindMode,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,MeshDepthMaterial,MeshDistanceMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NormalAnimationBlendMode,NumberKeyframeTrack,OctahedronGeometry,OneMinusConstantAlphaFactor,OneMinusConstantColorFactor,PCFSoftShadowMap,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format,RGDepthPacking,RawShaderMaterial,Ray,Raycaster,RenderTarget3D,RingGeometry,ShaderMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Spherical,SphericalHarmonics3,SplineCurve,SpotLightHelper,Sprite,StaticCopyUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding}from"./three.core.min.js";const ms=["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 fs{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=ms,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const jd=Ui(Wd,Wd.ALPHA_TEST),qd=Ui(Wd,Wd.COLOR),Xd=Ui(Wd,Wd.SHININESS),Kd=Ui(Wd,Wd.EMISSIVE),Yd=Ui(Wd,Wd.OPACITY),Qd=Ui(Wd,Wd.SPECULAR),Zd=Ui(Wd,Wd.SPECULAR_INTENSITY),Jd=Ui(Wd,Wd.SPECULAR_COLOR),ec=Ui(Wd,Wd.SPECULAR_STRENGTH),tc=Ui(Wd,Wd.REFLECTIVITY),rc=Ui(Wd,Wd.ROUGHNESS),sc=Ui(Wd,Wd.METALNESS),ic=Ui(Wd,Wd.NORMAL),nc=Ui(Wd,Wd.CLEARCOAT),ac=Ui(Wd,Wd.CLEARCOAT_ROUGHNESS),oc=Ui(Wd,Wd.CLEARCOAT_NORMAL),uc=Ui(Wd,Wd.ROTATION),lc=Ui(Wd,Wd.SHEEN),dc=Ui(Wd,Wd.SHEEN_ROUGHNESS),cc=Ui(Wd,Wd.ANISOTROPY),hc=Ui(Wd,Wd.IRIDESCENCE),pc=Ui(Wd,Wd.IRIDESCENCE_IOR),gc=Ui(Wd,Wd.IRIDESCENCE_THICKNESS),mc=Ui(Wd,Wd.TRANSMISSION),fc=Ui(Wd,Wd.THICKNESS),yc=Ui(Wd,Wd.IOR),xc=Ui(Wd,Wd.ATTENUATION_DISTANCE),bc=Ui(Wd,Wd.ATTENUATION_COLOR),Tc=Ui(Wd,Wd.LINE_SCALE),_c=Ui(Wd,Wd.LINE_DASH_SIZE),vc=Ui(Wd,Wd.LINE_GAP_SIZE),Nc=Ui(Wd,Wd.LINE_WIDTH),Sc=Ui(Wd,Wd.LINE_DASH_OFFSET),wc=Ui(Wd,Wd.POINT_SIZE),Ec=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e.autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e.autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(e.renderTarget)){const i=s.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT,a=s.msaaFrameBuffer,o=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i.hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e.autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const jd=Ui(Wd,Wd.ALPHA_TEST),qd=Ui(Wd,Wd.COLOR),Xd=Ui(Wd,Wd.SHININESS),Kd=Ui(Wd,Wd.EMISSIVE),Yd=Ui(Wd,Wd.OPACITY),Qd=Ui(Wd,Wd.SPECULAR),Zd=Ui(Wd,Wd.SPECULAR_INTENSITY),Jd=Ui(Wd,Wd.SPECULAR_COLOR),ec=Ui(Wd,Wd.SPECULAR_STRENGTH),tc=Ui(Wd,Wd.REFLECTIVITY),rc=Ui(Wd,Wd.ROUGHNESS),sc=Ui(Wd,Wd.METALNESS),ic=Ui(Wd,Wd.NORMAL),nc=Ui(Wd,Wd.CLEARCOAT),ac=Ui(Wd,Wd.CLEARCOAT_ROUGHNESS),oc=Ui(Wd,Wd.CLEARCOAT_NORMAL),uc=Ui(Wd,Wd.ROTATION),lc=Ui(Wd,Wd.SHEEN),dc=Ui(Wd,Wd.SHEEN_ROUGHNESS),cc=Ui(Wd,Wd.ANISOTROPY),hc=Ui(Wd,Wd.IRIDESCENCE),pc=Ui(Wd,Wd.IRIDESCENCE_IOR),gc=Ui(Wd,Wd.IRIDESCENCE_THICKNESS),mc=Ui(Wd,Wd.TRANSMISSION),fc=Ui(Wd,Wd.THICKNESS),yc=Ui(Wd,Wd.IOR),xc=Ui(Wd,Wd.ATTENUATION_DISTANCE),bc=Ui(Wd,Wd.ATTENUATION_COLOR),Tc=Ui(Wd,Wd.LINE_SCALE),_c=Ui(Wd,Wd.LINE_DASH_SIZE),vc=Ui(Wd,Wd.LINE_GAP_SIZE),Nc=Ui(Wd,Wd.LINE_WIDTH),Sc=Ui(Wd,Wd.LINE_DASH_OFFSET),wc=Ui(Wd,Wd.POINT_SIZE),Ec=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t Date: Fri, 6 Jun 2025 04:28:33 -0400 Subject: [PATCH 2/4] Decouple gui colors from color mgmt (#31232) --- examples/webgpu_compute_cloth.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/webgpu_compute_cloth.html b/examples/webgpu_compute_cloth.html index 2e34de6764412b..2543ab108f6ab7 100644 --- a/examples/webgpu_compute_cloth.html +++ b/examples/webgpu_compute_cloth.html @@ -62,6 +62,11 @@ wind: 1.0, }; + const API = { + color: 0x204080, // sRGB + sheenColor: 0xffffff // sRGB + }; + init(); async function init() { @@ -99,12 +104,13 @@ gui.add( params, 'wireframe' ); gui.add( params, 'sphere' ); gui.add( params, 'wind', 0, 5, 0.1 ); + const materialFolder = gui.addFolder( 'material' ); - materialFolder.addColor( clothMaterial, 'color' ); + materialFolder.addColor( API, 'color' ).onChange( function ( color ) { clothMaterial.color.setHex( color ); } ); materialFolder.add( clothMaterial, 'roughness', 0.0, 1, 0.01 ); materialFolder.add( clothMaterial, 'sheen', 0.0, 1, 0.01 ); materialFolder.add( clothMaterial, 'sheenRoughness', 0.0, 1, 0.01 ); - materialFolder.addColor( clothMaterial, 'sheenColor' ); + materialFolder.addColor( API, 'sheenColor' ).onChange( function ( color ) { clothMaterial.sheenColor.setHex( color ); } ); window.addEventListener( 'resize', onWindowResize ); @@ -452,13 +458,13 @@ geometry.setIndex( indices ); clothMaterial = new THREE.MeshPhysicalNodeMaterial( { - color: 0x204080, + color: new THREE.Color().setHex( API.color ), side: THREE.DoubleSide, transparent: true, opacity: 0.85, sheen: 1.0, sheenRoughness: 0.5, - sheenColor: 0xffffff + sheenColor: new THREE.Color().setHex( API.sheenColor ), } ); clothMaterial.positionNode = Fn( ( { material } ) => { From 25694af32239b04e64ef0c1680afceb1635a71eb Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Fri, 6 Jun 2025 10:30:41 +0200 Subject: [PATCH 3/4] WebGPURenderer: Make MSAA with MRT work with WebGL backend. (#31228) * WebGPURenderer: Make MSAA with MRT work with WebGL backend. * E2E: Update screenshots. --- .../webgpu_custom_fog_background.jpg | Bin 29804 -> 58718 bytes .../screenshots/webgpu_materials_toon.jpg | Bin 23787 -> 41869 bytes .../screenshots/webgpu_postprocessing_ao.jpg | Bin 76374 -> 74473 bytes examples/screenshots/webgpu_reflection.jpg | Bin 62354 -> 143218 bytes .../webgpu_skinning_instancing.jpg | Bin 42077 -> 81014 bytes src/nodes/display/PassNode.js | 7 --- src/renderers/webgl-fallback/WebGLBackend.js | 48 ++++++++++++++++-- .../webgl-fallback/utils/WebGLTextureUtils.js | 2 + 8 files changed, 47 insertions(+), 10 deletions(-) diff --git a/examples/screenshots/webgpu_custom_fog_background.jpg b/examples/screenshots/webgpu_custom_fog_background.jpg index 133fc28c06893e3ae9d7a09a656949a9ee4af5b9..112656882cc20f3d70e10885b765ade3a173fb14 100644 GIT binary patch literal 58718 zcmeFYc{p3$|2C?l(xT>>r!7Uy#FQ#u`kN@C_gl|;?7LCVvb=cmS&;2|O+#u8Hv zB|%G35@S^*ic;F7hDJ@V-+9mVUgytqe&<}*`_I|?+Sl6q+WU`nueJ7CpU-{Y>tyz1 ziQ_8R+|r!m%oz@jGp8rV$w!Wa)2IK<$H^NG{!1Lc&-`=l3_r(N{xj$J&zw-sRGilF z!vCxp$NzbpIeYH>g^Qe*xVSH0Jzq~V9IHGhdtxs77-N_myo}ypr`}@>gej}8-VWoX=ZM5*Anai zg~1)2oLzkG`#$jVMm2|23)eI+3Yge&dW8yJ*Lr$M$n<%6QyrKR$vnrEb7xLF>>NLbF~{Lh!*8bXn~;Cc z{>{yy$npOd|C^fN?DrBpQlfjewHW8@jszussgSf%R+Q`LY|nr7XGkA+SB~x(Z()d# zh`#OJFGD_!&JXzbUp&yS5mVt6$Rm1(qG}qkriqGZ2Le1uGXtLPNJIj*Dt~LVyFqU8 zT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VJ@w_V(%av`3xo2zc-; zpg+lG%=fI$|DrEF=_{2oizk>;O$7&VSoN&2*FnNWrA^B9XqSq-PJ0)--APZ{RVtM- zX+qquAIspQmTK`%I~LC~JB?GLo6u6=f^UDpa4pPg#n{M<7b8f9ddHYZKw_~&cK#s!hUD7H`^(2GS6l&Jh_f{uDtr6RJiPnF(<6|a7rv#D~#5adnPb_hyA{cS)xAiZ&v!NpyTmX z5A!5L{H>Qqx6Rmx*e}eUMSypR*qgP za~Sro&rwSHB zP%i*m9f|9iv?r4(vd+!{?kW?}39r_at!Y(o9lMs^s(fclJMcSsW@p8g zPg2tUb^JG+{?eQbBK_y`A;6bS5^nmA42WqJ4(=v9tfc3Q!K$-&)#^~tspBcMRrH(G H|Azht8>NQf diff --git a/examples/screenshots/webgpu_reflection.jpg b/examples/screenshots/webgpu_reflection.jpg index 0277076439aa09591ca732cd6f54e9c081ec196e..173ca740d4d65ada40cdfdafb94bb38382e9d2bd 100644 GIT binary patch literal 143218 zcmc$_d03Kb^fpS{%4VA!Du-QGmZqlVJg}>+rlyp0PV6!*MKtFDf!$!1nwDcZQJIn& zk^_VjX@$&Gj^*+zK?{%;BZVqow z0`@!D+S>xQYykka$ew^r8sM?)=>O-(<`=+$9RSgm7jjz;0RA|zMee|s&2L-Y$>zB2 z|I7^Ve?7MRA-8qgcKIDUckSK}_+yKl+#g%zwr$(GRdyy^_8nmBfo%tm8(i9c=*BJi z6A_0EAH00KL-TUYS4Ee8?#TT4&B`Uo3z<+LRYHR=Yy`%F-SN8yUaEL-39vPkbJv}o!$Czg>EU&Ec_-lf7p=b+0?tdKp ze+>G6*dsH1%O6{}%59bZ&z>!R#L3=r2exiIZm|8}r5p0MA`YD}e6Zv2<(F@3zV6h# z;KEhB9ofH2>Ey+!Q_KIE^uI0oe`nCc|4$bEk3s)q&*ms#kK7j71(Q1f00N|@m}ss+ zrz+eE*eQy^E|`1WX+mh^qw}Gp+0pe@z8DrGB_578rdaKxJHr#KfM6*uG5V7f%%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M;lU0tN7j$DN7*EY{a!tdVD~hR#x?7>ylgQU#(C>i_DO#k70M$@o0K1z^&Zug z-lbU?qm*!cKgN`|2z4^FQh(tsv^hEZTz~oyrCazf(3*e7UZ=g?GXTmM;|GlU8u>PR z&toakE^OM~;abFC>xSSsF$xM=Vc0>C15^qBG}XgK7rq;@eb*x|W7YZ)3x TW1H96hekYS9Q#&X3P1nZ=wY}t diff --git a/examples/screenshots/webgpu_skinning_instancing.jpg b/examples/screenshots/webgpu_skinning_instancing.jpg index b865dfa7766febdc8270af6d4fc2f6fb7f38f022..3b535c109a0222adafa190b4d15c4faaef08301c 100644 GIT binary patch literal 81014 zcmeFXcTiK``!0$fMWiSqy{q)zA@r~E0i;VwLdSsg8j1vnptR7D-a*6=0)*a05CTEE zbg7a=KtMDB#LzG2o;$y}f82ZK-1ETzhl<8WYt&OxLb6UAr8(_U@{U)c?I@RR2f1 z_RsYj)Hi8v(bCc1rTXXE_3QuKxK2%diU0m^nVBRf5LMG{MtV^ zZd|`X^WX4X`zQ43zRq-m`hncddymX%AW-Iq@~>~PJkBU@?4uP>upqHI2Tswk2`b`+ z$o~z}|BmQ?4p8*}5~BYC^j~-`m#7%7U%MKx>r7PIRF_oRCsd+TZ~u8k_y1@AAMS$o z+i`zBtx}haji&rcqvZ_<=c&#}#~~-^^+i!zg1yS#TuPPobU?umxO?8e4F^9f^15w> zAxu6*$^5?9zyT&zueXQifr>+mBTp~D(g1to-=lhd%d3IQmsI~WIvipQ1U(9IyWz$1 zwfE#`W;QI%mMoj#h-N8>0SSEbKCSr+m<>cqcQCx%ZcUD8z(RAsNKf0#+pki zt!nibv8CT04jn1iY=jM&busy_ethT34K3cM;n>V;MMVVRE-K4_1Azw-oJ$KIyTbh` zEO8(EsAHK~d2*SwXlC~Y!HQ9Z+Trp?A=;Ty6o%fj)|Wc zGd$BrZ~R8g{f<^^>^OU3Ix)OU|&zUY<2e9Kw> z-S~XFogf2PTuEsAb--ZC?x*lUFnB03M{AnBUA`9`+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Ug`@vEl}9= z(ML9*{AFKqe7ukOpB$=vdDNbH><^D@nIW}5z{Vg6X8IDTHUce|N|`Ra)=Z_mfiHcY zIoo~AUQ*D5RZ&pmHQszuSUdGa#G~*C5AN&hzf*73#;L97DqIwXxa6aGC3?p|c>r8f zBrzHQqqeBoh6QN)#>zI&%C^l)bcS&C!xa2C;F*g636$g+K3N9>+E1PRCVc(aj<2Y^ zh&rnUt-;%}av91%YW`YH@>TZAa`_Hz-pYz4{e!VLkZKsF4UX8X#gf^*-n7-PTNFSF zLb~Kp$6hC+^PYev3QVL5eiZ$k6KZEeXd17m33LY|tRdICMOleN8&RRSLu o>xKk(f;s%6GuqO<6)9t{vitw+9sXbb`~Ta!_W$L1w0}+i7vIXR0ssI2 diff --git a/src/nodes/display/PassNode.js b/src/nodes/display/PassNode.js index fed96e665374dd..6024ebaa75faa6 100644 --- a/src/nodes/display/PassNode.js +++ b/src/nodes/display/PassNode.js @@ -586,13 +586,6 @@ class PassNode extends TempNode { this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples; - // TODO: Disable MSAA for WebGL backend for now - if ( renderer.backend.isWebGLBackend === true ) { - - this.renderTarget.samples = 0; - - } - this.renderTarget.texture.type = renderer.getColorBufferType(); return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode(); diff --git a/src/renderers/webgl-fallback/WebGLBackend.js b/src/renderers/webgl-fallback/WebGLBackend.js index 622070bfe91a2e..01f65db23a57cc 100644 --- a/src/renderers/webgl-fallback/WebGLBackend.js +++ b/src/renderers/webgl-fallback/WebGLBackend.js @@ -563,15 +563,40 @@ class WebGLBackend extends Backend { } const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer; + const msaaRenderbuffers = renderTargetContextData.msaaRenderbuffers; const textures = renderContext.textures; + const isMRT = textures.length > 1; state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer ); state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb ); + if ( isMRT ) { + + // blitFramebuffer() can only copy/resolve the first color attachment of a framebuffer. When using MRT, + // the engine temporarily removes all attachments and then configures each attachment for the resolve. + + for ( let i = 0; i < textures.length; i ++ ) { + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, null ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, null, 0 ); + + } + + } + for ( let i = 0; i < textures.length; i ++ ) { - // TODO Add support for MRT + if ( isMRT ) { + + // configure attachment for resolve + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0 ); + + } if ( renderContext.scissor ) { @@ -601,6 +626,21 @@ class WebGLBackend extends Backend { } + if ( isMRT ) { + + // restore attachments + + for ( let i = 0; i < textures.length; i ++ ) { + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 ); + + } + + } + } else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; @@ -2095,8 +2135,6 @@ class WebGLBackend extends Backend { } - state.drawBuffers( descriptor, fb ); - } const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; @@ -2271,6 +2309,8 @@ class WebGLBackend extends Backend { } + gl.bindRenderbuffer( gl.RENDERBUFFER, null ); + renderTargetContextData.msaaFrameBuffer = msaaFb; renderTargetContextData.msaaRenderbuffers = msaaRenderbuffers; @@ -2298,6 +2338,8 @@ class WebGLBackend extends Backend { } + state.drawBuffers( descriptor, fb ); + } state.bindFramebuffer( gl.FRAMEBUFFER, currentFrameBuffer ); diff --git a/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js b/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js index 4e0c0fca20f1d2..5578ebe43075e6 100644 --- a/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +++ b/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js @@ -1021,6 +1021,8 @@ class WebGLTextureUtils { } + gl.bindRenderbuffer( gl.RENDERBUFFER, null ); + } /** From 82cab04339a57d7abf6751d2d8fdab082efca6ac Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 6 Jun 2025 10:32:45 +0200 Subject: [PATCH 4/4] Updated builds. --- build/three.webgpu.js | 57 +++++++++++++++++++++++++++------ build/three.webgpu.min.js | 2 +- build/three.webgpu.nodes.js | 57 +++++++++++++++++++++++++++------ build/three.webgpu.nodes.min.js | 2 +- 4 files changed, 96 insertions(+), 22 deletions(-) diff --git a/build/three.webgpu.js b/build/three.webgpu.js index f92e38fb5cbebc..7d4b6c1e7f875e 100644 --- a/build/three.webgpu.js +++ b/build/three.webgpu.js @@ -34554,13 +34554,6 @@ class PassNode extends TempNode { this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples; - // TODO: Disable MSAA for WebGL backend for now - if ( renderer.backend.isWebGLBackend === true ) { - - this.renderTarget.samples = 0; - - } - this.renderTarget.texture.type = renderer.getColorBufferType(); return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode(); @@ -59760,6 +59753,8 @@ class WebGLTextureUtils { } + gl.bindRenderbuffer( gl.RENDERBUFFER, null ); + } /** @@ -61199,15 +61194,40 @@ class WebGLBackend extends Backend { } const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer; + const msaaRenderbuffers = renderTargetContextData.msaaRenderbuffers; const textures = renderContext.textures; + const isMRT = textures.length > 1; state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer ); state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb ); + if ( isMRT ) { + + // blitFramebuffer() can only copy/resolve the first color attachment of a framebuffer. When using MRT, + // the engine temporarily removes all attachments and then configures each attachment for the resolve. + + for ( let i = 0; i < textures.length; i ++ ) { + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, null ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, null, 0 ); + + } + + } + for ( let i = 0; i < textures.length; i ++ ) { - // TODO Add support for MRT + if ( isMRT ) { + + // configure attachment for resolve + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0 ); + + } if ( renderContext.scissor ) { @@ -61237,6 +61257,21 @@ class WebGLBackend extends Backend { } + if ( isMRT ) { + + // restore attachments + + for ( let i = 0; i < textures.length; i ++ ) { + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 ); + + } + + } + } else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; @@ -62731,8 +62766,6 @@ class WebGLBackend extends Backend { } - state.drawBuffers( descriptor, fb ); - } const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; @@ -62907,6 +62940,8 @@ class WebGLBackend extends Backend { } + gl.bindRenderbuffer( gl.RENDERBUFFER, null ); + renderTargetContextData.msaaFrameBuffer = msaaFb; renderTargetContextData.msaaRenderbuffers = msaaRenderbuffers; @@ -62934,6 +62969,8 @@ class WebGLBackend extends Backend { } + state.drawBuffers( descriptor, fb ); + } state.bindFramebuffer( gl.FRAMEBUFFER, currentFrameBuffer ); diff --git a/build/three.webgpu.min.js b/build/three.webgpu.min.js index e1e98dde5549d9..4c6136b8542bb2 100644 --- a/build/three.webgpu.min.js +++ b/build/three.webgpu.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -import{Color as e,Vector2 as t,Vector3 as r,Vector4 as s,Matrix2 as i,Matrix3 as n,Matrix4 as a,EventDispatcher as o,MathUtils as u,WebGLCoordinateSystem as l,WebGPUCoordinateSystem as d,ColorManagement as c,SRGBTransfer as h,NoToneMapping as p,StaticDrawUsage as g,InterleavedBuffer as m,InterleavedBufferAttribute as f,DynamicDrawUsage as y,NoColorSpace as x,Texture as b,UnsignedIntType as T,IntType as _,NearestFilter as v,Sphere as N,BackSide as S,Euler as w,CubeTexture as E,CubeReflectionMapping as A,CubeRefractionMapping as R,TangentSpaceNormalMap as C,ObjectSpaceNormalMap as M,InstancedInterleavedBuffer as P,InstancedBufferAttribute as L,DataArrayTexture as F,FloatType as B,FramebufferTexture as I,LinearMipmapLinearFilter as D,DepthTexture as V,Material as U,NormalBlending as O,LineBasicMaterial as k,LineDashedMaterial as G,NoBlending as z,MeshNormalMaterial as H,SRGBColorSpace as $,WebGLCubeRenderTarget as W,BoxGeometry as j,Mesh as q,Scene as X,LinearFilter as K,CubeCamera as Y,EquirectangularReflectionMapping as Q,EquirectangularRefractionMapping as Z,AddOperation as J,MixOperation as ee,MultiplyOperation as te,MeshBasicMaterial as re,MeshLambertMaterial as se,MeshPhongMaterial as ie,OrthographicCamera as ne,PerspectiveCamera as ae,RenderTarget as oe,LinearSRGBColorSpace as ue,RGBAFormat as le,HalfFloatType as de,CubeUVReflectionMapping as ce,BufferGeometry as he,BufferAttribute as pe,MeshStandardMaterial as ge,MeshPhysicalMaterial as me,MeshToonMaterial as fe,MeshMatcapMaterial as ye,SpriteMaterial as xe,PointsMaterial as be,ShadowMaterial as Te,Uint32BufferAttribute as _e,Uint16BufferAttribute as ve,arrayNeedsUint32 as Ne,DoubleSide as Se,Camera as we,DepthStencilFormat as Ee,DepthFormat as Ae,UnsignedInt248Type as Re,UnsignedByteType as Ce,Plane as Me,Object3D as Pe,LinearMipMapLinearFilter as Le,Float32BufferAttribute as Fe,UVMapping as Be,VSMShadowMap as Ie,LessCompare as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as ke,NearestMipmapLinearFilter as Ge,Float16BufferAttribute as ze,REVISION as He,ArrayCamera as $e,PlaneGeometry as We,FrontSide as je,CustomBlending as qe,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,Quaternion as Qe,WebXRController as Ze,RAD2DEG as Je,PCFShadowMap as et,FrustumArray as tt,Frustum as rt,DataTexture as st,RedIntegerFormat as it,RedFormat as nt,ShortType as at,ByteType as ot,UnsignedShortType as ut,RGIntegerFormat as lt,RGBIntegerFormat as dt,RGBFormat as ct,RGBAIntegerFormat as ht,warnOnce as pt,createCanvasElement as gt,ReverseSubtractEquation as mt,SubtractEquation as ft,OneMinusDstAlphaFactor as yt,OneMinusDstColorFactor as xt,OneMinusSrcAlphaFactor as bt,OneMinusSrcColorFactor as Tt,DstAlphaFactor as _t,DstColorFactor as vt,SrcAlphaSaturateFactor as Nt,SrcAlphaFactor as St,SrcColorFactor as wt,OneFactor as Et,CullFaceNone as At,CullFaceBack as Rt,CullFaceFront as Ct,MultiplyBlending as Mt,SubtractiveBlending as Pt,AdditiveBlending as Lt,NotEqualDepth as Ft,GreaterDepth as Bt,GreaterEqualDepth as It,EqualDepth as Dt,LessEqualDepth as Vt,LessDepth as Ut,AlwaysDepth as Ot,NeverDepth as kt,UnsignedShort4444Type as Gt,UnsignedShort5551Type as zt,UnsignedInt5999Type as Ht,AlphaFormat as $t,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as jt,RGBA_S3TC_DXT3_Format as qt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Kt,RGB_PVRTC_2BPPV1_Format as Yt,RGBA_PVRTC_4BPPV1_Format as Qt,RGBA_PVRTC_2BPPV1_Format as Zt,RGB_ETC1_Format as Jt,RGB_ETC2_Format as er,RGBA_ETC2_EAC_Format as tr,RGBA_ASTC_4x4_Format as rr,RGBA_ASTC_5x4_Format as sr,RGBA_ASTC_5x5_Format as ir,RGBA_ASTC_6x5_Format as nr,RGBA_ASTC_6x6_Format as ar,RGBA_ASTC_8x5_Format as or,RGBA_ASTC_8x6_Format as ur,RGBA_ASTC_8x8_Format as lr,RGBA_ASTC_10x5_Format as dr,RGBA_ASTC_10x6_Format as cr,RGBA_ASTC_10x8_Format as hr,RGBA_ASTC_10x10_Format as pr,RGBA_ASTC_12x10_Format as gr,RGBA_ASTC_12x12_Format as mr,RGBA_BPTC_Format as fr,RED_RGTC1_Format as yr,SIGNED_RED_RGTC1_Format as xr,RED_GREEN_RGTC2_Format as br,SIGNED_RED_GREEN_RGTC2_Format as Tr,MirroredRepeatWrapping as _r,ClampToEdgeWrapping as vr,RepeatWrapping as Nr,NearestMipmapNearestFilter as Sr,NotEqualCompare as wr,GreaterCompare as Er,GreaterEqualCompare as Ar,EqualCompare as Rr,LessEqualCompare as Cr,AlwaysCompare as Mr,NeverCompare as Pr,LinearTransfer as Lr,NotEqualStencilFunc as Fr,GreaterStencilFunc as Br,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as kr,DecrementWrapStencilOp as Gr,IncrementWrapStencilOp as zr,DecrementStencilOp as Hr,IncrementStencilOp as $r,InvertStencilOp as Wr,ReplaceStencilOp as jr,ZeroStencilOp as qr,KeepStencilOp as Xr,MaxEquation as Kr,MinEquation as Yr,SpotLight as Qr,PointLight as Zr,DirectionalLight as Jr,RectAreaLight as es,AmbientLight as ts,HemisphereLight as rs,LightProbe as ss,LinearToneMapping as is,ReinhardToneMapping as ns,CineonToneMapping as as,ACESFilmicToneMapping as os,AgXToneMapping as us,NeutralToneMapping as ls,Group as ds,Loader as cs,FileLoader as hs,MaterialLoader as ps,ObjectLoader as gs}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,ConstantAlphaFactor,ConstantColorFactor,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CustomToneMapping,Cylindrical,Data3DTexture,DataTextureLoader,DataUtils,DefaultLoadingManager,DetachedBindMode,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,MeshDepthMaterial,MeshDistanceMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NormalAnimationBlendMode,NumberKeyframeTrack,OctahedronGeometry,OneMinusConstantAlphaFactor,OneMinusConstantColorFactor,PCFSoftShadowMap,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format,RGDepthPacking,RawShaderMaterial,Ray,Raycaster,RenderTarget3D,RingGeometry,ShaderMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Spherical,SphericalHarmonics3,SplineCurve,SpotLightHelper,Sprite,StaticCopyUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding}from"./three.core.min.js";const ms=["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 fs{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=ms,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const jd=Ui(Wd,Wd.ALPHA_TEST),qd=Ui(Wd,Wd.COLOR),Xd=Ui(Wd,Wd.SHININESS),Kd=Ui(Wd,Wd.EMISSIVE),Yd=Ui(Wd,Wd.OPACITY),Qd=Ui(Wd,Wd.SPECULAR),Zd=Ui(Wd,Wd.SPECULAR_INTENSITY),Jd=Ui(Wd,Wd.SPECULAR_COLOR),ec=Ui(Wd,Wd.SPECULAR_STRENGTH),tc=Ui(Wd,Wd.REFLECTIVITY),rc=Ui(Wd,Wd.ROUGHNESS),sc=Ui(Wd,Wd.METALNESS),ic=Ui(Wd,Wd.NORMAL),nc=Ui(Wd,Wd.CLEARCOAT),ac=Ui(Wd,Wd.CLEARCOAT_ROUGHNESS),oc=Ui(Wd,Wd.CLEARCOAT_NORMAL),uc=Ui(Wd,Wd.ROTATION),lc=Ui(Wd,Wd.SHEEN),dc=Ui(Wd,Wd.SHEEN_ROUGHNESS),cc=Ui(Wd,Wd.ANISOTROPY),hc=Ui(Wd,Wd.IRIDESCENCE),pc=Ui(Wd,Wd.IRIDESCENCE_IOR),gc=Ui(Wd,Wd.IRIDESCENCE_THICKNESS),mc=Ui(Wd,Wd.TRANSMISSION),fc=Ui(Wd,Wd.THICKNESS),yc=Ui(Wd,Wd.IOR),xc=Ui(Wd,Wd.ATTENUATION_DISTANCE),bc=Ui(Wd,Wd.ATTENUATION_COLOR),Tc=Ui(Wd,Wd.LINE_SCALE),_c=Ui(Wd,Wd.LINE_DASH_SIZE),vc=Ui(Wd,Wd.LINE_GAP_SIZE),Nc=Ui(Wd,Wd.LINE_WIDTH),Sc=Ui(Wd,Wd.LINE_DASH_OFFSET),wc=Ui(Wd,Wd.POINT_SIZE),Ec=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:Es,getTypedArrayFromType:ws,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const Ei=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)Ei.set(e,new si(e,"int"));const wi=new Map([...Ei].map((e=>new si(e.value))));for(const e of vi)wi.set(e,new si(e));for(const e of vi)wi.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:Ei,float:wi},Ri=new Map([...Ni,...wi]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),En=Ui(gn,"float","Iridescence"),wn=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),Ea=Vi(aa,"^").setParameterLength(2).setName("bitXor"),wa=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",Ea),oi("shiftLeft",wa),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),Eo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),wo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>wo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=wo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",wo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",Eo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class Eu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new Eu(Bi(e),t,r));oi("compute",wu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),El=Ui(Nl,Nl.WORLD_MATRIX),wl=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(El),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>El.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(El).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=El])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new E,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new w;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),Ed=Nd.toVar("transformedTangentView"),wd=Ed.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(Ed),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENU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ui(Wd,Wd.POINT_SIZE),wc=Ui(Wd,Wd.DISPERSION),Ac=Ui(Wd,Wd.LIGHT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=Es(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Eh=Vi(Sh).setParameterLength(0,3),wh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new w;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const Ep=new ie;class wp extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Ep),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=En.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=wh(),ag=wh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:wn,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,El,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?En.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),Eg=ji(.21),wg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(Eg),(()=>{t.assign(Ng.sub(e).mul(wg.sub(Sg)).div(Ng.sub(Eg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;En.assign(e),wn.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):wc;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),Em=new ye;class wm extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Em),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(El[0].xyz.length(),El[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):Ec;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?we:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=Ef){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=El.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=El;const i=cl.mul(s);return Pi(t)&&(i[0][0]=El[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=El[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const Ey=(e,...t)=>Bi(new Sy(Bi(e),...t)),wy=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=wy(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(wy(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(wy(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(wy(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(wy(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new E,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(wo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>wo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Ex=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class wx extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(wx).setParameterLength(1,3);class Rx extends wx{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function Eb(e,t,r){Tb(e,r),Nb(t,r)}var wb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:Eb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,Eb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),ET=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),wT=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(wT(i)).toVar(),o=ji(wT(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(wT(n)).toVar(),l=ji(wT(a)).toVar(),d=ji(wT(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(wT(i)).toVar(),o=ji(wT(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(wT(n)).toVar(),l=ji(wT(a)).toVar(),d=ji(wT(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return ET(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return ET(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return ET(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return ET(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(ET(AT(r,qi(0))),ET(AT(r,qi(1))),ET(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(ET(AT(r,s,qi(0))),ET(AT(r,s,qi(1))),ET(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(ET(AT(r,s,i,qi(0))),ET(AT(r,s,i,qi(1))),ET(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(ET(AT(r,s,i,n,qi(0))),ET(AT(r,s,i,n,qi(1))),ET(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),wo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),wo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=ws("float")):(r=As(t),s=ws(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:Ea,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:wu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():Ey(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:Eo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:wo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:wy,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=ws("float")):(r=As(t),s=ws(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:En,iridescenceIOR:wn,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:wc,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:Ec,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:wl,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:El,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:Ex,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:Ey,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:wa,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:Ed,transformedTangentWorld:wd,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:wh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:Eh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=Es(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new E_(e);if("mat2"===t)return new w_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new wf(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(Ev),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(Ev),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:wv;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:E,transparent:w,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:wv;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:wv;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[wr]:e.GREATER,[Er]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=s.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),d)for(let e=0;e{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",EN="triangle-strip",wN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",ES="depth16unorm",wS="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",eE="astc-4x4-unorm",tE="astc-4x4-unorm-srgb",rE="astc-5x4-unorm",sE="astc-5x4-unorm-srgb",iE="astc-5x5-unorm",nE="astc-5x5-unorm-srgb",aE="astc-6x5-unorm",oE="astc-6x5-unorm-srgb",uE="astc-6x6-unorm",lE="astc-6x6-unorm-srgb",dE="astc-8x5-unorm",cE="astc-8x5-unorm-srgb",hE="astc-8x6-unorm",pE="astc-8x6-unorm-srgb",gE="astc-8x8-unorm",mE="astc-8x8-unorm-srgb",fE="astc-10x5-unorm",yE="astc-10x5-unorm-srgb",xE="astc-10x6-unorm",bE="astc-10x6-unorm-srgb",TE="astc-10x8-unorm",_E="astc-10x8-unorm-srgb",vE="astc-10x10-unorm",NE="astc-10x10-unorm-srgb",SE="astc-12x10-unorm",EE="astc-12x10-unorm-srgb",wE="astc-12x12-unorm",AE="astc-12x12-unorm-srgb",RE="clamp-to-edge",CE="repeat",ME="mirror-repeat",PE="linear",LE="nearest",FE="zero",BE="one",IE="src",DE="one-minus-src",VE="src-alpha",UE="one-minus-src-alpha",OE="dst",kE="one-minus-dst",GE="dst-alpha",zE="one-minus-dst-alpha",HE="src-alpha-saturated",$E="constant",WE="one-minus-constant",jE="add",qE="subtract",XE="reverse-subtract",KE="min",YE="max",QE=0,ZE=15,JE="keep",ew="zero",tw="replace",rw="invert",sw="increment-clamp",iw="decrement-clamp",nw="increment-wrap",aw="decrement-wrap",ow="storage",uw="read-only-storage",lw="write-only",dw="read-only",cw="read-write",hw="non-filtering",pw="comparison",gw="float",mw="unfilterable-float",fw="depth",yw="sint",xw="uint",bw="2d",Tw="3d",_w="2d",vw="2d-array",Nw="cube",Sw="3d",Ew="all",ww="vertex",Aw="instance",Rw={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class Cw extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class Mw extends Cw{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class Pw extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let Lw=0;class Fw extends Pw{constructor(e,t){super("StorageBuffer_"+Lw++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Bw extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:PE}),this.flipYSampler=e.createSampler({minFilter:LE}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:EN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:EN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kw=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,Gw={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zw extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(Ow);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kw.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Hw extends q_{parseFunction(e){return new zw(e)}}const $w="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Ww={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jw={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qw={vertex:$w?$w.VERTEX:1,fragment:$w?$w.FRAGMENT:2,compute:$w?$w.COMPUTE:4},Xw={instance:!0,swizzleAssign:!1,storageBuffer:!0},Kw={"^^":"tsl_xor"},Yw={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},Qw={},Zw={tsl_xor:new wx("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new wx("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new wx("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new wx("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new wx("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new wx("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new wx("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new wx("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new wx("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new wx("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new wx("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 wx("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new wx("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},Jw={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(Zw.pow_float=new wx("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),Zw.pow_vec2=new wx("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 ) ); }",[Zw.pow_float]),Zw.pow_vec3=new wx("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 ) ); }",[Zw.pow_float]),Zw.pow_vec4=new wx("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 ) ); }",[Zw.pow_float]),Jw.pow_float="tsl_pow_float",Jw.pow_vec2="tsl_pow_vec2",Jw.pow_vec3="tsl_pow_vec3",Jw.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new Hw),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jw[e.wrapS]}S_${jw[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=Qw[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(Zw.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(Zw.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(Zw.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",Qw[t]=r=new wx(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=Kw[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return Ww[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qw[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new Mw(`${i.name}_sampler`,i.node,o);e.setVisibility(qw[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:Fw)(e,o);n.setVisibility(qw[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qw[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${Uw(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return Yw[e]||e}isAvailable(e){let t=Xw[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),Xw[e]=t),t}_getWGSLMethod(e){return void 0!==Zw[e]&&this._include(e),Jw[e]}_include(e){const t=Zw[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=wS),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mw)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mw:s.sampleType=fw;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yw:e===T?s.sampleType=xw:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gw:s.sampleType=mw)}r.isSampledCubeTexture?s.viewDimension=Nw:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vw:r.isSampledTexture3D&&(s.viewDimension=Sw),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=Ew;let n;n=t.isSampledCubeTexture?Nw:t.isSampledTexture3D?Sw:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vw:_w,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},E={},w=e.context.depth,A=e.context.stencil;if(!0!==w&&!0!==A||(!0===w&&(E.format=v,E.depthWriteEnabled=s.depthWrite,E.depthCompare=_),!0===A&&(E.stencilFront=m,E.stencilBack={},E.stencilReadMask=s.stencilFuncMask,E.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(E.depthBias=s.polygonOffsetUnits,E.depthBiasSlopeScale=s.polygonOffsetFactor,E.depthBiasClamp=0),S.depthStencil=E),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jE},r={srcFactor:i,dstFactor:n,operation:jE}};if(e.premultipliedAlpha)switch(s){case O:i(BE,UE,BE,UE);break;case Lt:i(BE,BE,BE,BE);break;case Pt:i(FE,DE,FE,BE);break;case Mt:i(FE,IE,FE,VE)}else switch(s){case O:i(VE,UE,BE,UE);break;case Lt:i(VE,BE,VE,BE);break;case Pt:i(FE,DE,FE,BE);break;case Mt:i(FE,IE,FE,IE)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=FE;break;case wt:t=BE;break;case Et:t=IE;break;case Tt:t=DE;break;case St:t=VE;break;case bt:t=UE;break;case vt:t=OE;break;case xt:t=kE;break;case _t:t=GE;break;case yt:t=zE;break;case Nt:t=HE;break;case 211:t=$E;break;case 212:t=WE;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=wN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=JE;break;case qr:t=ew;break;case jr:t=tw;break;case Wr:t=rw;break;case $r:t=sw;break;case Hr:t=iw;break;case zr:t=nw;break;case Gr:t=aw;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jE;break;case ft:t=qE;break;case mt:t=XE;break;case Yr:t=KE;break;case Kr:t=YE;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?ZE:QE}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=wN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new Vw(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(Rw),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(Rw.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t 1; state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer ); state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb ); + if ( isMRT ) { + + // blitFramebuffer() can only copy/resolve the first color attachment of a framebuffer. When using MRT, + // the engine temporarily removes all attachments and then configures each attachment for the resolve. + + for ( let i = 0; i < textures.length; i ++ ) { + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, null ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, null, 0 ); + + } + + } + for ( let i = 0; i < textures.length; i ++ ) { - // TODO Add support for MRT + if ( isMRT ) { + + // configure attachment for resolve + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0 ); + + } if ( renderContext.scissor ) { @@ -61237,6 +61257,21 @@ class WebGLBackend extends Backend { } + if ( isMRT ) { + + // restore attachments + + for ( let i = 0; i < textures.length; i ++ ) { + + const { textureGPU } = this.get( textures[ i ] ); + + gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] ); + gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 ); + + } + + } + } else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) { const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ]; @@ -62731,8 +62766,6 @@ class WebGLBackend extends Backend { } - state.drawBuffers( descriptor, fb ); - } const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT; @@ -62907,6 +62940,8 @@ class WebGLBackend extends Backend { } + gl.bindRenderbuffer( gl.RENDERBUFFER, null ); + renderTargetContextData.msaaFrameBuffer = msaaFb; renderTargetContextData.msaaRenderbuffers = msaaRenderbuffers; @@ -62934,6 +62969,8 @@ class WebGLBackend extends Backend { } + state.drawBuffers( descriptor, fb ); + } state.bindFramebuffer( gl.FRAMEBUFFER, currentFrameBuffer ); diff --git a/build/three.webgpu.nodes.min.js b/build/three.webgpu.nodes.min.js index 8abde250a73ef5..76471bcca5c7b4 100644 --- a/build/three.webgpu.nodes.min.js +++ b/build/three.webgpu.nodes.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ -import{Color as e,Vector2 as t,Vector3 as r,Vector4 as s,Matrix2 as i,Matrix3 as n,Matrix4 as a,EventDispatcher as o,MathUtils as u,WebGLCoordinateSystem as l,WebGPUCoordinateSystem as d,ColorManagement as c,SRGBTransfer as h,NoToneMapping as p,StaticDrawUsage as g,InterleavedBuffer as m,InterleavedBufferAttribute as f,DynamicDrawUsage as y,NoColorSpace as x,Texture as b,UnsignedIntType as T,IntType as _,NearestFilter as v,Sphere as N,BackSide as S,Euler as w,CubeTexture as E,CubeReflectionMapping as A,CubeRefractionMapping as R,TangentSpaceNormalMap as C,ObjectSpaceNormalMap as M,InstancedInterleavedBuffer as P,InstancedBufferAttribute as L,DataArrayTexture as F,FloatType as B,FramebufferTexture as I,LinearMipmapLinearFilter as D,DepthTexture as V,Material as U,NormalBlending as O,LineBasicMaterial as k,LineDashedMaterial as G,NoBlending as z,MeshNormalMaterial as H,SRGBColorSpace as $,WebGLCubeRenderTarget as W,BoxGeometry as j,Mesh as q,Scene as X,LinearFilter as K,CubeCamera as Y,EquirectangularReflectionMapping as Q,EquirectangularRefractionMapping as Z,AddOperation as J,MixOperation as ee,MultiplyOperation as te,MeshBasicMaterial as re,MeshLambertMaterial as se,MeshPhongMaterial as ie,OrthographicCamera as ne,PerspectiveCamera as ae,RenderTarget as oe,LinearSRGBColorSpace as ue,RGBAFormat as le,HalfFloatType as de,CubeUVReflectionMapping as ce,BufferGeometry as he,BufferAttribute as pe,MeshStandardMaterial as ge,MeshPhysicalMaterial as me,MeshToonMaterial as fe,MeshMatcapMaterial as ye,SpriteMaterial as xe,PointsMaterial as be,ShadowMaterial as Te,Uint32BufferAttribute as _e,Uint16BufferAttribute as ve,arrayNeedsUint32 as Ne,DoubleSide as Se,Camera as we,DepthStencilFormat as Ee,DepthFormat as Ae,UnsignedInt248Type as Re,UnsignedByteType as Ce,Plane as Me,Object3D as Pe,LinearMipMapLinearFilter as Le,Float32BufferAttribute as Fe,UVMapping as Be,VSMShadowMap as Ie,LessCompare as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as ke,NearestMipmapLinearFilter as Ge,Float16BufferAttribute as ze,REVISION as He,ArrayCamera as $e,PlaneGeometry as We,FrontSide as je,CustomBlending as qe,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,Quaternion as Qe,WebXRController as Ze,RAD2DEG as Je,PCFShadowMap as et,FrustumArray as tt,Frustum as rt,DataTexture as st,RedIntegerFormat as it,RedFormat as nt,ShortType as at,ByteType as ot,UnsignedShortType as ut,RGIntegerFormat as lt,RGBIntegerFormat as dt,RGBFormat as ct,RGBAIntegerFormat as ht,warnOnce as pt,createCanvasElement as gt,ReverseSubtractEquation as mt,SubtractEquation as ft,OneMinusDstAlphaFactor as yt,OneMinusDstColorFactor as xt,OneMinusSrcAlphaFactor as bt,OneMinusSrcColorFactor as Tt,DstAlphaFactor as _t,DstColorFactor as vt,SrcAlphaSaturateFactor as Nt,SrcAlphaFactor as St,SrcColorFactor as wt,OneFactor as Et,CullFaceNone as At,CullFaceBack as Rt,CullFaceFront as Ct,MultiplyBlending as Mt,SubtractiveBlending as Pt,AdditiveBlending as Lt,NotEqualDepth as Ft,GreaterDepth as Bt,GreaterEqualDepth as It,EqualDepth as Dt,LessEqualDepth as Vt,LessDepth as Ut,AlwaysDepth as Ot,NeverDepth as kt,UnsignedShort4444Type as Gt,UnsignedShort5551Type as zt,UnsignedInt5999Type as Ht,AlphaFormat as $t,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as jt,RGBA_S3TC_DXT3_Format as qt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Kt,RGB_PVRTC_2BPPV1_Format as Yt,RGBA_PVRTC_4BPPV1_Format as Qt,RGBA_PVRTC_2BPPV1_Format as Zt,RGB_ETC1_Format as Jt,RGB_ETC2_Format as er,RGBA_ETC2_EAC_Format as tr,RGBA_ASTC_4x4_Format as rr,RGBA_ASTC_5x4_Format as sr,RGBA_ASTC_5x5_Format as ir,RGBA_ASTC_6x5_Format as nr,RGBA_ASTC_6x6_Format as ar,RGBA_ASTC_8x5_Format as or,RGBA_ASTC_8x6_Format as ur,RGBA_ASTC_8x8_Format as lr,RGBA_ASTC_10x5_Format as dr,RGBA_ASTC_10x6_Format as cr,RGBA_ASTC_10x8_Format as hr,RGBA_ASTC_10x10_Format as pr,RGBA_ASTC_12x10_Format as gr,RGBA_ASTC_12x12_Format as mr,RGBA_BPTC_Format as fr,RED_RGTC1_Format as yr,SIGNED_RED_RGTC1_Format as xr,RED_GREEN_RGTC2_Format as br,SIGNED_RED_GREEN_RGTC2_Format as Tr,MirroredRepeatWrapping as _r,ClampToEdgeWrapping as vr,RepeatWrapping as Nr,NearestMipmapNearestFilter as Sr,NotEqualCompare as wr,GreaterCompare as Er,GreaterEqualCompare as Ar,EqualCompare as Rr,LessEqualCompare as Cr,AlwaysCompare as Mr,NeverCompare as Pr,LinearTransfer as Lr,NotEqualStencilFunc as Fr,GreaterStencilFunc as Br,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as kr,DecrementWrapStencilOp as Gr,IncrementWrapStencilOp as zr,DecrementStencilOp as Hr,IncrementStencilOp as $r,InvertStencilOp as Wr,ReplaceStencilOp as jr,ZeroStencilOp as qr,KeepStencilOp as Xr,MaxEquation as Kr,MinEquation as Yr,SpotLight as Qr,PointLight as Zr,DirectionalLight as Jr,RectAreaLight as es,AmbientLight as ts,HemisphereLight as rs,LightProbe as ss,LinearToneMapping as is,ReinhardToneMapping as ns,CineonToneMapping as as,ACESFilmicToneMapping as os,AgXToneMapping as us,NeutralToneMapping as ls,Group as ds,Loader as cs,FileLoader as hs,MaterialLoader as ps,ObjectLoader as gs}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,ConstantAlphaFactor,ConstantColorFactor,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CustomToneMapping,Cylindrical,Data3DTexture,DataTextureLoader,DataUtils,DefaultLoadingManager,DetachedBindMode,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,MeshDepthMaterial,MeshDistanceMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NormalAnimationBlendMode,NumberKeyframeTrack,OctahedronGeometry,OneMinusConstantAlphaFactor,OneMinusConstantColorFactor,PCFSoftShadowMap,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format,RGDepthPacking,RawShaderMaterial,Ray,Raycaster,RenderTarget3D,RingGeometry,ShaderMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Spherical,SphericalHarmonics3,SplineCurve,SpotLightHelper,Sprite,StaticCopyUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding}from"./three.core.min.js";const ms=["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 fs{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=ms,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Ls,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:ws,getTypedArrayFromType:Es,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const wi=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)wi.set(e,new si(e,"int"));const Ei=new Map([...wi].map((e=>new si(e.value))));for(const e of vi)Ei.set(e,new si(e));for(const e of vi)Ei.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:wi,float:Ei},Ri=new Map([...Ni,...Ei]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),wn=Ui(gn,"float","Iridescence"),En=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Ln=Ui(gn,"color","SpecularColor"),Fn=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),wa=Vi(aa,"^").setParameterLength(2).setName("bitXor"),Ea=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",wa),oi("shiftLeft",Ea),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const La=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),Fa=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",La),oi("modInt",Fa);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),wo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),Eo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Lo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Fo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>Eo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=Eo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",Eo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Lo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",wo),oi("saturate",Vo),oi("cbrt",Fo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class wu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new wu(Bi(e),t,r));oi("compute",Eu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Lu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Fu=Vi(Lu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Lu).setParameterLength(3,5);oi("remap",Fu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),wl=Ui(Nl,Nl.WORLD_MATRIX),El=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Ll=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Fl)).once()().toVar("modelViewMatrix"),Fl=cl.mul(wl),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>wl.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(wl).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=wl])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new w,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new E;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Ll.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),wd=Nd.toVar("transformedTangentView"),Ed=wd.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Ld=Ad(Ql.cross(wd),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Fd=Ld.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_GAP_SIZE="gapSize",Wd.LINE_WIDTH="linewidth",Wd.LINE_DASH_OFFSET="dashOffset",Wd.POINT_SIZE="size",Wd.DISPERSION="dispersion",Wd.LIGHT_MAP="light",Wd.AO="ao";const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isotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Lc=Ui(Pc,Pc.VERTEX),Fc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Fc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new L(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Fc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=ws(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Ls(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Lc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new F(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Fc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const wh=Vi(Sh).setParameterLength(0,3),Eh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Lh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Fh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Lh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Fh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Ll.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Ll.mul(nn(e,1))).toVar("start"),s=nn(Ll.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new E;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Ln,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const wp=new ie;class Ep extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(wp),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Ln.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lp=ji(1/Math.PI),Fp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Lp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=wn.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Fp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=Eh(),ag=Eh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:En,cosTheta1:e,thinFilmThickness:An,baseF0:Ln}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Ln,Fn,t,wl,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?wn.mix(Ln,this.iridescenceF0):Ln).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Ln.add(Ln.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Ln,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Ln.mul(f.x).add(Ln.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Fn);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),wg=ji(.21),Eg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(wg),(()=>{t.assign(Ng.sub(e).mul(Eg.sub(Sg)).div(Ng.sub(wg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Lg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Fg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Lg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Fg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Ln.assign(e),Fn.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Ln.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Fn.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;wn.assign(e),En.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):Ec;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),wm=new ye;class Em extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(wm),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Ll.mul(en(i||0));let u=Yi(wl[0].xyz.length(),wl[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Lm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ll.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):wc;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Fm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Fm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Lh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?Ee:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=wf){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Fi(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Fi(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Fi(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Lf extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Ff extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=wl.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=wl;const i=cl.mul(s);return Pi(t)&&(i[0][0]=wl[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=wl[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Le,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Fe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Fe(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const wy=(e,...t)=>Bi(new Sy(Bi(e),...t)),Ey=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=Ey(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(Ey(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(Ey(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(Ey(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(Ey(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends L{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ly=Ui(Py),Fy=new w,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Fy.copy(r.backgroundRotation),Fy.x*=-1,Fy.y*=-1,Fy.z*=-1,By.makeRotationFromEuler(Fy)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Ll).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(Eo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>Eo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Fh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Ll),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wx=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ex extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(Ex).setParameterLength(1,3);class Rx extends Ex{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Fs(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Lx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Fx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Lx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Lx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Fx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function wb(e,t,r){Tb(e,r),Nb(t,r)}var Eb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:wb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Lb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Fb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Lb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Ls(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Fb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,wb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),wT=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ET=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(ET(i)).toVar(),o=ji(ET(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(ET(n)).toVar(),l=ji(ET(a)).toVar(),d=ji(ET(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return wT(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return wT(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return wT(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return wT(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),LT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(wT(AT(r,qi(0))),wT(AT(r,qi(1))),wT(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(wT(AT(r,s,qi(0))),wT(AT(r,s,qi(1))),wT(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(wT(AT(r,s,i,qi(0))),wT(AT(r,s,i,qi(1))),wT(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(wT(AT(r,s,i,n,qi(0))),wT(AT(r,s,i,n,qi(1))),wT(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),FT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(FT(o,a,n,i),FT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(FT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(LT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),Eo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(LT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),Eo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Fi,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:wa,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Fo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:Eu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new L(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinIndexNode=qc(new L(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.skinWeightNode=qc(new L(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Fc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():wy(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:wo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:Eo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Li,getCurrentStack:zi,getDirection:Lg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Fb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:Ey,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Fc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=Es("float")):(r=As(t),s=Es(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:wn,iridescenceIOR:En,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:Ec,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:wc,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Fl,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:Fa,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:El,modelRadius:Cl,modelScale:Al,modelViewMatrix:Ll,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:wl,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>FT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:wx,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Fh,pmremTexture:um,pointShadow:Jb,pointUV:Ly,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:La,remap:Fu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:wy,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:Ea,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Ln,specularF90:Fn,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Fg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Lo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Ld,transformedBitangentWorld:Fd,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:wd,transformedTangentWorld:Ed,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Lc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Lh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:Eh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:wh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class L_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=ws(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new w_(e);if("mat2"===t)return new E_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class F_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new F_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new Ef(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(wv),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(wv),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:Ev;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:w,transparent:E,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&E.length>0&&this._renderTransparents(E,w,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:Ev;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Lv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Fv extends Lv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Fv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Fv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[Er]:e.GREATER,[wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Lr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=e.textures;r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i);for(let r=0;r{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",wN="triangle-strip",EN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",LN="greater-equal",FN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",wS="depth16unorm",ES="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",LS="bc2-rgba-unorm",FS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",ew="astc-4x4-unorm",tw="astc-4x4-unorm-srgb",rw="astc-5x4-unorm",sw="astc-5x4-unorm-srgb",iw="astc-5x5-unorm",nw="astc-5x5-unorm-srgb",aw="astc-6x5-unorm",ow="astc-6x5-unorm-srgb",uw="astc-6x6-unorm",lw="astc-6x6-unorm-srgb",dw="astc-8x5-unorm",cw="astc-8x5-unorm-srgb",hw="astc-8x6-unorm",pw="astc-8x6-unorm-srgb",gw="astc-8x8-unorm",mw="astc-8x8-unorm-srgb",fw="astc-10x5-unorm",yw="astc-10x5-unorm-srgb",xw="astc-10x6-unorm",bw="astc-10x6-unorm-srgb",Tw="astc-10x8-unorm",_w="astc-10x8-unorm-srgb",vw="astc-10x10-unorm",Nw="astc-10x10-unorm-srgb",Sw="astc-12x10-unorm",ww="astc-12x10-unorm-srgb",Ew="astc-12x12-unorm",Aw="astc-12x12-unorm-srgb",Rw="clamp-to-edge",Cw="repeat",Mw="mirror-repeat",Pw="linear",Lw="nearest",Fw="zero",Bw="one",Iw="src",Dw="one-minus-src",Vw="src-alpha",Uw="one-minus-src-alpha",Ow="dst",kw="one-minus-dst",Gw="dst-alpha",zw="one-minus-dst-alpha",Hw="src-alpha-saturated",$w="constant",Ww="one-minus-constant",jw="add",qw="subtract",Xw="reverse-subtract",Kw="min",Yw="max",Qw=0,Zw=15,Jw="keep",eE="zero",tE="replace",rE="invert",sE="increment-clamp",iE="decrement-clamp",nE="increment-wrap",aE="decrement-wrap",oE="storage",uE="read-only-storage",lE="write-only",dE="read-only",cE="read-write",hE="non-filtering",pE="comparison",gE="float",mE="unfilterable-float",fE="depth",yE="sint",xE="uint",bE="2d",TE="3d",_E="2d",vE="2d-array",NE="cube",SE="3d",wE="all",EE="vertex",AE="instance",RE={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class CE extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class ME extends CE{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class PE extends Lv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let LE=0;class FE extends PE{constructor(e,t){super("StorageBuffer_"+LE++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class BE extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:Pw}),this.flipYSampler=e.createSampler({minFilter:Lw}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:wN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_E,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kE=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,GE={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zE extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(OE);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kE.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class HE extends q_{parseFunction(e){return new zE(e)}}const $E="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},WE={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jE={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qE={vertex:$E?$E.VERTEX:1,fragment:$E?$E.FRAGMENT:2,compute:$E?$E.COMPUTE:4},XE={instance:!0,swizzleAssign:!1,storageBuffer:!0},KE={"^^":"tsl_xor"},YE={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},QE={},ZE={tsl_xor:new Ex("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ex("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ex("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ex("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ex("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ex("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ex("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ex("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Ex("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Ex("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ex("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 Ex("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ex("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},JE={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(ZE.pow_float=new Ex("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),ZE.pow_vec2=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec3=new Ex("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 ) ); }",[ZE.pow_float]),ZE.pow_vec4=new Ex("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 ) ); }",[ZE.pow_float]),JE.pow_float="tsl_pow_float",JE.pow_vec2="tsl_pow_vec2",JE.pow_vec3="tsl_pow_vec3",JE.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends L_{constructor(e,t){super(e,t,new HE),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jE[e.wrapS]}S_${jE[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=QE[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(ZE.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(ZE.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(ZE.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",QE[t]=r=new Ex(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=KE[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return WE[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qE[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new ME(`${i.name}_sampler`,i.node,o);e.setVisibility(qE[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:FE)(e,o);n.setVisibility(qE[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qE[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${UE(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return YE[e]||e}isAvailable(e){let t=XE[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),XE[e]=t),t}_getWGSLMethod(e){return void 0!==ZE[e]&&this._include(e),JE[e]}_include(e){const t=ZE[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=ES),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mE)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mE:s.sampleType=fE;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yE:e===T?s.sampleType=xE:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gE:s.sampleType=mE)}r.isSampledCubeTexture?s.viewDimension=NE:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vE:r.isSampledTexture3D&&(s.viewDimension=SE),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=wE;let n;n=t.isSampledCubeTexture?NE:t.isSampledTexture3D?SE:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vE:_E,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},w={},E=e.context.depth,A=e.context.stencil;if(!0!==E&&!0!==A||(!0===E&&(w.format=v,w.depthWriteEnabled=s.depthWrite,w.depthCompare=_),!0===A&&(w.stencilFront=m,w.stencilBack={},w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),S.depthStencil=w),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jw},r={srcFactor:i,dstFactor:n,operation:jw}};if(e.premultipliedAlpha)switch(s){case O:i(Bw,Uw,Bw,Uw);break;case Lt:i(Bw,Bw,Bw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Vw)}else switch(s){case O:i(Vw,Uw,Bw,Uw);break;case Lt:i(Vw,Bw,Vw,Bw);break;case Pt:i(Fw,Dw,Fw,Bw);break;case Mt:i(Fw,Iw,Fw,Iw)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=Fw;break;case Et:t=Bw;break;case wt:t=Iw;break;case Tt:t=Dw;break;case St:t=Vw;break;case bt:t=Uw;break;case vt:t=Ow;break;case xt:t=kw;break;case _t:t=Gw;break;case yt:t=zw;break;case Nt:t=Hw;break;case 211:t=$w;break;case 212:t=Ww;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=EN;break;case Or:t=FN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=LN;break;case Br:t=MN;break;case Fr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=Jw;break;case qr:t=eE;break;case jr:t=tE;break;case Wr:t=rE;break;case $r:t=sE;break;case Hr:t=iE;break;case zr:t=nE;break;case Gr:t=aE;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jw;break;case ft:t=qw;break;case mt:t=Xw;break;case Yr:t=Kw;break;case Kr:t=Yw;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?Zw:Qw}_getDepthCompare(e){let t;if(!1===e.depthTest)t=FN;else{const r=e.depthFunc;switch(r){case kt:t=EN;break;case Ot:t=FN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=LN;break;case Bt:t=MN;break;case Ft:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new VE(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(RE),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(RE.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==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 e=!1;for(let r=0;r>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;ee.charCodeAt(0))).buffer}var Is=Object.freeze({__proto__:null,arrayBufferToBase64:Ls,base64ToArrayBuffer:Bs,getByteBoundaryFromType:Cs,getCacheKey:_s,getDataFromObject:Fs,getLengthFromType:As,getMemoryLengthFromType:Rs,getNodeChildren:vs,getTypeFromLength:Es,getTypedArrayFromType:ws,getValueFromType:Ps,getValueType:Ms,hash:Ts,hashArray:bs,hashString:xs});const Ds={VERTEX:"vertex",FRAGMENT:"fragment"},Vs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Us={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Os={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ks=["fragment","vertex"],Gs=["setup","analyze","generate"],zs=[...ks,"compute"],Hs=["x","y","z","w"],$s={analyze:"setup",generate:"analyze"};let Ws=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Vs.NONE,this.updateBeforeType=Vs.NONE,this.updateAfterType=Vs.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Ws++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Vs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Vs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Vs.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of vs(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ts(_s(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=$s[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return vs(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class qs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Xs extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ks extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Ys extends Ks{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Qs=Hs.join("");class Zs extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Hs.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Qs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Js extends Ks{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),li=e=>ui(e).split("").sort().join(""),di={setup(e,t){const r=t.shift();return e(Ii(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ni.assign(r,...e),r);if(ai.has(t)){const s=ai.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&ai.has(t.slice(0,t.length-6))){const s=ai.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=ui(t),Bi(new Zs(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(3).toLowerCase()),r=>Bi(new Js(e,t,Bi(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=li(t.slice(4).toLowerCase()),()=>Bi(new ei(Bi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Bi(new Zs(e,t));if(!0===/^\d+$/.test(t))return Bi(new qs(r,new si(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Bi(new ii(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},ci=new WeakMap,hi=new WeakMap,pi=function(e,t=null){for(const r in e)e[r]=Bi(e[r],t);return e},gi=function(e,t=null){const r=e.length;for(let s=0;sBi(null!==s?Object.assign(e,s):e);let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.lengtho?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Di(l(t)))):null!==r?(r=Bi(r),n=(...s)=>i(new e(t,...Di(l(s)),r))):n=(...r)=>i(new e(t,...Di(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},fi=function(e,...t){return Bi(new e(...Di(t)))};class yi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let s=hi.get(e.constructor);void 0===s&&(s=new WeakMap,hi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Bi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),n=Bi(i.call(r))}else{const s=t.jsFunc,i=null!==r||s.length>1?s(r||[],e):s(e);n=Bi(i)}return t.once&&(s[i]=n),n}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getOutputNamespace();return t[r]=t[r]||this.setupOutput(e),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getOutputNamespace(),a=this.getOutputNode(e);if("setup"===s){const t=e.getNamespace("initialized");!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e)),r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Ii(e),Bi(new yi(this,e))}setup(){return this.call()}}const bi=[!1,!0],Ti=[0,1,2,3],_i=[-1,-2],vi=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Ni=new Map;for(const e of bi)Ni.set(e,new si(e));const Si=new Map;for(const e of Ti)Si.set(e,new si(e,"uint"));const Ei=new Map([...Si].map((e=>new si(e.value,"int"))));for(const e of _i)Ei.set(e,new si(e,"int"));const wi=new Map([...Ei].map((e=>new si(e.value))));for(const e of vi)wi.set(e,new si(e));for(const e of vi)wi.set(-e,new si(-e));const Ai={bool:Ni,uint:Si,ints:Ei,float:wi},Ri=new Map([...Ni,...wi]),Ci=(e,t)=>Ri.has(e)?Ri.get(e):!0===e.isNode?e:new si(e,t),Mi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Ps(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Bi(t.get(r[0]));if(1===r.length){const t=Ci(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Bi(t):Bi(new Xs(t,e))}const s=r.map((e=>Ci(e)));return Bi(new Ys(s,e))}},Pi=e=>"object"==typeof e&&null!==e?e.value:e,Fi=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Li(e,t){return new Proxy(new xi(e,t),di)}const Bi=(e,t=null)=>function(e,t=null){const r=Ms(e);if("node"===r){let t=ci.get(e);return void 0===t&&(t=new Proxy(e,di),ci.set(e,t),ci.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Bi(Ci(e,t)):"shader"===r?e.isFn?e:ki(e):e}(e,t),Ii=(e,t=null)=>new pi(e,t),Di=(e,t=null)=>new gi(e,t),Vi=(...e)=>new mi(...e),Ui=(...e)=>new fi(...e);let Oi=0;const ki=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Li(e,r),i=(...e)=>{let t;Ii(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.namespace=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Oi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},Gi=e=>{ni=e},zi=()=>ni,Hi=(...e)=>ni.If(...e);function $i(e){return ni&&ni.add(e),e}oi("toStack",$i);const Wi=new Mi("color"),ji=new Mi("float",Ai.float),qi=new Mi("int",Ai.ints),Xi=new Mi("uint",Ai.uint),Ki=new Mi("bool",Ai.bool),Yi=new Mi("vec2"),Qi=new Mi("ivec2"),Zi=new Mi("uvec2"),Ji=new Mi("bvec2"),en=new Mi("vec3"),tn=new Mi("ivec3"),rn=new Mi("uvec3"),sn=new Mi("bvec3"),nn=new Mi("vec4"),an=new Mi("ivec4"),on=new Mi("uvec4"),un=new Mi("bvec4"),ln=new Mi("mat2"),dn=new Mi("mat3"),cn=new Mi("mat4");oi("toColor",Wi),oi("toFloat",ji),oi("toInt",qi),oi("toUint",Xi),oi("toBool",Ki),oi("toVec2",Yi),oi("toIVec2",Qi),oi("toUVec2",Zi),oi("toBVec2",Ji),oi("toVec3",en),oi("toIVec3",tn),oi("toUVec3",rn),oi("toBVec3",sn),oi("toVec4",nn),oi("toIVec4",an),oi("toUVec4",on),oi("toBVec4",un),oi("toMat2",ln),oi("toMat3",dn),oi("toMat4",cn);const hn=Vi(qs).setParameterLength(2),pn=(e,t)=>Bi(new Xs(Bi(e),t));oi("element",hn),oi("convert",pn);oi("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),$i(e))));class gn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const mn=(e,t)=>Bi(new gn(e,t)),fn=(e,t)=>Bi(new gn(e,t,!0)),yn=Ui(gn,"vec4","DiffuseColor"),xn=Ui(gn,"vec3","EmissiveColor"),bn=Ui(gn,"float","Roughness"),Tn=Ui(gn,"float","Metalness"),_n=Ui(gn,"float","Clearcoat"),vn=Ui(gn,"float","ClearcoatRoughness"),Nn=Ui(gn,"vec3","Sheen"),Sn=Ui(gn,"float","SheenRoughness"),En=Ui(gn,"float","Iridescence"),wn=Ui(gn,"float","IridescenceIOR"),An=Ui(gn,"float","IridescenceThickness"),Rn=Ui(gn,"float","AlphaT"),Cn=Ui(gn,"float","Anisotropy"),Mn=Ui(gn,"vec3","AnisotropyT"),Pn=Ui(gn,"vec3","AnisotropyB"),Fn=Ui(gn,"color","SpecularColor"),Ln=Ui(gn,"float","SpecularF90"),Bn=Ui(gn,"float","Shininess"),In=Ui(gn,"vec4","Output"),Dn=Ui(gn,"float","dashSize"),Vn=Ui(gn,"float","gapSize"),Un=Ui(gn,"float","pointWidth"),On=Ui(gn,"float","IOR"),kn=Ui(gn,"float","Transmission"),Gn=Ui(gn,"float","Thickness"),zn=Ui(gn,"float","AttenuationDistance"),Hn=Ui(gn,"color","AttenuationColor"),$n=Ui(gn,"float","Dispersion");class Wn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const jn=e=>new Wn(e),qn=(e,t=0)=>new Wn(e,!0,t),Xn=qn("frame"),Kn=qn("render"),Yn=jn("object");class Qn extends ti{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Yn}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Zn=(e,t)=>{const r=Fi(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Bi(new Qn(s,r))};class Jn extends Ks{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const ea=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Jn(null,r.length,r)}else{const r=e[0],s=e[1];t=new Jn(r,s)}return Bi(t)};oi("toArray",((e,t)=>ea(Array(t).fill(e))));class ta extends Ks{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Hs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(t=t.length>1||t[0]&&!0===t[0].isNode?Di(t):Ii(t[0]),Bi(new sa(Bi(e),t)));oi("call",ia);const na={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class aa extends Ks{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new aa(e,t,r);for(let t=0;t>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const oa=Vi(aa,"+").setParameterLength(2,1/0).setName("add"),ua=Vi(aa,"-").setParameterLength(2,1/0).setName("sub"),la=Vi(aa,"*").setParameterLength(2,1/0).setName("mul"),da=Vi(aa,"/").setParameterLength(2,1/0).setName("div"),ca=Vi(aa,"%").setParameterLength(2).setName("mod"),ha=Vi(aa,"==").setParameterLength(2).setName("equal"),pa=Vi(aa,"!=").setParameterLength(2).setName("notEqual"),ga=Vi(aa,"<").setParameterLength(2).setName("lessThan"),ma=Vi(aa,">").setParameterLength(2).setName("greaterThan"),fa=Vi(aa,"<=").setParameterLength(2).setName("lessThanEqual"),ya=Vi(aa,">=").setParameterLength(2).setName("greaterThanEqual"),xa=Vi(aa,"&&").setParameterLength(2,1/0).setName("and"),ba=Vi(aa,"||").setParameterLength(2,1/0).setName("or"),Ta=Vi(aa,"!").setParameterLength(1).setName("not"),_a=Vi(aa,"^^").setParameterLength(2).setName("xor"),va=Vi(aa,"&").setParameterLength(2).setName("bitAnd"),Na=Vi(aa,"~").setParameterLength(2).setName("bitNot"),Sa=Vi(aa,"|").setParameterLength(2).setName("bitOr"),Ea=Vi(aa,"^").setParameterLength(2).setName("bitXor"),wa=Vi(aa,"<<").setParameterLength(2).setName("shiftLeft"),Aa=Vi(aa,">>").setParameterLength(2).setName("shiftRight"),Ra=ki((([e])=>(e.addAssign(1),e))),Ca=ki((([e])=>(e.subAssign(1),e))),Ma=ki((([e])=>{const t=qi(e).toConst();return e.addAssign(1),t})),Pa=ki((([e])=>{const t=qi(e).toConst();return e.subAssign(1),t}));oi("add",oa),oi("sub",ua),oi("mul",la),oi("div",da),oi("mod",ca),oi("equal",ha),oi("notEqual",pa),oi("lessThan",ga),oi("greaterThan",ma),oi("lessThanEqual",fa),oi("greaterThanEqual",ya),oi("and",xa),oi("or",ba),oi("not",Ta),oi("xor",_a),oi("bitAnd",va),oi("bitNot",Na),oi("bitOr",Sa),oi("bitXor",Ea),oi("shiftLeft",wa),oi("shiftRight",Aa),oi("incrementBefore",Ra),oi("decrementBefore",Ca),oi("increment",Ma),oi("decrement",Pa);const Fa=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(e,t)),La=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ca(qi(e),qi(t)));oi("remainder",Fa),oi("modInt",La);class Ba extends Ks{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Ba.MAX||e===Ba.MIN)&&arguments.length>3){let i=new Ba(e,t,r);for(let t=2;tn&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Ba.LENGTH||t===Ba.DISTANCE||t===Ba.DOT?"float":t===Ba.CROSS?"vec3":t===Ba.ALL||t===Ba.ANY?"bool":t===Ba.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Ba.ONE_MINUS)i=ua(1,t);else if(s===Ba.RECIPROCAL)i=da(1,t);else if(s===Ba.DIFFERENCE)i=no(ua(t,r));else if(s===Ba.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=nn(en(n),0):s=nn(en(s),0);const a=la(s,n).xyz;i=Qa(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Ba.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Ba.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Ba.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Ba.MIN&&r!==Ba.MAX?r===Ba.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Ba.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Ba.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Ba.DFDX&&r!==Ba.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ba.ALL="all",Ba.ANY="any",Ba.RADIANS="radians",Ba.DEGREES="degrees",Ba.EXP="exp",Ba.EXP2="exp2",Ba.LOG="log",Ba.LOG2="log2",Ba.SQRT="sqrt",Ba.INVERSE_SQRT="inversesqrt",Ba.FLOOR="floor",Ba.CEIL="ceil",Ba.NORMALIZE="normalize",Ba.FRACT="fract",Ba.SIN="sin",Ba.COS="cos",Ba.TAN="tan",Ba.ASIN="asin",Ba.ACOS="acos",Ba.ATAN="atan",Ba.ABS="abs",Ba.SIGN="sign",Ba.LENGTH="length",Ba.NEGATE="negate",Ba.ONE_MINUS="oneMinus",Ba.DFDX="dFdx",Ba.DFDY="dFdy",Ba.ROUND="round",Ba.RECIPROCAL="reciprocal",Ba.TRUNC="trunc",Ba.FWIDTH="fwidth",Ba.TRANSPOSE="transpose",Ba.BITCAST="bitcast",Ba.EQUALS="equals",Ba.MIN="min",Ba.MAX="max",Ba.STEP="step",Ba.REFLECT="reflect",Ba.DISTANCE="distance",Ba.DIFFERENCE="difference",Ba.DOT="dot",Ba.CROSS="cross",Ba.POW="pow",Ba.TRANSFORM_DIRECTION="transformDirection",Ba.MIX="mix",Ba.CLAMP="clamp",Ba.REFRACT="refract",Ba.SMOOTHSTEP="smoothstep",Ba.FACEFORWARD="faceforward";const Ia=ji(1e-6),Da=ji(1e6),Va=ji(Math.PI),Ua=ji(2*Math.PI),Oa=Vi(Ba,Ba.ALL).setParameterLength(1),ka=Vi(Ba,Ba.ANY).setParameterLength(1),Ga=Vi(Ba,Ba.RADIANS).setParameterLength(1),za=Vi(Ba,Ba.DEGREES).setParameterLength(1),Ha=Vi(Ba,Ba.EXP).setParameterLength(1),$a=Vi(Ba,Ba.EXP2).setParameterLength(1),Wa=Vi(Ba,Ba.LOG).setParameterLength(1),ja=Vi(Ba,Ba.LOG2).setParameterLength(1),qa=Vi(Ba,Ba.SQRT).setParameterLength(1),Xa=Vi(Ba,Ba.INVERSE_SQRT).setParameterLength(1),Ka=Vi(Ba,Ba.FLOOR).setParameterLength(1),Ya=Vi(Ba,Ba.CEIL).setParameterLength(1),Qa=Vi(Ba,Ba.NORMALIZE).setParameterLength(1),Za=Vi(Ba,Ba.FRACT).setParameterLength(1),Ja=Vi(Ba,Ba.SIN).setParameterLength(1),eo=Vi(Ba,Ba.COS).setParameterLength(1),to=Vi(Ba,Ba.TAN).setParameterLength(1),ro=Vi(Ba,Ba.ASIN).setParameterLength(1),so=Vi(Ba,Ba.ACOS).setParameterLength(1),io=Vi(Ba,Ba.ATAN).setParameterLength(1,2),no=Vi(Ba,Ba.ABS).setParameterLength(1),ao=Vi(Ba,Ba.SIGN).setParameterLength(1),oo=Vi(Ba,Ba.LENGTH).setParameterLength(1),uo=Vi(Ba,Ba.NEGATE).setParameterLength(1),lo=Vi(Ba,Ba.ONE_MINUS).setParameterLength(1),co=Vi(Ba,Ba.DFDX).setParameterLength(1),ho=Vi(Ba,Ba.DFDY).setParameterLength(1),po=Vi(Ba,Ba.ROUND).setParameterLength(1),go=Vi(Ba,Ba.RECIPROCAL).setParameterLength(1),mo=Vi(Ba,Ba.TRUNC).setParameterLength(1),fo=Vi(Ba,Ba.FWIDTH).setParameterLength(1),yo=Vi(Ba,Ba.TRANSPOSE).setParameterLength(1),xo=Vi(Ba,Ba.BITCAST).setParameterLength(2),bo=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ha(e,t)),To=Vi(Ba,Ba.MIN).setParameterLength(2,1/0),_o=Vi(Ba,Ba.MAX).setParameterLength(2,1/0),vo=Vi(Ba,Ba.STEP).setParameterLength(2),No=Vi(Ba,Ba.REFLECT).setParameterLength(2),So=Vi(Ba,Ba.DISTANCE).setParameterLength(2),Eo=Vi(Ba,Ba.DIFFERENCE).setParameterLength(2),wo=Vi(Ba,Ba.DOT).setParameterLength(2),Ao=Vi(Ba,Ba.CROSS).setParameterLength(2),Ro=Vi(Ba,Ba.POW).setParameterLength(2),Co=Vi(Ba,Ba.POW,2).setParameterLength(1),Mo=Vi(Ba,Ba.POW,3).setParameterLength(1),Po=Vi(Ba,Ba.POW,4).setParameterLength(1),Fo=Vi(Ba,Ba.TRANSFORM_DIRECTION).setParameterLength(2),Lo=e=>la(ao(e),Ro(no(e),1/3)),Bo=e=>wo(e,e),Io=Vi(Ba,Ba.MIX).setParameterLength(3),Do=(e,t=0,r=1)=>Bi(new Ba(Ba.CLAMP,Bi(e),Bi(t),Bi(r))),Vo=e=>Do(e),Uo=Vi(Ba,Ba.REFRACT).setParameterLength(3),Oo=Vi(Ba,Ba.SMOOTHSTEP).setParameterLength(3),ko=Vi(Ba,Ba.FACEFORWARD).setParameterLength(3),Go=ki((([e])=>{const t=wo(e.xy,Yi(12.9898,78.233)),r=ca(t,Va);return Za(Ja(r).mul(43758.5453))})),zo=(e,t,r)=>Io(t,r,e),Ho=(e,t,r)=>Oo(t,r,e),$o=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),io(e,t)),Wo=ko,jo=Xa;oi("all",Oa),oi("any",ka),oi("equals",bo),oi("radians",Ga),oi("degrees",za),oi("exp",Ha),oi("exp2",$a),oi("log",Wa),oi("log2",ja),oi("sqrt",qa),oi("inverseSqrt",Xa),oi("floor",Ka),oi("ceil",Ya),oi("normalize",Qa),oi("fract",Za),oi("sin",Ja),oi("cos",eo),oi("tan",to),oi("asin",ro),oi("acos",so),oi("atan",io),oi("abs",no),oi("sign",ao),oi("length",oo),oi("lengthSq",Bo),oi("negate",uo),oi("oneMinus",lo),oi("dFdx",co),oi("dFdy",ho),oi("round",po),oi("reciprocal",go),oi("trunc",mo),oi("fwidth",fo),oi("atan2",$o),oi("min",To),oi("max",_o),oi("step",vo),oi("reflect",No),oi("distance",So),oi("dot",wo),oi("cross",Ao),oi("pow",Ro),oi("pow2",Co),oi("pow3",Mo),oi("pow4",Po),oi("transformDirection",Fo),oi("mix",zo),oi("clamp",Do),oi("refract",Uo),oi("smoothstep",Ho),oi("faceForward",ko),oi("difference",Eo),oi("saturate",Vo),oi("cbrt",Lo),oi("transpose",yo),oi("rand",Go);class qo extends js{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?mn(r).build(e):"";s.nodeProperty=l;const d=i.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${d} ) {\n\n`).addFlowTab();let c=n.build(e,r);if(c&&(u?c=l+" = "+c+";":(c="return "+c+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"\t"+c+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Xo=Vi(qo).setParameterLength(2,3);oi("select",Xo);const Ko=(...e)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),Xo(...e));oi("cond",Ko);class Yo extends js{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){const r=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,t);return e.setContext(r),s}}const Qo=Vi(Yo).setParameterLength(1,2),Zo=(e,t)=>Qo(e,{label:t});oi("context",Qo),oi("label",Zo);class Jo extends js{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,o=!1;s&&(a=e.isDeterministic(t),o=n?s:a);const u=e.getVectorType(this.getNodeType(e)),l=t.build(e,u),d=e.getVarFromNode(this,r,u,void 0,o),c=e.getPropertyName(d);let h=c;if(o)if(n)h=a?`const ${c}`:`let ${c}`;else{const r=e.getArrayCount(t);h=`const ${e.getVar(d.type,c,r)}`}return e.addLineFlowCode(`${h} = ${l}`,this),c}}const eu=Vi(Jo),tu=(e,t=null)=>eu(e,t).toStack(),ru=(e,t=null)=>eu(e,t,!0).toStack();oi("toVar",tu),oi("toConst",ru);const su=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),eu(e));oi("temp",su);class iu extends js{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=this.node}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ds.VERTEX,this.node)}generate(e){const t=e.getNodeProperties(this),r=this.setupVarying(e);if(void 0===t.propertyName){const s=this.getNodeType(e),i=e.getPropertyName(r,Ds.VERTEX);e.flowNodeFromShaderStage(Ds.VERTEX,this.node,s,i),t.propertyName=i}return e.getPropertyName(r)}}const nu=Vi(iu).setParameterLength(1,2),au=e=>nu(e);oi("toVarying",nu),oi("toVertexStage",au),oi("varying",((...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),nu(...e)))),oi("vertexStage",((...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),nu(...e))));const ou=ki((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return Io(t,r,s)})).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uu=ki((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return Io(t,r,s)})).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),lu="WorkingColorSpace";class du extends Ks{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===lu?c.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==c.enabled&&r!==s&&r&&s?(c.getTransfer(r)===h&&(i=nn(ou(i.rgb),i.a)),c.getPrimaries(r)!==c.getPrimaries(s)&&(i=nn(dn(c._getMatrix(new n,r,s)).mul(i.rgb),i.a)),c.getTransfer(s)===h&&(i=nn(uu(i.rgb),i.a)),i):i}}const cu=(e,t)=>Bi(new du(Bi(e),lu,t)),hu=(e,t)=>Bi(new du(Bi(e),t,lu));oi("workingToColorSpace",cu),oi("colorSpaceToWorking",hu);let pu=class extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class gu extends js{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Vs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Bi(new pu(this,Bi(e)))}setNodeType(e){const t=Zn(null,e).getSelf();null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new mu(e,t,r));class yu extends Ks{static get type(){return"ToneMappingNode"}constructor(e,t=bu,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ts(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,r=this.toneMapping;if(r===p)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=nn(i(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const xu=(e,t,r)=>Bi(new yu(e,Bi(t),Bi(r))),bu=fu("toneMappingExposure","float");oi("toneMapping",((e,t,r)=>xu(t,r,e)));class Tu extends ti{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=g,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),i=this.bufferStride||s,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new m(r,i),o=new f(a,s,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let i=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,i=s;else{i=nu(this).build(e,t)}return i}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const _u=(e,t=null,r=0,s=0)=>Bi(new Tu(e,t,r,s)),vu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setUsage(y),Nu=(e,t=null,r=0,s=0)=>_u(e,t,r,s).setInstanced(!0),Su=(e,t=null,r=0,s=0)=>vu(e,t,r,s).setInstanced(!0);oi("toAttribute",(e=>_u(e.value)));class Eu extends js{static get type(){return"ComputeNode"}constructor(e,t,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Vs.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let r=t[0];for(let e=1;eBi(new Eu(Bi(e),t,r));oi("compute",wu);class Au extends js{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}}const Ru=(e,t)=>Bi(new Au(Bi(e),t)),Cu=(e,t)=>e.context({namespace:t});oi("cache",Ru);class Mu extends js{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pu=Vi(Mu).setParameterLength(2);oi("bypass",Pu);class Fu extends js{static get type(){return"RemapNode"}constructor(e,t,r,s=ji(0),i=ji(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=i,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:i,doClamp:n}=this;let a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(i.sub(s)).add(s)}}const Lu=Vi(Fu,null,null,{doClamp:!1}).setParameterLength(3,5),Bu=Vi(Fu).setParameterLength(3,5);oi("remap",Lu),oi("remapClamp",Bu);class Iu extends js{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Du=Vi(Iu).setParameterLength(1,2),Vu=e=>(e?Xo(e,Du("discard")):Du("discard")).toStack();oi("discard",Vu);class Uu extends Ks{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||p,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||x;return r!==p&&(t=t.toneMapping(r)),s!==x&&s!==c.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Ou=(e,t=null,r=null)=>Bi(new Uu(Bi(e),t,r));oi("renderOutput",Ou);class ku extends Ks{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(s.length);let n="";return n+="// #"+s+"#\n",n+=e.flow.code.replace(/^\t/gm,"")+"\n",n+="/* ... */ "+r+" /* ... */\n",n+="// #"+i+"#\n",null!==t?t(e,n):console.log(n),r}}const Gu=(e,t=null)=>Bi(new ku(Bi(e),t));oi("debug",Gu);class zu extends js{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return nu(this).build(e,r)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Hu=(e,t=null)=>Bi(new zu(e,t)),$u=(e=0)=>Hu("uv"+(e>0?e:""),"vec2");class Wu extends js{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ju=Vi(Wu).setParameterLength(1,2);class qu extends Qn{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Vs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xu=Vi(qu).setParameterLength(1),Ku=new b;class Yu extends Qn{static get type(){return"TextureNode"}constructor(e=Ku,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Vs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===T?"uvec4":this.value.type===_?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return $u(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Zn(this.value.matrix)),this._matrixUniform.mul(en(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Vs.OBJECT:Vs.NONE,this}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.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(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,s,i,n,a,o){const u=this.value;let l;return l=s?e.generateTextureLevel(u,t,r,s,n):i?e.generateTextureBias(u,t,r,i,n):o?e.generateTextureGrad(u,t,r,o,n):a?e.generateTextureCompare(u,t,r,a,n):!1===this.sampler?e.generateTextureLoad(u,t,r,n):e.generateTexture(u,t,r,n),l}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=n.propertyName;if(void 0===a){const{uvNode:t,levelNode:r,biasNode:o,compareNode:u,depthNode:l,gradNode:d}=s,c=this.generateUV(e,t),h=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=l?l.build(e,"int"):null,m=u?u.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);const x=this.generateSnippet(e,i,c,h,p,g,m,f);e.addLineFlowCode(`${a} = ${x}`,this),n.snippet=x,n.propertyName=a}let o=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=hu(Du(o,u),r.colorSpace).setup(e).build(e,u)),e.format(o,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}blur(e){const t=this.clone();t.biasNode=Bi(e).mul(Xu(t)),t.referenceNode=this.getSelf();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===v||r.magFilter===v)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Bi(t)}level(e){const t=this.clone();return t.levelNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}size(e){return ju(this,e)}bias(e){const t=this.clone();return t.biasNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}compare(e){const t=this.clone();return t.compareNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}grad(e,t){const r=this.clone();return r.gradNode=[Bi(e),Bi(t)],r.referenceNode=this.getSelf(),Bi(r)}depth(e){const t=this.clone();return t.depthNode=Bi(e),t.referenceNode=this.getSelf(),Bi(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Qu=Vi(Yu).setParameterLength(1,4).setName("texture"),Zu=(e=Ku,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=Qu(e,t,r,s),i},Ju=(...e)=>Zu(...e).setSampler(!1);class el extends Qn{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const tl=(e,t,r)=>Bi(new el(e,t,r));class rl extends qs{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class sl extends el{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Ms(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Vs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rBi(new sl(e,t));const nl=Vi(class extends js{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}).setParameterLength(1),al=Zn(0,"uint").label("u_cameraIndex").setGroup(qn("cameraIndex")).toVarying("v_cameraIndex"),ol=Zn("float").label("cameraNear").setGroup(Kn).onRenderUpdate((({camera:e})=>e.near)),ul=Zn("float").label("cameraFar").setGroup(Kn).onRenderUpdate((({camera:e})=>e.far)),ll=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);t=il(r).setGroup(Kn).label("cameraProjectionMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrix")}else t=Zn("mat4").label("cameraProjectionMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrix));return t})).once()(),dl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);t=il(r).setGroup(Kn).label("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraProjectionMatrixInverse")}else t=Zn("mat4").label("cameraProjectionMatrixInverse").setGroup(Kn).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse));return t})).once()(),cl=ki((({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);t=il(r).setGroup(Kn).label("cameraViewMatrices").element(e.isMultiViewCamera?nl("gl_ViewID_OVR"):al).toVar("cameraViewMatrix")}else t=Zn("mat4").label("cameraViewMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorldInverse));return t})).once()(),hl=Zn("mat4").label("cameraWorldMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.matrixWorld)),pl=Zn("mat3").label("cameraNormalMatrix").setGroup(Kn).onRenderUpdate((({camera:e})=>e.normalMatrix)),gl=Zn(new r).label("cameraPosition").setGroup(Kn).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),ml=new N;class fl extends js{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Vs.OBJECT,this.uniformNode=new Qn(null)}getNodeType(){const e=this.scope;return e===fl.WORLD_MATRIX?"mat4":e===fl.POSITION||e===fl.VIEW_POSITION||e===fl.DIRECTION||e===fl.SCALE?"vec3":e===fl.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===fl.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===fl.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===fl.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===fl.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===fl.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===fl.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),ml.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=ml.radius}}generate(e){const t=this.scope;return t===fl.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===fl.POSITION||t===fl.VIEW_POSITION||t===fl.DIRECTION||t===fl.SCALE?this.uniformNode.nodeType="vec3":t===fl.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}fl.WORLD_MATRIX="worldMatrix",fl.POSITION="position",fl.SCALE="scale",fl.VIEW_POSITION="viewPosition",fl.DIRECTION="direction",fl.RADIUS="radius";const yl=Vi(fl,fl.DIRECTION).setParameterLength(1),xl=Vi(fl,fl.WORLD_MATRIX).setParameterLength(1),bl=Vi(fl,fl.POSITION).setParameterLength(1),Tl=Vi(fl,fl.SCALE).setParameterLength(1),_l=Vi(fl,fl.VIEW_POSITION).setParameterLength(1),vl=Vi(fl,fl.RADIUS).setParameterLength(1);class Nl extends fl{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Sl=Ui(Nl,Nl.DIRECTION),El=Ui(Nl,Nl.WORLD_MATRIX),wl=Ui(Nl,Nl.POSITION),Al=Ui(Nl,Nl.SCALE),Rl=Ui(Nl,Nl.VIEW_POSITION),Cl=Ui(Nl,Nl.RADIUS),Ml=Zn(new n).onObjectUpdate((({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld))),Pl=Zn(new a).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),Fl=ki((e=>e.renderer.overrideNodes.modelViewMatrix||Ll)).once()().toVar("modelViewMatrix"),Ll=cl.mul(El),Bl=ki((e=>(e.context.isHighPrecisionModelViewMatrix=!0,Zn("mat4").onObjectUpdate((({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))))).once()().toVar("highpModelViewMatrix"),Il=ki((e=>{const t=e.context.isHighPrecisionModelViewMatrix;return Zn("mat3").onObjectUpdate((({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix))))})).once()().toVar("highpModelNormalViewMatrix"),Dl=Hu("position","vec3"),Vl=Dl.toVarying("positionLocal"),Ul=Dl.toVarying("positionPrevious"),Ol=ki((e=>El.mul(Vl).xyz.toVarying(e.getNamespace("v_positionWorld"))),"vec3").once("POSITION")(),kl=ki((e=>Vl.transformDirection(El).toVarying(e.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection")),"vec3").once("POSITION")(),Gl=ki((e=>e.context.setupPositionView().toVarying(e.getNamespace("v_positionView"))),"vec3").once("POSITION")(),zl=Gl.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Hl extends js{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:r}=e;return t.coordinateSystem===l&&r.side===S?"false":e.getFrontFacing()}}const $l=Ui(Hl),Wl=ji($l).mul(2).sub(1),jl=Hu("normal","vec3"),ql=ki((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),en(0,1,0)):jl),"vec3").once()().toVar("normalLocal"),Xl=Gl.dFdx().cross(Gl.dFdy()).normalize().toVar("normalFlat"),Kl=ki((e=>{let t;return t=!0===e.material.flatShading?Xl:nu(td(ql),"v_normalView").normalize(),t}),"vec3").once()().toVar("normalView"),Yl=ki((e=>{let t=Kl.transformDirection(cl);return!0!==e.material.flatShading&&(t=nu(t,"v_normalWorld")),t}),"vec3").once()().normalize().toVar("normalWorld"),Ql=ki((e=>{let t=e.context.setupNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedNormalView"),Zl=Ql.transformDirection(cl).toVar("transformedNormalWorld"),Jl=ki((e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return!0!==e.material.flatShading&&(t=t.mul(Wl)),t}),"vec3").once()().toVar("transformedClearcoatNormalView"),ed=ki((([e,t=El])=>{const r=dn(t),s=e.div(en(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz})),td=ki((([e],t)=>{const r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);const s=Ml.mul(e);return cl.transformDirection(s)})),rd=new E,sd=new a,id=Zn(0).onReference((({material:e})=>e)).onObjectUpdate((({material:e})=>e.refractionRatio)),nd=Zn(1).onReference((({material:e})=>e)).onObjectUpdate((function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity})),ad=Zn(new a).onReference((function(e){return e.material})).onObjectUpdate((function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(rd.copy(r),sd.makeRotationFromEuler(rd)):sd.identity(),sd})),od=zl.negate().reflect(Ql),ud=zl.negate().refract(Ql,id),ld=od.transformDirection(cl).toVar("reflectVector"),dd=ud.transformDirection(cl).toVar("reflectVector"),cd=new w;class hd extends Yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===A?ld:e.mapping===R?dd:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),en(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.renderer.coordinateSystem!==d&&r.isRenderTargetTexture||(t=en(t.x.negate(),t.yz)),ad.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const pd=Vi(hd).setParameterLength(1,4).setName("cubeTexture"),gd=(e=cd,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=Bi(e.clone()),i.referenceNode=e.getSelf(),null!==t&&(i.uvNode=Bi(t)),null!==r&&(i.levelNode=Bi(r)),null!==s&&(i.biasNode=Bi(s))):i=pd(e,t,r,s),i};class md extends qs{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class fd extends js{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Vs.OBJECT}element(e){return Bi(new md(this,Bi(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=null!==this.count?tl(null,e,this.count):Array.isArray(this.getValueFromReference())?il(null,e):"texture"===e?Zu(null):"cubeTexture"===e?gd(null):Zn(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;eBi(new fd(e,t,r)),xd=(e,t,r,s)=>Bi(new fd(e,t,s,r));class bd extends fd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Td=(e,t,r=null)=>Bi(new bd(e,t,r)),_d=ki((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),Hu("tangent","vec4"))))(),vd=_d.xyz.toVar("tangentLocal"),Nd=Fl.mul(nn(vd,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),Sd=Nd.transformDirection(cl).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),Ed=Nd.toVar("transformedTangentView"),wd=Ed.transformDirection(cl).normalize().toVar("transformedTangentWorld"),Ad=ki((([e,t],r)=>{let s=e.mul(_d.w).xyz;return!0!==r.material.flatShading&&(s=nu(s,t)),s})).once(),Rd=Ad(jl.cross(_d),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Cd=Ad(ql.cross(vd),"v_bitangentLocal").normalize().toVar("bitangentLocal"),Md=Ad(Kl.cross(Nd),"v_bitangentView").normalize().toVar("bitangentView"),Pd=Ad(Yl.cross(Sd),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Fd=Ad(Ql.cross(Ed),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Ld=Fd.transformDirection(cl).normalize().toVar("transformedBitangentWorld"),Bd=dn(Nd,Md,Kl),Id=zl.mul(Bd),Dd=(()=>{let e=Pn.cross(zl);return e=e.cross(Pn).normalize(),e=Io(e,Ql,Cn.mul(bn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),Vd=ki((e=>{const{eye_pos:t,surf_norm:r,mapN:s,uv:i}=e,n=t.dFdx(),a=t.dFdy(),o=i.dFdx(),u=i.dFdy(),l=r,d=a.cross(l),c=l.cross(n),h=d.mul(o.x).add(c.mul(u.x)),p=d.mul(o.y).add(c.mul(u.y)),g=h.dot(h).max(p.dot(p)),m=Wl.mul(g.inverseSqrt());return oa(h.mul(s.x,m),p.mul(s.y,m),l.mul(s.z)).normalize()}));class Ud extends Ks{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=C}setup(e){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);null!==r&&(s=en(s.xy.mul(r),s.z));let i=null;if(t===M)i=td(s);else if(t===C){i=!0===e.hasGeometryAttribute("tangent")?Bd.mul(s).normalize():Vd({eye_pos:Gl,surf_norm:Kl,mapN:s,uv:$u()})}return i}}const Od=Vi(Ud).setParameterLength(1,2),kd=ki((({textureNode:e,bumpScale:t})=>{const r=t=>e.cache().context({getUV:e=>t(e.uvNode||$u()),forceUVContext:!0}),s=ji(r((e=>e)));return Yi(ji(r((e=>e.add(e.dFdx())))).sub(s),ji(r((e=>e.add(e.dFdy())))).sub(s)).mul(t)})),Gd=ki((e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(Wl),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()}));class zd extends Ks{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=kd({textureNode:this.textureNode,bumpScale:e});return Gd({surf_pos:Gl,surf_norm:Kl,dHdxy:t})}}const Hd=Vi(zd).setParameterLength(1,2),$d=new Map;class Wd extends js{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=$d.get(e);return void 0===r&&(r=Td(e,t),$d.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Wd.COLOR){const e=void 0!==t.color?this.getColor(r):en();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Wd.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Wd.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ji(1);else if(r===Wd.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Wd.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Wd.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Wd.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Wd.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Wd.NORMAL)t.normalMap?(s=Od(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):s=t.bumpMap?Hd(this.getTexture("bump").r,this.getFloat("bumpScale")):Kl;else if(r===Wd.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Wd.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Od(this.getTexture(r),this.getCache(r+"Scale","vec2")):Kl;else if(r===Wd.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Wd.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(.07,1)}else if(r===Wd.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=ln(Cc.x,Cc.y,Cc.y.negate(),Cc.x).mul(e.rg.mul(2).sub(Yi(1)).normalize().mul(e.b))}else s=Cc;else if(r===Wd.IRIDESCENCE_THICKNESS){const e=yd("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=yd("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Wd.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Wd.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Wd.IOR)s=this.getFloat(r);else if(r===Wd.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Wd.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Wd.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):ji(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Wd.ALPHA_TEST="alphaTest",Wd.COLOR="color",Wd.OPACITY="opacity",Wd.SHININESS="shininess",Wd.SPECULAR="specular",Wd.SPECULAR_STRENGTH="specularStrength",Wd.SPECULAR_INTENSITY="specularIntensity",Wd.SPECULAR_COLOR="specularColor",Wd.REFLECTIVITY="reflectivity",Wd.ROUGHNESS="roughness",Wd.METALNESS="metalness",Wd.NORMAL="normal",Wd.CLEARCOAT="clearcoat",Wd.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Wd.CLEARCOAT_NORMAL="clearcoatNormal",Wd.EMISSIVE="emissive",Wd.ROTATION="rotation",Wd.SHEEN="sheen",Wd.SHEEN_ROUGHNESS="sheenRoughness",Wd.ANISOTROPY="anisotropy",Wd.IRIDESCENCE="iridescence",Wd.IRIDESCENCE_IOR="iridescenceIOR",Wd.IRIDESCENCE_THICKNESS="iridescenceThickness",Wd.IOR="ior",Wd.TRANSMISSION="transmission",Wd.THICKNESS="thickness",Wd.ATTENUATION_DISTANCE="attenuationDistance",Wd.ATTENUATION_COLOR="attenuationColor",Wd.LINE_SCALE="scale",Wd.LINE_DASH_SIZE="dashSize",Wd.LINE_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HT_MAP),Rc=Ui(Wd,Wd.AO),Cc=Zn(new t).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))})),Mc=ki((e=>e.context.setupModelViewProjection()),"vec4").once()().toVarying("v_modelViewProjection");class Pc extends js{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===Pc.VERTEX)s=e.getVertexIndex();else if(r===Pc.INSTANCE)s=e.getInstanceIndex();else if(r===Pc.DRAW)s=e.getDrawIndex();else if(r===Pc.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Pc.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==Pc.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=nu(this).build(e,t)}return i}}Pc.VERTEX="vertex",Pc.INSTANCE="instance",Pc.SUBGROUP="subgroup",Pc.INVOCATION_LOCAL="invocationLocal",Pc.INVOCATION_SUBGROUP="invocationSubgroup",Pc.DRAW="draw";const Fc=Ui(Pc,Pc.VERTEX),Lc=Ui(Pc,Pc.INSTANCE),Bc=Ui(Pc,Pc.SUBGROUP),Ic=Ui(Pc,Pc.INVOCATION_SUBGROUP),Dc=Ui(Pc,Pc.INVOCATION_LOCAL),Vc=Ui(Pc,Pc.DRAW);class Uc extends js{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Vs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:r,instanceColor:s}=this;let{instanceMatrixNode:i,instanceColorNode:n}=this;if(null===i){if(t<=1e3)i=tl(r.array,"mat4",Math.max(t,1)).element(Lc);else{const e=new P(r.array,16,1);this.buffer=e;const t=r.usage===y?Su:Nu,s=[t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12)];i=cn(...s)}this.instanceMatrixNode=i}if(s&&null===n){const e=new F(s.array,3),t=s.usage===y?Su:Nu;this.bufferColor=e,n=en(t(e,"vec3",3,0)),this.instanceColorNode=n}const a=i.mul(Vl).xyz;if(Vl.assign(a),e.hasGeometryAttribute("normal")){const e=ed(ql,i);ql.assign(e)}null!==this.instanceColorNode&&fn("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==y&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==y&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const Oc=Vi(Uc).setParameterLength(2,3);class kc extends Uc{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Gc=Vi(kc).setParameterLength(1);class zc extends js{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=Lc:this.batchingIdNode=Vc);const t=ki((([e])=>{const t=qi(ju(Ju(this.batchMesh._indirectTexture),0).x),r=qi(e).mod(t),s=qi(e).div(t);return Ju(this.batchMesh._indirectTexture,Qi(r,s)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(qi(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=qi(ju(Ju(s),0).x),n=ji(r).mul(4).toInt().toVar(),a=n.mod(i),o=n.div(i),u=cn(Ju(s,Qi(a,o)),Ju(s,Qi(a.add(1),o)),Ju(s,Qi(a.add(2),o)),Ju(s,Qi(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ki((([e])=>{const t=qi(ju(Ju(l),0).x),r=e,s=r.mod(t),i=r.div(t);return Ju(l,Qi(s,i)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);fn("vec3","vBatchColor").assign(t)}const d=dn(u);Vl.assign(u.mul(Vl));const c=ql.div(en(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;ql.assign(h),e.hasGeometryAttribute("tangent")&&vd.mulAssign(d)}}const Hc=Vi(zc).setParameterLength(1);class $c extends qs{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Wc=Vi($c).setParameterLength(2);class jc extends el{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStruct?(s="struct",i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=Es(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=Os.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Wc(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Os.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=_u(this.value),this._varying=nu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const qc=(e,t=null,r=0)=>Bi(new jc(e,t,r)),Xc=new WeakMap;class Kc extends js{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Vs.OBJECT,this.skinIndexNode=Hu("skinIndex","uvec4"),this.skinWeightNode=Hu("skinWeight","vec4"),this.bindMatrixNode=yd("bindMatrix","mat4"),this.bindMatrixInverseNode=yd("bindMatrixInverse","mat4"),this.boneMatricesNode=xd("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Vl,this.toPositionNode=Vl,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=oa(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=ql){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w);let d=oa(s.x.mul(a),s.y.mul(o),s.z.mul(u),s.w.mul(l));return d=n.mul(d).mul(i),d.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=xd("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Ul)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||!0===Fs(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&Ul.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();ql.assign(t),e.hasGeometryAttribute("tangent")&&vd.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Xc.get(t)!==e.frameId&&(Xc.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const Yc=e=>Bi(new Kc(e));class Qc extends js{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(u)?">=":"<")),a)n=`while ( ${u} )`;else{const r={start:o,end:u},s=r.start,i=r.end;let a;const p=()=>c.includes("<")?"+=":"-=";if(null!=h)switch(typeof h){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=l+" "+p()+" "+e.generateConst(d,h);break;case"string":a=l+" "+h;break;default:h.isNode?a=l+" "+p()+" "+h.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),a="break /* invalid update */")}else h="int"===d||"uint"===d?c.includes("<")?"++":"--":p()+" 1.",a=l+" "+h;n=`for ( ${e.getVar(d,l)+" = "+s}; ${l+" "+c+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tBi(new Qc(Di(e,"int"))).toStack(),Jc=()=>Du("break").toStack(),eh=new WeakMap,th=new s,rh=ki((({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=qi(Fc).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return Ju(e,Qi(u,o)).depth(i).xyz.mul(t)}));class sh extends js{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Zn(1),this.updateType=Vs.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=eh.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new L(m,h,p,a);f.type=B,f.needsUpdate=!0;const y=4*c;for(let b=0;b{const t=ji(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Ju(this.mesh.morphTexture,Qi(qi(e).add(1),qi(Lc))).r):t.assign(yd("morphTargetInfluences","float").element(e).toVar()),Hi(t.notEqual(0),(()=>{!0===s&&Vl.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(0)})),!0===i&&ql.addAssign(rh({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:qi(1)}))}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}const ih=Vi(sh).setParameterLength(1);class nh extends js{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class ah extends nh{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends Yo{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:en().toVar("directDiffuse"),directSpecular:en().toVar("directSpecular"),indirectDiffuse:en().toVar("indirectDiffuse"),indirectSpecular:en().toVar("indirectSpecular")};return{radiance:en().toVar("radiance"),irradiance:en().toVar("irradiance"),iblIrradiance:en().toVar("iblIrradiance"),ambientOcclusion:ji(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const uh=Vi(oh);class lh extends nh{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let dh,ch;class hh extends js{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===hh.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Vs.NONE;return this.scope!==hh.SIZE&&this.scope!==hh.VIEWPORT||(e=Vs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===hh.VIEWPORT?null!==t?ch.copy(t.viewport):(e.getViewport(ch),ch.multiplyScalar(e.getPixelRatio())):null!==t?(dh.width=t.width,dh.height=t.height):e.getDrawingBufferSize(dh)}setup(){const e=this.scope;let r=null;return r=e===hh.SIZE?Zn(dh||(dh=new t)):e===hh.VIEWPORT?Zn(ch||(ch=new s)):Yi(mh.div(gh)),r}generate(e){if(this.scope===hh.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(gh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}hh.COORDINATE="coordinate",hh.VIEWPORT="viewport",hh.SIZE="size",hh.UV="uv";const ph=Ui(hh,hh.UV),gh=Ui(hh,hh.SIZE),mh=Ui(hh,hh.COORDINATE),fh=Ui(hh,hh.VIEWPORT),yh=fh.zw,xh=mh.sub(fh.xy),bh=xh.div(yh),Th=ki((()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),gh)),"vec2").once()(),_h=ki((()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),ph)),"vec2").once()(),vh=ki((()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),ph.flipY())),"vec2").once()(),Nh=new t;class Sh extends Yu{static get type(){return"ViewportTextureNode"}constructor(e=ph,t=null,r=null){null===r&&((r=new I).minFilter=D),super(r,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Vs.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Nh);const r=this.value;r.image.width===Nh.width&&r.image.height===Nh.height||(r.image.width=Nh.width,r.image.height=Nh.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Eh=Vi(Sh).setParameterLength(0,3),wh=Vi(Sh,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Ah=null;class Rh extends Sh{static get type(){return"ViewportDepthTextureNode"}constructor(e=ph,t=null){null===Ah&&(Ah=new V),super(e,t,Ah)}}const Ch=Vi(Rh).setParameterLength(0,2);class Mh extends js{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Mh.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Mh.DEPTH_BASE)null!==r&&(s=Ih().assign(r));else if(t===Mh.DEPTH)s=e.isPerspectiveCamera?Fh(Gl.z,ol,ul):Ph(Gl.z,ol,ul);else if(t===Mh.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=Lh(r,ol,ul);s=Ph(e,ol,ul)}else s=r;else s=Ph(Gl.z,ol,ul);return s}}Mh.DEPTH_BASE="depthBase",Mh.DEPTH="depth",Mh.LINEAR_DEPTH="linearDepth";const Ph=(e,t,r)=>e.add(t).div(t.sub(r)),Fh=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),Lh=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),Bh=(e,t,r)=>{t=t.max(1e-6).toVar();const s=ja(e.negate().div(t)),i=ja(r.div(t));return s.div(i)},Ih=Vi(Mh,Mh.DEPTH_BASE),Dh=Ui(Mh,Mh.DEPTH),Vh=Vi(Mh,Mh.LINEAR_DEPTH).setParameterLength(0,1),Uh=Vh(Ch());Dh.assign=e=>Ih(e);class Oh extends js{static get type(){return"ClippingNode"}constructor(e=Oh.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Oh.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===Oh.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return ki((()=>{const r=ji().toVar("distanceToPlane"),s=ji().toVar("distanceToGradient"),i=ji(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=il(t);Zc(n,(({i:t})=>{const n=e.element(t);r.assign(Gl.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Oo(s.negate(),s,r))}))}const a=e.length;if(a>0){const t=il(e),n=ji(1).toVar("intersectionClipOpacity");Zc(a,(({i:e})=>{const i=t.element(e);r.assign(Gl.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Oo(s.negate(),s,r).oneMinus())})),i.mulAssign(n.oneMinus())}yn.a.mulAssign(i),yn.a.equal(0).discard()}))()}setupDefault(e,t){return ki((()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=il(t);Zc(r,(({i:t})=>{const r=e.element(t);Gl.dot(r.xyz).greaterThan(r.w).discard()}))}const s=e.length;if(s>0){const t=il(e),r=Ki(!0).toVar("clipped");Zc(s,(({i:e})=>{const s=t.element(e);r.assign(Gl.dot(s.xyz).greaterThan(s.w).and(r))})),r.discard()}}))()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),ki((()=>{const s=il(e),i=nl(t.getClipDistance());Zc(r,(({i:e})=>{const t=s.element(e),r=Gl.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)}))}))()}}Oh.ALPHA_TO_COVERAGE="alphaToCoverage",Oh.DEFAULT="default",Oh.HARDWARE="hardware";const kh=ki((([e])=>Za(la(1e4,Ja(la(17,e.x).add(la(.1,e.y)))).mul(oa(.1,no(Ja(la(13,e.y).add(e.x)))))))),Gh=ki((([e])=>kh(Yi(kh(e.xy),e.z)))),zh=ki((([e])=>{const t=_o(oo(co(e.xyz)),oo(ho(e.xyz))),r=ji(1).div(ji(.05).mul(t)).toVar("pixScale"),s=Yi($a(Ka(ja(r))),$a(Ya(ja(r)))),i=Yi(Gh(Ka(s.x.mul(e.xyz))),Gh(Ka(s.y.mul(e.xyz)))),n=Za(ja(r)),a=oa(la(n.oneMinus(),i.x),la(n,i.y)),o=To(n,n.oneMinus()),u=en(a.mul(a).div(la(2,o).mul(ua(1,o))),a.sub(la(.5,o)).div(ua(1,o)),ua(1,ua(1,a).mul(ua(1,a)).div(la(2,o).mul(ua(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return Do(l,1e-6,1)})).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Hh extends zu{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $h=(e=0)=>Bi(new Hh(e));class Wh extends U{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+_s(this)}build(e){this.setup(e)}setupObserver(e){return new fs(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=this.vertexNode||s;let n;e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.add(a);const i=nn(s,yn.a).max(0);n=this.setupOutput(e,i),In.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&In.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=nn(t)),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.samples;this.alphaToCoverage&&t>1?s=Bi(new Oh(Oh.ALPHA_TO_COVERAGE)):e.stack.add(Bi(new Oh))}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Bi(new Oh(Oh.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?Bh(Gl.z,ol,ul):Ph(Gl.z,ol,ul))}null!==s&&Dh.assign(s).toStack()}setupPositionView(){return Fl.mul(Vl).xyz}setupModelViewProjection(){return ll.mul(Gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Mc}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ih(t).toStack(),!0===t.isSkinnedMesh&&Yc(t).toStack(),this.displacementMap){const e=Td("displacementMap","texture"),t=Td("displacementScale","float"),r=Td("displacementBias","float");Vl.addAssign(ql.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Hc(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Gc(t).toStack(),null!==this.positionNode&&Vl.assign(Cu(this.positionNode,"POSITION")),Vl}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&Ki(this.maskNode).not().discard();let r=this.colorNode?nn(this.colorNode):qd;if(!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul($h())),e.instanceColor){r=fn("vec3","vInstanceColor").mul(r)}if(e.isBatchedMesh&&e._colorsTexture){r=fn("vec3","vBatchColor").mul(r)}yn.assign(r);const s=this.opacityNode?ji(this.opacityNode):Yd;yn.a.assign(yn.a.mul(s));let i=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(i=null!==this.alphaTestNode?ji(this.alphaTestNode):jd,yn.a.lessThanEqual(i).discard()),!0===this.alphaHash&&yn.a.lessThan(zh(Vl)).discard();!1===this.transparent&&this.blending===O&&!1===this.alphaToCoverage?yn.a.assign(1):null===i&&yn.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?en(0):yn.rgb}setupNormal(){return this.normalNode?en(this.normalNode):ic}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Td("envMap","cubeTexture"):Td("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lh(Ac)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:Rc;t.push(new ah(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=uh(n,t,r,s)}else null!==r&&(a=en(null!==s?Io(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(xn.assign(en(i||Kd)),a=a.add(xn)),a}setupFog(e,t){const r=e.fogNode;return r&&(In.assign(t),t=nn(r)),t}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=U.prototype.toJSON.call(this,e),s=vs(this);r.inputNodes={};for(const{property:t,childNode:i}of s)r.inputNodes[t]=i.toJSON(e).uuid;function i(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=i(e.textures),s=i(e.images),n=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jh=new k;class qh extends Wh{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jh),this.setValues(e)}}const Xh=new G;class Kh extends Wh{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Xh),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ji(this.offsetNode):Sc,t=this.dashScaleNode?ji(this.dashScaleNode):Tc,r=this.dashSizeNode?ji(this.dashSizeNode):_c,s=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(r),Vn.assign(s);const i=nu(Hu("lineDistance").mul(t));(e?i.add(e):i).mod(Dn.add(Vn)).greaterThan(Dn).discard()}}let Yh=null;class Qh extends Sh{static get type(){return"ViewportSharedTextureNode"}constructor(e=ph,t=null){null===Yh&&(Yh=new I),super(e,t,Yh)}updateReference(){return this}}const Zh=Vi(Qh).setParameterLength(0,2),Jh=new G;class ep extends Wh{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Jh),this.useColor=e.vertexColors,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=z,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,i=this._useDash,n=this._useWorldUnits,a=ki((({start:e,end:t})=>{const r=ll.element(2).element(2),s=ll.element(3).element(2).mul(-.5).div(r).sub(e.z).div(t.z.sub(e.z));return nn(Io(e.xyz,t.xyz,s),t.w)})).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=ki((()=>{const e=Hu("instanceStart"),t=Hu("instanceEnd"),r=nn(Fl.mul(nn(e,1))).toVar("start"),s=nn(Fl.mul(nn(t,1))).toVar("end");if(i){const e=this.dashScaleNode?ji(this.dashScaleNode):Tc,t=this.offsetNode?ji(this.offsetNode):Sc,r=Hu("instanceDistanceStart"),s=Hu("instanceDistanceEnd");let i=Dl.y.lessThan(.5).select(e.mul(r),e.mul(s));i=i.add(t),fn("float","lineDistance").assign(i)}n&&(fn("vec3","worldStart").assign(r.xyz),fn("vec3","worldEnd").assign(s.xyz));const o=fh.z.div(fh.w),u=ll.element(2).element(3).equal(-1);Hi(u,(()=>{Hi(r.z.lessThan(0).and(s.z.greaterThan(0)),(()=>{s.assign(a({start:r,end:s}))})).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),(()=>{r.assign(a({start:s,end:r}))}))}));const l=ll.mul(r),d=ll.mul(s),c=l.xyz.div(l.w),h=d.xyz.div(d.w),p=h.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(o)),p.assign(p.normalize());const g=nn().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=Io(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=fn("vec4","worldPos");o.assign(Dl.y.lessThan(.5).select(r,s));const u=Nc.mul(.5);o.addAssign(nn(Dl.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(nn(Dl.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(nn(a.mul(u),0)),Hi(Dl.y.greaterThan(1).or(Dl.y.lessThan(0)),(()=>{o.subAssign(nn(a.mul(2).mul(u),0))}))),g.assign(ll.mul(o));const l=en().toVar();l.assign(Dl.y.lessThan(.5).select(c,h)),g.z.assign(l.z.mul(g.w))}else{const e=Yi(p.y,p.x.negate()).toVar("offset");p.x.assign(p.x.div(o)),e.x.assign(e.x.div(o)),e.assign(Dl.x.lessThan(0).select(e.negate(),e)),Hi(Dl.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(Dl.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(Nc)),e.assign(e.div(fh.w)),g.assign(Dl.y.lessThan(.5).select(l,d)),e.assign(e.mul(g.w)),g.assign(g.add(nn(e,0,0)))}return g}))();const o=ki((({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Yi(h,p)}));if(this.colorNode=ki((()=>{const e=$u();if(i){const t=this.dashSizeNode?ji(this.dashSizeNode):_c,r=this.gapSizeNode?ji(this.gapSizeNode):vc;Dn.assign(t),Vn.assign(r);const s=fn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(Dn.add(Vn)).greaterThan(Dn).discard()}const a=ji(1).toVar("alpha");if(n){const e=fn("vec3","worldStart"),s=fn("vec3","worldEnd"),n=fn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:en(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(Nc);if(!i)if(r&&t.samples>1){const e=h.fwidth();a.assign(Oo(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.samples>1){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=ji(s.fwidth()).toVar("dlen");Hi(e.y.abs().greaterThan(1),(()=>{a.assign(Oo(i.oneMinus(),i.add(1),s).oneMinus())}))}else Hi(e.y.abs().greaterThan(1),(()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()}));let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=Hu("instanceColorStart"),t=Hu("instanceColorEnd");u=Dl.y.lessThan(.5).select(e,t).mul(qd)}else u=qd;return nn(u,a)}))(),this.transparent){const e=this.opacityNode?ji(this.opacityNode):Yd;this.outputNode=nn(this.colorNode.rgb.mul(e).add(Zh().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const tp=e=>Bi(e).mul(.5).add(.5),rp=new H;class sp extends Wh{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(rp),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ji(this.opacityNode):Yd;yn.assign(hu(nn(tp(Ql),e),$))}}class ip extends Ks{static get type(){return"EquirectUVNode"}constructor(e=kl){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Yi(t,r)}}const np=Vi(ip).setParameterLength(0,1);class ap extends W{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=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;const i=new j(5,5,5),n=np(kl),a=new Wh;a.colorNode=Zu(t,n,0),a.side=S,a.blending=z;const o=new q(i,a),u=new X;u.add(o),t.minFilter===D&&(t.minFilter=K);const l=new Y(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.currentGenerateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}}const op=new WeakMap;class up extends Ks{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=gd(null);const t=new w;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Vs.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===Q||r===Z){if(op.has(e)){const t=op.get(e);dp(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new ap(r.height);s.fromEquirectangularTexture(t,e),dp(s.texture,e.mapping),this._cubeTexture=s.texture,op.set(e,s.texture),e.addEventListener("dispose",lp)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lp(e){const t=e.target;t.removeEventListener("dispose",lp);const r=op.get(t);void 0!==r&&(op.delete(t),r.dispose())}function dp(e,t){t===Q?e.mapping=A:t===Z&&(e.mapping=R)}const cp=Vi(up).setParameterLength(1);class hp extends nh{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=cp(this.envNode)}}class pp extends nh{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ji(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gp{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class mp extends gp{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(nn(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(nn(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case te:s.rgb.assign(Io(s.rgb,s.rgb.mul(i.rgb),ec.mul(tc)));break;case ee:s.rgb.assign(Io(s.rgb,i.rgb,ec.mul(tc)));break;case J:s.rgb.addAssign(i.rgb.mul(ec.mul(tc)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}const fp=new re;class yp extends Wh{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(fp),this.setValues(e)}setupNormal(){return Kl}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pp(Ac)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new mp}}const xp=ki((({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))})),bp=ki((e=>e.diffuseColor.mul(1/Math.PI))),Tp=ki((({dotNH:e})=>Bn.mul(ji(.5)).add(1).mul(ji(1/Math.PI)).mul(e.pow(Bn)))),_p=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(t).clamp(),s=zl.dot(t).clamp(),i=xp({f0:Fn,f90:1,dotVH:s}),n=ji(.25),a=Tp({dotNH:r});return i.mul(n).mul(a)}));class vp extends mp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(_p({lightDirection:e})).mul(ec))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const Np=new se;class Sp extends Wh{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Np),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp(!1)}}const Ep=new ie;class wp extends Wh{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Ep),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new hp(t):null}setupLightingModel(){return new vp}setupVariants(){const e=(this.shininessNode?ji(this.shininessNode):Xd).max(1e-4);Bn.assign(e);const t=this.specularNode||Qd;Fn.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Ap=ki((e=>{if(!1===e.geometry.hasAttribute("normal"))return ji(0);const t=Kl.dFdx().abs().max(Kl.dFdy().abs());return t.x.max(t.y).max(t.z)})),Rp=ki((e=>{const{roughness:t}=e,r=Ap();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s})),Cp=ki((({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return da(.5,i.add(n).max(Ia))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Mp=ki((({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(en(e.mul(r),t.mul(s),a).length()),l=a.mul(en(e.mul(i),t.mul(n),o).length());return da(.5,u.add(l)).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"}]}),Pp=ki((({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Fp=ji(1/Math.PI),Lp=ki((({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=en(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return Fp.mul(n.mul(u.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"}]}),Bp=ki((e=>{const{lightDirection:t,f0:r,f90:s,roughness:i,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=e,u=e.normalView||Ql,l=i.pow2(),d=t.add(zl).normalize(),c=u.dot(t).clamp(),h=u.dot(zl).clamp(),p=u.dot(d).clamp(),g=zl.dot(d).clamp();let m,f,y=xp({f0:r,f90:s,dotVH:g});if(Pi(a)&&(y=En.mix(y,n)),Pi(o)){const e=Mn.dot(t),r=Mn.dot(zl),s=Mn.dot(d),i=Pn.dot(t),n=Pn.dot(zl),a=Pn.dot(d);m=Mp({alphaT:Rn,alphaB:l,dotTV:r,dotBV:n,dotTL:e,dotBL:i,dotNV:h,dotNL:c}),f=Lp({alphaT:Rn,alphaB:l,dotNH:p,dotTH:s,dotBH:a})}else m=Cp({alpha:l,dotNL:c,dotNV:h}),f=Pp({alpha:l,dotNH:p});return y.mul(m).mul(f)})),Ip=ki((({roughness:e,dotNV:t})=>{const r=nn(-1,-.0275,-.572,.022),s=nn(1,.0425,1.04,-.04),i=e.mul(r).add(s),n=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y);return Yi(-1.04,1.04).mul(n).add(i.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),Dp=ki((e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=Ip({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))})),Vp=ki((({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(en(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"}]}),Up=ki((({roughness:e,dotNH:t})=>{const r=e.pow2(),s=ji(1).div(r),i=t.pow2().oneMinus().max(.0078125);return ji(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),Op=ki((({dotNV:e,dotNL:t})=>ji(1).div(ji(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),kp=ki((({lightDirection:e})=>{const t=e.add(zl).normalize(),r=Ql.dot(e).clamp(),s=Ql.dot(zl).clamp(),i=Ql.dot(t).clamp(),n=Up({roughness:Sn,dotNH:i}),a=Op({dotNV:s,dotNL:r});return Nn.mul(n).mul(a)})),Gp=ki((({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Yi(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),zp=ki((({f:e})=>{const t=e.length();return _o(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Hp=ki((({v1:e,v2:t})=>{const r=e.dot(t),s=r.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=r.greaterThan(0).select(a,_o(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),$p=ki((({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=en().toVar();return Hi(d.dot(r.sub(i)).greaterThanEqual(0),(()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(dn(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=en(0).toVar();f.addAssign(Hp({v1:h,v2:p})),f.addAssign(Hp({v1:p,v2:g})),f.addAssign(Hp({v1:g,v2:m})),f.addAssign(Hp({v1:m,v2:h})),c.assign(en(zp({f:f})))})),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"}]}),Wp=ki((({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=en().toVar();return Hi(o.dot(e.sub(t)).greaterThanEqual(0),(()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=en(0).toVar();d.addAssign(Hp({v1:n,v2:a})),d.addAssign(Hp({v1:a,v2:o})),d.addAssign(Hp({v1:o,v2:l})),d.addAssign(Hp({v1:l,v2:n})),u.assign(en(zp({f:d.abs()})))})),u})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),jp=1/6,qp=e=>la(jp,la(e,la(e,e.negate().add(3)).sub(3)).add(1)),Xp=e=>la(jp,la(e,la(e,la(3,e).sub(6))).add(4)),Kp=e=>la(jp,la(e,la(e,la(-3,e).add(3)).add(3)).add(1)),Yp=e=>la(jp,Ro(e,3)),Qp=e=>qp(e).add(Xp(e)),Zp=e=>Kp(e).add(Yp(e)),Jp=e=>oa(-1,Xp(e).div(qp(e).add(Xp(e)))),eg=e=>oa(1,Yp(e).div(Kp(e).add(Yp(e)))),tg=(e,t,r)=>{const s=e.uvNode,i=la(s,t.zw).add(.5),n=Ka(i),a=Za(i),o=Qp(a.x),u=Zp(a.x),l=Jp(a.x),d=eg(a.x),c=Jp(a.y),h=eg(a.y),p=Yi(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Yi(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Yi(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Yi(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Qp(a.y).mul(oa(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),x=Zp(a.y).mul(oa(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(x)},rg=ki((([e,t=ji(3)])=>{const r=Yi(e.size(qi(t))),s=Yi(e.size(qi(t.add(1)))),i=da(1,r),n=da(1,s),a=tg(e,nn(i,r),Ka(t)),o=tg(e,nn(n,s),Ya(t));return Za(t).mix(a,o)})),sg=ki((([e,t,r,s,i])=>{const n=en(Uo(t.negate(),Qa(e),da(1,s))),a=en(oo(i[0].xyz),oo(i[1].xyz),oo(i[2].xyz));return Qa(n).mul(r.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"}]}),ig=ki((([e,t])=>e.mul(Do(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),ng=wh(),ag=wh(),og=ki((([e,t,r],{material:s})=>{const i=(s.side===S?ng:ag).sample(e),n=ja(gh.x).mul(ig(t,r));return rg(i,n)})),ug=ki((([e,t,r])=>(Hi(r.notEqual(0),(()=>{const s=Wa(t).negate().div(r);return Ha(s.negate().mul(e))})),en(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lg=ki((([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=nn().toVar(),f=en().toVar();const i=d.sub(1).mul(g.mul(.025)),n=en(d.sub(i),d,d.add(i));Zc({start:0,end:3},(({i:i})=>{const d=n.element(i),g=sg(e,t,c,d,o),y=a.add(g),x=l.mul(u.mul(nn(y,1))),b=Yi(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(Yi(b.x,b.y.oneMinus()));const T=og(b,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(ug(oo(g),h,p).element(i)))})),m.a.divAssign(3)}else{const i=sg(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(nn(n,1))),y=Yi(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Yi(y.x,y.y.oneMinus())),m=og(y,r,d),f=s.mul(ug(oo(i),h,p))}const y=f.rgb.mul(m.rgb),x=e.dot(t).clamp(),b=en(Dp({dotNV:x,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return nn(b.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())})),dg=dn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),cg=(e,t)=>e.sub(t).div(e.add(t)).pow2(),hg=ki((({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=Io(e,t,Oo(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();Hi(a.lessThan(0),(()=>en(1)));const o=a.sqrt(),u=cg(n,e),l=xp({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=ji(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return en(1).add(t).div(en(1).sub(t))})(i.clamp(0,.9999)),g=cg(p,n.toVec3()),m=xp({f0:g,f90:1,dotVH:o}),f=en(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),x=en(h).add(f),b=l.mul(m).clamp(1e-5,.9999),T=b.sqrt(),_=d.pow2().mul(m).div(en(1).sub(b)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Zc({start:1,end:2,condition:"<=",name:"m"},(({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=en(54856e-17,44201e-17,52481e-17),i=en(1681e3,1795300,2208400),n=en(43278e5,93046e5,66121e5),a=ji(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=en(o.x.add(a),o.y,o.z).div(1.0685e-7),dg.mul(o)})(ji(e).mul(y),ji(e).mul(x)).mul(2);v.addAssign(N.mul(t))})),v.max(en(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"}]}),pg=ki((({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.pow2(),n=Xo(r.lessThan(.25),ji(-339.2).mul(i).add(ji(161.4).mul(r)).sub(25.9),ji(-8.48).mul(i).add(ji(14.3).mul(r)).sub(9.95)),a=Xo(r.lessThan(.25),ji(44).mul(i).sub(ji(23.7).mul(r)).add(3.26),ji(1.97).mul(i).sub(ji(3.27).mul(r)).add(.72));return Xo(r.lessThan(.25),0,ji(.1).mul(r).sub(.025)).add(n.mul(s).add(a).exp()).mul(1/Math.PI).saturate()})),gg=en(.04),mg=ji(1);class fg extends gp{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=en().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=en().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=en().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=en().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=en().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ql.dot(zl).clamp();this.iridescenceFresnel=hg({outsideIOR:ji(1),eta2:wn,cosTheta1:e,thinFilmThickness:An,baseF0:Fn}),this.iridescenceF0=Vp({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Ol,r=gl.sub(Ol).normalize(),s=Zl,i=e.context;i.backdrop=lg(s,r,bn,yn,Fn,Ln,t,El,cl,ll,On,Gn,Hn,zn,this.dispersion?$n:null),i.backdropAlpha=kn,yn.a.mulAssign(Io(1,i.backdrop.a,kn))}super.start(e)}computeMultiscattering(e,t,r){const s=Ql.dot(zl).clamp(),i=Ip({roughness:bn,dotNV:s}),n=(this.iridescenceF0?En.mix(Fn,this.iridescenceF0):Fn).mul(i.x).add(r.mul(i.y)),a=i.x.add(i.y).oneMinus(),o=Fn.add(Fn.oneMinus().mul(.047619)),u=n.mul(o).div(a.mul(o).oneMinus());e.addAssign(n),t.addAssign(u.mul(a))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ql.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(s.mul(kp({lightDirection:e}))),!0===this.clearcoat){const r=Jl.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(Bp({lightDirection:e,f0:gg,f90:mg,roughness:vn,normalView:Jl})))}r.directDiffuse.addAssign(s.mul(bp({diffuseColor:yn.rgb}))),r.directSpecular.addAssign(s.mul(Bp({lightDirection:e,f0:Fn,f90:1,roughness:bn,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ql,h=zl,p=Gl.toVar(),g=Gp({N:c,V:h,roughness:bn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=dn(en(m.x,0,m.y),en(0,1,0),en(m.z,0,m.w)).toVar(),x=Fn.mul(f.x).add(Fn.oneMinus().mul(f.y)).toVar();i.directSpecular.addAssign(e.mul(x).mul($p({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(yn).mul($p({N:c,V:h,P:p,mInv:dn(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(bp({diffuseColor:yn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Nn,pg({normal:Ql,viewDir:zl,roughness:Sn}))),!0===this.clearcoat){const e=Jl.dot(zl).clamp(),t=Dp({dotNV:e,specularColor:gg,specularF90:mg,roughness:vn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=en().toVar("singleScattering"),n=en().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(i,n,Ln);const o=i.add(n),u=yn.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(t.mul(i)),s.indirectSpecular.addAssign(n.mul(a)),s.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ql.dot(zl).clamp().add(t),i=bn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Jl.dot(zl).clamp(),r=xp({dotVH:e,f0:gg,f90:mg}),s=t.mul(_n.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(_n));t.assign(s)}if(!0===this.sheen){const e=Nn.r.max(Nn.g).max(Nn.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const yg=ji(1),xg=ji(-2),bg=ji(.8),Tg=ji(-1),_g=ji(.4),vg=ji(2),Ng=ji(.305),Sg=ji(3),Eg=ji(.21),wg=ji(4),Ag=ji(4),Rg=ji(16),Cg=ki((([e])=>{const t=en(no(e)).toVar(),r=ji(-1).toVar();return Hi(t.x.greaterThan(t.z),(()=>{Hi(t.x.greaterThan(t.y),(()=>{r.assign(Xo(e.x.greaterThan(0),0,3))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})).Else((()=>{Hi(t.z.greaterThan(t.y),(()=>{r.assign(Xo(e.z.greaterThan(0),2,5))})).Else((()=>{r.assign(Xo(e.y.greaterThan(0),1,4))}))})),r})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Mg=ki((([e,t])=>{const r=Yi().toVar();return Hi(t.equal(0),(()=>{r.assign(Yi(e.z,e.y).div(no(e.x)))})).ElseIf(t.equal(1),(()=>{r.assign(Yi(e.x.negate(),e.z.negate()).div(no(e.y)))})).ElseIf(t.equal(2),(()=>{r.assign(Yi(e.x.negate(),e.y).div(no(e.z)))})).ElseIf(t.equal(3),(()=>{r.assign(Yi(e.z.negate(),e.y).div(no(e.x)))})).ElseIf(t.equal(4),(()=>{r.assign(Yi(e.x.negate(),e.z).div(no(e.y)))})).Else((()=>{r.assign(Yi(e.x,e.y).div(no(e.z)))})),la(.5,r.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Pg=ki((([e])=>{const t=ji(0).toVar();return Hi(e.greaterThanEqual(bg),(()=>{t.assign(yg.sub(e).mul(Tg.sub(xg)).div(yg.sub(bg)).add(xg))})).ElseIf(e.greaterThanEqual(_g),(()=>{t.assign(bg.sub(e).mul(vg.sub(Tg)).div(bg.sub(_g)).add(Tg))})).ElseIf(e.greaterThanEqual(Ng),(()=>{t.assign(_g.sub(e).mul(Sg.sub(vg)).div(_g.sub(Ng)).add(vg))})).ElseIf(e.greaterThanEqual(Eg),(()=>{t.assign(Ng.sub(e).mul(wg.sub(Sg)).div(Ng.sub(Eg)).add(Sg))})).Else((()=>{t.assign(ji(-2).mul(ja(la(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),Fg=ki((([e,t])=>{const r=e.toVar();r.assign(la(2,r).sub(1));const s=en(r,1).toVar();return Hi(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"}]}),Lg=ki((([e,t,r,s,i,n])=>{const a=ji(r),o=en(t),u=Do(Pg(a),xg,n),l=Za(u),d=Ka(u),c=en(Bg(e,o,d,s,i,n)).toVar();return Hi(l.notEqual(0),(()=>{const t=en(Bg(e,o,d.add(1),s,i,n)).toVar();c.assign(Io(c,t,l))})),c})),Bg=ki((([e,t,r,s,i,n])=>{const a=ji(r).toVar(),o=en(t),u=ji(Cg(o)).toVar(),l=ji(_o(Ag.sub(a),0)).toVar();a.assign(_o(a,Ag));const d=ji($a(a)).toVar(),c=Yi(Mg(o,u).mul(d.sub(2)).add(1)).toVar();return Hi(u.greaterThan(2),(()=>{c.y.addAssign(d),u.subAssign(3)})),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(la(3,Rg))),c.y.addAssign(la(4,$a(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Yi(),Yi())})),Ig=ki((({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=eo(s),l=r.mul(u).add(i.cross(r).mul(Ja(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return Bg(e,l,t,n,a,o)})),Dg=ki((({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=en(Xo(t,r,Ao(r,s))).toVar();Hi(h.equal(en(0)),(()=>{h.assign(en(s.z,0,s.x.negate()))})),h.assign(Qa(h));const p=en().toVar();return p.addAssign(i.element(0).mul(Ig({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Zc({start:qi(1),end:e},(({i:e})=>{Hi(e.greaterThanEqual(n),(()=>{Jc()}));const t=ji(a.mul(ji(e))).toVar();p.addAssign(i.element(e).mul(Ig({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(Ig({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))})),nn(p,1)})),Vg=[.125,.215,.35,.446,.526,.582],Ug=20,Og=new ne(-1,1,1,-1,0,1),kg=new ae(90,1),Gg=new e;let zg=null,Hg=0,$g=0;const Wg=(1+Math.sqrt(5))/2,jg=1/Wg,qg=[new r(-Wg,jg,0),new r(Wg,jg,0),new r(-jg,0,Wg),new r(jg,0,Wg),new r(0,Wg,-jg),new r(0,Wg,jg),new r(-1,1,-1),new r(1,1,-1),new r(-1,1,1),new r(1,1,1)],Xg=new r,Kg=new WeakMap,Yg=[3,1,5,0,4,2],Qg=Fg($u(),Hu("faceIndex")).normalize(),Zg=en(Qg.x,Qg.y,Qg.z);class Jg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Xg,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const n=o||this._allocateTarget();return i.renderTarget=n,this.fromSceneAsync(e,t,r,s,i),n}zg=this._renderer.getRenderTarget(),Hg=this._renderer.getActiveCubeFace(),$g=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sm(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=im(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===A||e.mapping===R?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?u=Vg[o-e+4-1]:0===o&&(u=0),s.push(u);const l=1/(a-2),d=-l,c=1+l,h=[d,d,c,d,c,c,d,d,c,c,d,c],p=6,g=6,m=3,f=2,y=1,x=new Float32Array(m*g*p),b=new Float32Array(f*g*p),T=new Float32Array(y*g*p);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Yg[e];x.set(s,m*g*i),b.set(h,f*g*i);const n=[i,i,i,i,i,i];T.set(n,y*g*i)}const _=new he;_.setAttribute("position",new pe(x,m)),_.setAttribute("uv",new pe(b,f)),_.setAttribute("faceIndex",new pe(T,y)),t.push(_),i.push(new q(_,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:s,lodMeshes:i}}(t)),this._blurMaterial=function(e,t,s){const i=il(new Array(Ug).fill(0)),n=Zn(new r(0,1,0)),a=Zn(0),o=ji(Ug),u=Zn(0),l=Zn(1),d=Zu(null),c=Zn(0),h=ji(1/t),p=ji(1/s),g=ji(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:Zg,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=rm("blur");return f.fragmentNode=Dg({...m,latitudinal:u.equal(1)}),Kg.set(f,m),f}(t,e.width,e.height)}}async _compileMaterial(e){const t=new q(this._lodPlanes[0],e);await this._renderer.compile(t,Og)}_sceneToCubeUV(e,t,r,s,i){const n=kg;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(Gg),u.autoClear=!1;let d=this._backgroundBox;if(null===d){const e=new re({name:"PMREM.Background",side:S,depthWrite:!1,depthTest:!1});d=new q(new j,e)}let c=!1;const h=e.background;h?h.isColor&&(d.material.color.copy(h),e.background=null,c=!0):(d.material.color.copy(Gg),c=!0),u.setRenderTarget(s),u.clear(),c&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;tm(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=h}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===A||e.mapping===R;s?null===this._cubemapMaterial&&(this._cubemapMaterial=sm(e)):null===this._equirectMaterial&&(this._equirectMaterial=im(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;tm(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,Og)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let t=1;tUg&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const m=[];let f=0;for(let e=0;ey-4?s-y+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(t),o.render(l,Og)}}function em(e,t){const r=new oe(e,t,{magFilter:K,minFilter:K,generateMipmaps:!1,type:de,format:le,colorSpace:ue});return r.texture.mapping=ce,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function tm(e,t,r,s,i){e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i)}function rm(e){const t=new Wh;return t.depthTest=!1,t.depthWrite=!1,t.blending=z,t.name=`PMREM_${e}`,t}function sm(e){const t=rm("cubemap");return t.fragmentNode=gd(e,Zg),t}function im(e){const t=rm("equirect");return t.fragmentNode=Zu(e,np(Zg),0),t}const nm=new WeakMap;function am(e,t,r){const s=function(e){let t=nm.get(e);void 0===t&&(t=new WeakMap,nm.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class om extends Ks{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new b;s.isRenderTargetTexture=!0,this._texture=Zu(s),this._width=Zn(0),this._height=Zn(0),this._maxMip=Zn(0),this.updateBeforeType=Vs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture?s:am(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Jg(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=ad.mul(en(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),Lg(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const um=Vi(om).setParameterLength(1,3),lm=new WeakMap;class dm extends nh{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const e=r.isTextureNode?r.value:t[r.property];let s=lm.get(e);void 0===s&&(s=um(e),lm.set(e,s)),r=s}const s=!0===t.useAnisotropy||t.anisotropy>0?Dd:Ql,i=r.context(cm(bn,s)).mul(nd),n=r.context(hm(Zl)).mul(Math.PI).mul(nd),a=Ru(i),o=Ru(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(cm(vn,Jl)).mul(nd),t=Ru(e);u.addAssign(t)}}}const cm=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=zl.negate().reflect(t),r=e.mul(e).mix(r,t).normalize(),r=r.transformDirection(cl)),r),getTextureLevel:()=>e}},hm=e=>({getUV:()=>e,getTextureLevel:()=>ji(1)}),pm=new ge;class gm extends Wh{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(pm),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dm(t):null}setupLightingModel(){return new fg}setupSpecular(){const e=Io(en(.04),yn.rgb,Tn);Fn.assign(e),Ln.assign(1)}setupVariants(){const e=this.metalnessNode?ji(this.metalnessNode):sc;Tn.assign(e);let t=this.roughnessNode?ji(this.roughnessNode):rc;t=Rp({roughness:t}),bn.assign(t),this.setupSpecular(),yn.assign(nn(yn.rgb.mul(e.oneMinus()),yn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const mm=new me;class fm extends gm{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(mm),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?ji(this.iorNode):yc;On.assign(e),Fn.assign(Io(To(Co(On.sub(1).div(On.add(1))).mul(Jd),en(1)).mul(Zd),yn.rgb,Tn)),Ln.assign(Io(Zd,1,Tn))}setupLightingModel(){return new fg(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?ji(this.clearcoatNode):nc,t=this.clearcoatRoughnessNode?ji(this.clearcoatRoughnessNode):ac;_n.assign(e),vn.assign(Rp({roughness:t}))}if(this.useSheen){const e=this.sheenNode?en(this.sheenNode):lc,t=this.sheenRoughnessNode?ji(this.sheenRoughnessNode):dc;Nn.assign(e),Sn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?ji(this.iridescenceNode):hc,t=this.iridescenceIORNode?ji(this.iridescenceIORNode):pc,r=this.iridescenceThicknessNode?ji(this.iridescenceThicknessNode):gc;En.assign(e),wn.assign(t),An.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Yi(this.anisotropyNode):cc).toVar();Cn.assign(e.length()),Hi(Cn.equal(0),(()=>{e.assign(Yi(1,0))})).Else((()=>{e.divAssign(Yi(Cn)),Cn.assign(Cn.saturate())})),Rn.assign(Cn.pow2().mix(bn.pow2(),1)),Mn.assign(Bd[0].mul(e.x).add(Bd[1].mul(e.y))),Pn.assign(Bd[1].mul(e.x).sub(Bd[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?ji(this.transmissionNode):mc,t=this.thicknessNode?ji(this.thicknessNode):fc,r=this.attenuationDistanceNode?ji(this.attenuationDistanceNode):xc,s=this.attenuationColorNode?en(this.attenuationColorNode):bc;if(kn.assign(e),Gn.assign(t),zn.assign(r),Hn.assign(s),this.useDispersion){const e=this.dispersionNode?ji(this.dispersionNode):wc;$n.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?en(this.clearcoatNormalNode):oc}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class ym extends fg{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ql.mul(a)).normalize(),h=ji(zl.dot(c.negate()).saturate().pow(l).mul(d)),p=en(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class xm extends fm{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ji(.1),this.thicknessAmbientNode=ji(0),this.thicknessAttenuationNode=ji(.1),this.thicknessPowerNode=ji(2),this.thicknessScaleNode=ji(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new ym(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const bm=ki((({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Yi(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Td("gradientMap","texture").context({getUV:()=>i});return en(e.r)}{const e=i.fwidth().mul(.5);return Io(en(.7),en(1),Oo(ji(.7).sub(e.x),ji(.7).add(e.x),i.x))}}));class Tm extends gp{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=bm({normal:jl,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul(bp({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(bp({diffuseColor:yn}))),s.indirectDiffuse.mulAssign(t)}}const _m=new fe;class vm extends Wh{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_m),this.setValues(e)}setupLightingModel(){return new Tm}}class Nm extends Ks{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=en(zl.z,0,zl.x.negate()).normalize(),t=zl.cross(e);return Yi(e.dot(Ql),t.dot(Ql)).mul(.495).add(.5)}}const Sm=Ui(Nm),Em=new ye;class wm extends Wh{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Em),this.setValues(e)}setupVariants(e){const t=Sm;let r;r=e.material.matcap?Td("matcap","texture").context({getUV:()=>t}):en(Io(.2,.8,t.y)),yn.rgb.mulAssign(r.rgb)}}class Am extends Ks{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return ln(e,s,s.negate(),e).mul(r)}{const e=t,s=cn(nn(1,0,0,0),nn(0,eo(e.x),Ja(e.x).negate(),0),nn(0,Ja(e.x),eo(e.x),0),nn(0,0,0,1)),i=cn(nn(eo(e.y),0,Ja(e.y),0),nn(0,1,0,0),nn(Ja(e.y).negate(),0,eo(e.y),0),nn(0,0,0,1)),n=cn(nn(eo(e.z),Ja(e.z).negate(),0,0),nn(Ja(e.z),eo(e.z),0,0),nn(0,0,1,0),nn(0,0,0,1));return s.mul(i).mul(n).mul(nn(r,1)).xyz}}}const Rm=Vi(Am).setParameterLength(2),Cm=new xe;class Mm extends Wh{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Cm),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,s=this.sizeAttenuation,{positionNode:i,rotationNode:n,scaleNode:a}=this,o=Fl.mul(en(i||0));let u=Yi(El[0].xyz.length(),El[1].xyz.length());if(null!==a&&(u=u.mul(Yi(a))),!1===s)if(r.isPerspectiveCamera)u=u.mul(o.z.negate());else{const e=ji(2).div(ll.element(1).element(1));u=u.mul(e.mul(2))}let l=Dl.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>Bi(new gu(e,t,r)))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=ji(n||uc),c=Rm(l,d);return nn(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pm=new be;class Fm extends Mm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pm),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Fl.mul(en(e||Vl)).xyz}setupVertex(e){const t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;const{rotationNode:r,scaleNode:s,sizeNode:i}=this,n=Dl.xy.toVar(),a=fh.z.div(fh.w);if(r&&r.isNode){const e=ji(r);n.assign(Rm(n,e))}let o=null!==i?Yi(i):Ec;return!0===this.sizeAttenuation&&(o=o.mul(o.div(Gl.z.negate()))),s&&s.isNode&&(o=o.mul(Yi(s))),n.mulAssign(o.mul(2)),n.assign(n.div(fh.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(nn(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class Lm extends gp{constructor(){super(),this.shadowNode=ji(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const Bm=new Te;class Im extends Wh{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Bm),this.setValues(e)}setupLightingModel(){return new Lm}}const Dm=mn("vec3"),Vm=mn("vec3"),Um=mn("vec3");class Om extends gp{constructor(){super()}start(e){const{material:t,context:r}=e,s=mn("vec3"),i=mn("vec3");Hi(gl.sub(Ol).length().greaterThan(Cl.mul(2)),(()=>{s.assign(gl),i.assign(Ol)})).Else((()=>{s.assign(Ol),i.assign(gl)}));const n=i.sub(s),a=Zn("int").onRenderUpdate((({material:e})=>e.steps)),o=n.length().div(a).toVar(),u=n.normalize().toVar(),l=ji(0).toVar(),d=en(1).toVar();t.offsetNode&&l.addAssign(t.offsetNode.mul(o)),Zc(a,(()=>{const i=s.add(u.mul(l)),n=cl.mul(nn(i,1)).xyz;let a;null!==t.depthNode&&(Vm.assign(Vh(Fh(n.z,ol,ul))),r.sceneDepthNode=Vh(t.depthNode).toVar()),r.positionWorld=i,r.shadowPositionWorld=i,r.positionView=n,Dm.assign(0),t.scatteringNode&&(a=t.scatteringNode({positionRay:i})),super.start(e),a&&Dm.mulAssign(a);const c=Dm.mul(.01).negate().mul(o).exp();d.mulAssign(c),l.addAssign(o)})),Um.addAssign(d.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Hi(r.greaterThanEqual(Vm),(()=>{Dm.addAssign(e)})):Dm.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(Wp({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(Um)}}class km extends Wh{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=S,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new Om}}class Gm{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class zm{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set;for(const i of e){const e=i.node&&i.node.attribute?i.node.attribute:t.getAttribute(i.name);if(void 0===e)continue;r.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;s.add(n)}return this.attributes=r,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1&&(r+=e.uuid+","),r+=e.receiveShadow+",",xs(r)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ts(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ts(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Wm=[];class jm{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Wm[0]=e,Wm[1]=t,Wm[2]=n,Wm[3]=i;let l=u.get(Wm);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Wm,l)):(l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Wm.length=0,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new zm)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new $m(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.delete(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class qm{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Xm=1,Km=2,Ym=3,Qm=4,Zm=16;class Jm extends qm{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Xm?this.backend.createAttribute(e):t===Km?this.backend.createIndexAttribute(e):t===Ym?this.backend.createStorageAttribute(e):t===Qm&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ym):this.updateAttribute(e,Xm);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Km);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Qm)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=tf(t),e.set(t,r)):r.version!==ef(t)&&(this.attributes.delete(r),r=tf(t),e.set(t,r)),s=r}return s}}class sf{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class nf{constructor(e){this.cacheKey=e,this.usedTimes=0}}class af extends nf{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class of extends nf{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let uf=0;class lf{constructor(e,t,r,s=null,i=null){this.id=uf++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class df extends qm{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new lf(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new lf(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new lf(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new of(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new af(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class cf extends qm{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!1===this.nodes.updateGroup(t))continue}if(t.isStorageBuffer){const e=t.attribute,r=e.isIndirectStorageBufferAttribute?Qm:Ym;this.attributes.update(e,r)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){const e=this.textures.get(t.texture);t.needsBindingsUpdate(e.generation)&&(s=!0);const o=t.update(),u=t.texture;o&&this.textures.updateTexture(u);const l=r.get(u);if(void 0!==l.externalTexture||e.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===r.isWebGPUBackend&&void 0===l.texture&&void 0===l.externalTexture&&(console.error("Bindings._update: binding should be available:",t,o,u,t.textureNode.value,s),this.textures.updateTexture(u),s=!0),!0===u.isStorageTexture){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function hf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function pf(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function gf(e){return(e.transmission>0||e.transmissionNode)&&e.side===Se&&!1===e.forceSinglePass}class mf{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0?(gf(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||hf),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||pf),this.transparent.length>1&&this.transparent.sort(t||pf)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;void 0===l&&d&&(l=new V,l.format=e.stencilBuffer?we:Ae,l.type=e.stencilBuffer?Re:T,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.isArrayTexture=!0===e.multiview&&a.depth>1,i[t]=l),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=l.isArrayTexture?l.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const h={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const s=e.image;if(void 0===s)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&i.generateMipmaps(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version}if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=Ef){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class Af extends e{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class Rf extends gn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class Cf extends js{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){const r=new Li(t);return this._currentCond=Xo(e,r),this.add(this._currentCond)}ElseIf(e,t){const r=new Li(t),s=Xo(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Li(e),this}Switch(e){return this._expressionNode=Bi(e),this}Case(...e){const t=[];if(!(e.length>=2))throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}))),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=0;for(const r of this.membersLayout){const s=r.type,i=Rs(s)*e,n=t%8,a=n%Cs(s),o=n+a;t+=a,0!==o&&8-oe.name===t));return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Ff extends js{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class Lf extends js{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;t{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)})),Of=(e,t)=>Ro(la(4,e.mul(ua(1,e))),t),kf=ki((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gf=ki((([e])=>en(kf(e.z.add(kf(e.y.mul(1)))),kf(e.z.add(kf(e.x.mul(1)))),kf(e.y.add(kf(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),zf=ki((([e,t,r])=>{const s=en(e).toVar(),i=ji(1.4).toVar(),n=ji(0).toVar(),a=en(s).toVar();return Zc({start:ji(0),end:ji(3),type:"float",condition:"<="},(()=>{const e=en(Gf(a.mul(2))).toVar();s.addAssign(e.add(r.mul(ji(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=ji(kf(s.z.add(kf(s.x.add(kf(s.y)))))).toVar();n.addAssign(o.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 Hf extends js{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let r=this._candidateFnCall;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFnCall=r=s(...t)}return r}}const $f=Vi(Hf),Wf=e=>(...t)=>$f(e,...t),jf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.time)),qf=Zn(0).setGroup(Kn).onRenderUpdate((e=>e.deltaTime)),Xf=Zn(0,"uint").setGroup(Kn).onRenderUpdate((e=>e.frameId)),Kf=ki((([e,t,r=Yi(.5)])=>Rm(e.sub(r),t).add(r))),Yf=ki((([e,t,r=Yi(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))})),Qf=ki((({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=El.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=El;const i=cl.mul(s);return Pi(t)&&(i[0][0]=El[0].length(),i[0][1]=0,i[0][2]=0),Pi(r)&&(i[1][0]=0,i[1][1]=El[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ll.mul(i).mul(Vl)})),Zf=ki((([e=null])=>{const t=Vh();return Vh(Ch(e)).sub(t).lessThan(0).select(ph,e)}));class Jf extends js{static get type(){return"SpriteSheetUVNode"}constructor(e,t=$u(),r=ji(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:i}=r,n=e.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=r.reciprocal(),l=Yi(a,o);return t.add(l).mul(u)}}const ey=Vi(Jf).setParameterLength(3);class ty extends js{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,r=null,s=ji(1),i=Vl,n=ql){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=r,this.scaleNode=s,this.positionNode=i,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:r,scaleNode:s,positionNode:i,normalNode:n}=this;let a=n.abs().normalize();a=a.div(a.dot(en(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Zu(d,o).mul(a.x),g=Zu(c,u).mul(a.y),m=Zu(h,l).mul(a.z);return oa(p,g,m)}}const ry=Vi(ty).setParameterLength(1,6),sy=new Me,iy=new r,ny=new r,ay=new r,oy=new a,uy=new r(0,0,-1),ly=new s,dy=new r,cy=new r,hy=new s,py=new t,gy=new oe,my=ph.flipX();gy.depthTexture=new V(1,1);let fy=!1;class yy extends Yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||gy.texture,my),this._reflectorBaseNode=e.reflector||new xy(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Bi(new yy({defaultTexture:gy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class xy extends js{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new Pe,resolution:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=s,this.generateMipmaps=i,this.bounces=n,this.depth=a,this.updateBeforeType=n?Vs.RENDER:Vs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolution;t.getDrawingBufferSize(py),e.setSize(Math.round(py.width*r),Math.round(py.height*r))}setup(e){return this._updateResolution(gy,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new oe(0,0,{type:de}),!0===this.generateMipmaps&&(t.texture.minFilter=Fe,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&fy)return!1;fy=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(py),this._updateResolution(o,s),ny.setFromMatrixPosition(n.matrixWorld),ay.setFromMatrixPosition(r.matrixWorld),oy.extractRotation(n.matrixWorld),iy.set(0,0,1),iy.applyMatrix4(oy),dy.subVectors(ny,ay);let u=!1;if(!0===dy.dot(iy)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(fy=!1);u=!0}dy.reflect(iy).negate(),dy.add(ny),oy.extractRotation(r.matrixWorld),uy.set(0,0,-1),uy.applyMatrix4(oy),uy.add(ay),cy.subVectors(ny,uy),cy.reflect(iy).negate(),cy.add(ny),a.coordinateSystem=r.coordinateSystem,a.position.copy(dy),a.up.set(0,1,0),a.up.applyMatrix4(oy),a.up.reflect(iy),a.lookAt(cy),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),sy.setFromNormalAndCoplanarPoint(iy,ny),sy.applyMatrix4(a.matrixWorldInverse),ly.set(sy.normal.x,sy.normal.y,sy.normal.z,sy.constant);const l=a.projectionMatrix;hy.x=(Math.sign(ly.x)+l.elements[8])/l.elements[0],hy.y=(Math.sign(ly.y)+l.elements[9])/l.elements[5],hy.z=-1,hy.w=(1+l.elements[10])/l.elements[14],ly.multiplyScalar(1/ly.dot(hy));l.elements[2]=ly.x,l.elements[6]=ly.y,l.elements[10]=s.coordinateSystem===d?ly.z-0:ly.z+1-0,l.elements[14]=ly.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const c=s.getRenderTarget(),h=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),s.setMRT(h),s.setRenderTarget(c),s.autoClear=p,i.visible=!0,fy=!1,this.forceUpdate=!1}}const by=new ne(-1,1,1,-1,0,1);class Ty extends he{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Le([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Le(t,2))}}const _y=new Ty;class vy extends q{constructor(e=null){super(_y,e),this.camera=by,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,by)}render(e){e.render(this,by)}}const Ny=new t;class Sy extends Yu{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:de}){const i=new oe(t,r,s);super(i.texture,$u()),this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new vy(new Wh),this.updateBeforeType=Vs.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(Ny);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const Ey=(e,...t)=>Bi(new Sy(Bi(e),...t)),wy=ki((([e,t,r],s)=>{let i;s.renderer.coordinateSystem===d?(e=Yi(e.x,e.y.oneMinus()).mul(2).sub(1),i=nn(en(e,t),1)):i=nn(en(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=nn(r.mul(i));return n.xyz.div(n.w)})),Ay=ki((([e,t])=>{const r=t.mul(nn(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Yi(s.x,s.y.oneMinus())})),Ry=ki((([e,t,r])=>{const s=ju(Ju(t)),i=Qi(e.mul(s)).toVar(),n=Ju(t,i).toVar(),a=Ju(t,i.sub(Qi(2,0))).toVar(),o=Ju(t,i.sub(Qi(1,0))).toVar(),u=Ju(t,i.add(Qi(1,0))).toVar(),l=Ju(t,i.add(Qi(2,0))).toVar(),d=Ju(t,i.add(Qi(0,2))).toVar(),c=Ju(t,i.add(Qi(0,1))).toVar(),h=Ju(t,i.sub(Qi(0,1))).toVar(),p=Ju(t,i.sub(Qi(0,2))).toVar(),g=no(ua(ji(2).mul(o).sub(a),n)).toVar(),m=no(ua(ji(2).mul(u).sub(l),n)).toVar(),f=no(ua(ji(2).mul(c).sub(d),n)).toVar(),y=no(ua(ji(2).mul(h).sub(p),n)).toVar(),x=wy(e,n,r).toVar(),b=g.lessThan(m).select(x.sub(wy(e.sub(Yi(ji(1).div(s.x),0)),o,r)),x.negate().add(wy(e.add(Yi(ji(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(x.sub(wy(e.add(Yi(0,ji(1).div(s.y))),c,r)),x.negate().add(wy(e.sub(Yi(0,ji(1).div(s.y))),h,r)));return Qa(Ao(b,T))}));class Cy extends F{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class My extends pe{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Py extends js{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Fy=Ui(Py),Ly=new E,By=new a;class Iy extends js{static get type(){return"SceneNode"}constructor(e=Iy.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=null!==this.scene?this.scene:e.scene;let s;return t===Iy.BACKGROUND_BLURRINESS?s=yd("backgroundBlurriness","float",r):t===Iy.BACKGROUND_INTENSITY?s=yd("backgroundIntensity","float",r):t===Iy.BACKGROUND_ROTATION?s=Zn("mat4").label("backgroundRotation").setGroup(Kn).onRenderUpdate((()=>{const e=r.background;return null!==e&&e.isTexture&&e.mapping!==Be?(Ly.copy(r.backgroundRotation),Ly.x*=-1,Ly.y*=-1,Ly.z*=-1,By.makeRotationFromEuler(Ly)):By.identity(),By})):console.error("THREE.SceneNode: Unknown scope:",t),s}}Iy.BACKGROUND_BLURRINESS="backgroundBlurriness",Iy.BACKGROUND_INTENSITY="backgroundIntensity",Iy.BACKGROUND_ROTATION="backgroundRotation";const Dy=Ui(Iy,Iy.BACKGROUND_BLURRINESS),Vy=Ui(Iy,Iy.BACKGROUND_INTENSITY),Uy=Ui(Iy,Iy.BACKGROUND_ROTATION);class Oy extends Yu{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=Os.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let r;return r=null!==this.storeNode?this.generateStore(e):super.generate(e,t),r}toReadWrite(){return this.setAccess(Os.READ_WRITE)}toReadOnly(){return this.setAccess(Os.READ_ONLY)}toWriteOnly(){return this.setAccess(Os.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(e,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const ky=Vi(Oy).setParameterLength(1,3),Gy=ki((({texture:e,uv:t})=>{const r=1e-4,s=en().toVar();return Hi(t.x.lessThan(r),(()=>{s.assign(en(1,0,0))})).ElseIf(t.y.lessThan(r),(()=>{s.assign(en(0,1,0))})).ElseIf(t.z.lessThan(r),(()=>{s.assign(en(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{s.assign(en(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{s.assign(en(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{s.assign(en(0,0,-1))})).Else((()=>{const r=.01,i=e.sample(t.add(en(-.01,0,0))).r.sub(e.sample(t.add(en(r,0,0))).r),n=e.sample(t.add(en(0,-.01,0))).r.sub(e.sample(t.add(en(0,r,0))).r),a=e.sample(t.add(en(0,0,-.01))).r.sub(e.sample(t.add(en(0,0,r))).r);s.assign(en(i,n,a))})),s.normalize()}));class zy extends Yu{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return en(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!e.isFlipY()||!0!==r.isRenderTargetTexture&&!0!==r.isFramebufferTexture||(t=this.sampler?t.flipY():t.setY(qi(ju(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gy({texture:this,uv:e})}}const Hy=Vi(zy).setParameterLength(1,3);class $y extends fd{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Wy=new WeakMap;class jy extends Ks{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Vs.OBJECT,this.updateAfterType=Vs.OBJECT,this.previousModelWorldMatrix=Zn(new a),this.previousProjectionMatrix=Zn(new a).setGroup(Kn),this.previousCameraViewMatrix=Zn(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=Xy(r);this.previousModelWorldMatrix.value.copy(s);const i=qy(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){Xy(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?ll:Zn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(Fl).mul(Vl),s=this.previousProjectionMatrix.mul(t).mul(Ul),i=r.xy.div(r.w),n=s.xy.div(s.w);return ua(i,n)}}function qy(e){let t=Wy.get(e);return void 0===t&&(t={},Wy.set(e,t)),t}function Xy(e,t=0){const r=qy(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const Ky=Ui(jy),Yy=ki((([e,t])=>To(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Qy=ki((([e,t])=>To(e.div(t.oneMinus()),1))).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Zy=ki((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Jy=ki((([e,t])=>Io(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),vo(.5,e)))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),ex=ki((([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return nn(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)})).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),tx=ki((([e])=>nn(e.rgb.mul(e.a),e.a)),{color:"vec4",return:"vec4"}),rx=ki((([e])=>(Hi(e.a.equal(0),(()=>nn(0))),nn(e.rgb.div(e.a),e.a))),{color:"vec4",return:"vec4"}),sx=ki((([e])=>ox(e.rgb))),ix=ki((([e,t=ji(1)])=>t.mix(ox(e.rgb),e.rgb))),nx=ki((([e,t=ji(1)])=>{const r=oa(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return Io(e.rgb,s,i)})),ax=ki((([e,t=ji(1)])=>{const r=en(.57735,.57735,.57735),s=t.cos();return en(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(wo(r,e.rgb).mul(s.oneMinus())))))})),ox=(e,t=en(c.getLuminanceCoefficients(new r)))=>wo(e,t),ux=ki((([e,t=en(1),s=en(0),i=en(1),n=ji(1),a=en(c.getLuminanceCoefficients(new r,ue))])=>{const o=e.rgb.dot(en(a)),u=_o(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return Hi(u.r.greaterThan(0),(()=>{u.r.assign(l.r)})),Hi(u.g.greaterThan(0),(()=>{u.g.assign(l.g)})),Hi(u.b.greaterThan(0),(()=>{u.b.assign(l.b)})),u.assign(o.add(u.sub(o).mul(n))),nn(u.rgb,e.a)}));class lx extends Ks{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const dx=Vi(lx).setParameterLength(2),cx=new t;class hx extends Yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class px extends hx{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class gx extends Ks{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const i=new V;i.isRenderTargetTexture=!0,i.name="depth";const n=new oe(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:de,...s});n.texture.name="output",n.depthTexture=i,this.renderTarget=n,this._textures={output:n.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Zn(0),this._cameraFar=Zn(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Vs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=Bi(new px(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=Bi(new px(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=Lh(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=Ph(i,r,s)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===gx.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,i;const n=t.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(i=1,s=t.xr.getCamera(),t.xr.updateCamera(s),cx.set(n.width,n.height)):(s=this.camera,i=t.getPixelRatio(),t.getSize(cx)),this._pixelRatio=i,this.setSize(cx.width,cx.height);const a=t.getRenderTarget(),o=t.getMRT(),u=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(r,s),t.setRenderTarget(a),t.setMRT(o),s.layers.mask=u}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}gx.COLOR="color",gx.DEPTH="depth";class mx extends gx{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(gx.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction(((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)})),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Wh;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=S;const t=ql.negate(),r=ll.mul(Fl),s=ji(1),i=r.mul(nn(Vl,1)),n=r.mul(nn(Vl.add(t),1)),a=Qa(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=nn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fx=ki((([e,t])=>e.mul(t).clamp())).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),yx=ki((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xx=ki((([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)})).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bx=ki((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)})),Tx=ki((([e,t])=>{const r=dn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=dn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=bx(e),(e=s.mul(e)).clamp()})).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_x=dn(en(1.6605,-.1246,-.0182),en(-.5876,1.1329,-.1006),en(-.0728,-.0083,1.1187)),vx=dn(en(.6274,.0691,.0164),en(.3293,.9195,.088),en(.0433,.0113,.8956)),Nx=ki((([e])=>{const t=en(e).toVar(),r=en(t.mul(t)).toVar(),s=en(r.mul(r)).toVar();return ji(15.5).mul(s.mul(r)).sub(la(40.14,s.mul(t))).add(la(31.96,s).sub(la(6.868,r.mul(t))).add(la(.4298,r).add(la(.1191,t).sub(.00232))))})),Sx=ki((([e,t])=>{const r=en(e).toVar(),s=dn(en(.856627153315983,.137318972929847,.11189821299995),en(.0951212405381588,.761241990602591,.0767994186031903),en(.0482516061458583,.101439036467562,.811302368396859)),i=dn(en(1.1271005818144368,-.1413297634984383,-.14132976349843826),en(-.11060664309660323,1.157823702216272,-.11060664309660294),en(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=ji(-12.47393),a=ji(4.026069);return r.mulAssign(t),r.assign(vx.mul(r)),r.assign(s.mul(r)),r.assign(_o(r,1e-10)),r.assign(ja(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Do(r,0,1)),r.assign(Nx(r)),r.assign(i.mul(r)),r.assign(Ro(_o(en(0),r),en(2.2))),r.assign(_x.mul(r)),r.assign(Do(r,0,1)),r})).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Ex=ki((([e,t])=>{const r=ji(.76),s=ji(.15);e=e.mul(t);const i=To(e.r,To(e.g,e.b)),n=Xo(i.lessThan(.08),i.sub(la(6.25,i.mul(i))),.04);e.subAssign(n);const a=_o(e.r,_o(e.g,e.b));Hi(a.lessThan(r),(()=>e));const o=ua(1,r),u=ua(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=ua(1,da(1,s.mul(a.sub(u)).add(1)));return Io(e,en(u),l)})).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class wx extends js{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ax=Vi(wx).setParameterLength(1,3);class Rx extends wx{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const Cx=(e,t=[],r="")=>{for(let e=0;es.call(...e);return i.functionNode=s,i};class Mx extends js{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new o,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ji()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Ls(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?Bs(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Px=Vi(Mx).setParameterLength(1);class Fx extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){const s=t(...r);return this.set(e,s),s}}}class Lx{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Bx=new Fx;class Ix extends js{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new Fx,this._output=Px(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const r=this._outputs;return void 0===r[e]?r[e]=Px(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=Px(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new Lx(this),t=Bx.get("THREE"),r=Bx.get("TSL"),s=this.getMethod(),i=[e,this._local,Bx,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,r];this._object=s(...i);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ji()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",r="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],r),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[xs(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return bs(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Dx=Vi(Ix).setParameterLength(1,2);function Vx(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||Gl.z).negate()}const Ux=ki((([e,t],r)=>{const s=Vx(r);return Oo(e,t,s)})),Ox=ki((([e],t)=>{const r=Vx(t);return e.mul(e,r,r).negate().exp().oneMinus()})),kx=ki((([e,t])=>nn(t.toFloat().mix(In.rgb,e.toVec3()),In.a)));let Gx=null,zx=null;class Hx extends js{static get type(){return"RangeNode"}constructor(e=ji(),t=ji()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ms(this.minNode.value)),r=e.getTypeLength(Ms(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Ms(i)),o=e.getTypeLength(Ms(n));Gx=Gx||new s,zx=zx||new s,Gx.setScalar(0),zx.setScalar(0),1===a?Gx.setScalar(i):i.isColor?Gx.set(i.r,i.g,i.b,1):Gx.set(i.x,i.y,i.z||0,i.w||0),1===o?zx.setScalar(n):n.isColor?zx.set(n.r,n.g,n.b,1):zx.set(n.x,n.y,n.z||0,n.w||0);const l=4,d=l*t.count,c=new Float32Array(d);for(let e=0;eBi(new Wx(e,t)),qx=jx("numWorkgroups","uvec3"),Xx=jx("workgroupId","uvec3"),Kx=jx("globalId","uvec3"),Yx=jx("localId","uvec3"),Qx=jx("subgroupSize","uint");const Zx=Vi(class extends js{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}});class Jx extends qs{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class eb extends js{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Bi(new Jx(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class tb extends js{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=Du(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}tb.ATOMIC_LOAD="atomicLoad",tb.ATOMIC_STORE="atomicStore",tb.ATOMIC_ADD="atomicAdd",tb.ATOMIC_SUB="atomicSub",tb.ATOMIC_MAX="atomicMax",tb.ATOMIC_MIN="atomicMin",tb.ATOMIC_AND="atomicAnd",tb.ATOMIC_OR="atomicOr",tb.ATOMIC_XOR="atomicXor";const rb=Vi(tb),sb=(e,t,r)=>rb(e,t,r).toStack();let ib;function nb(e){ib=ib||new WeakMap;let t=ib.get(e);return void 0===t&&ib.set(e,t={}),t}function ab(e){const t=nb(e);return t.shadowMatrix||(t.shadowMatrix=Zn("mat4").setGroup(Kn).onRenderUpdate((t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||e.shadow.updateMatrices(e),e.shadow.matrix))))}function ob(e,t=Ol){const r=ab(e).mul(t);return r.xyz.div(r.w)}function ub(e){const t=nb(e);return t.position||(t.position=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld))))}function lb(e){const t=nb(e);return t.targetPosition||(t.targetPosition=Zn(new r).setGroup(Kn).onRenderUpdate(((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld))))}function db(e){const t=nb(e);return t.viewPosition||(t.viewPosition=Zn(new r).setGroup(Kn).onRenderUpdate((({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)})))}const cb=e=>cl.transformDirection(ub(e).sub(lb(e))),hb=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pb=new WeakMap,gb=[];class mb extends js{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=en().toVar(),this.totalSpecularNode=en().toVar(),this.outgoingLightNode=en().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort(((e,t)=>e.id-t.id)))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(Bi(e));else{let s=null;if(null!==r&&(s=hb(e.id,r)),null===s){const r=i.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let s=null;pb.has(e)?s=pb.get(e):(s=Bi(new r(e)),pb.set(e,s)),t.push(s)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=en(null!==l?l.mix(g,u):u),s.material.transparent=!0),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class fb extends js{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Vs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){yb.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ol)}}const yb=mn("vec3","shadowPositionWorld");function xb(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function bb(e,t){return t=xb(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Tb(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function _b(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function vb(e,t){return t=_b(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Nb(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Sb(e,t,r){return r=vb(t,r=bb(e,r))}function Eb(e,t,r){Tb(e,r),Nb(t,r)}var wb=Object.freeze({__proto__:null,resetRendererAndSceneState:Sb,resetRendererState:bb,resetSceneState:vb,restoreRendererAndSceneState:Eb,restoreRendererState:Tb,restoreSceneState:Nb,saveRendererAndSceneState:function(e,t,r={}){return r=_b(t,r=xb(e,r))},saveRendererState:xb,saveSceneState:_b});const Ab=new WeakMap,Rb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Zu(e,t.xy).label("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)})),Cb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=yd("radius","float",r).setGroup(Kn),o=Yi(1).div(n),u=o.x.negate().mul(a),l=o.y.negate().mul(a),d=o.x.mul(a),c=o.y.mul(a),h=u.div(2),p=l.div(2),g=d.div(2),m=c.div(2);return oa(i(t.xy.add(Yi(u,l)),t.z),i(t.xy.add(Yi(0,l)),t.z),i(t.xy.add(Yi(d,l)),t.z),i(t.xy.add(Yi(h,p)),t.z),i(t.xy.add(Yi(0,p)),t.z),i(t.xy.add(Yi(g,p)),t.z),i(t.xy.add(Yi(u,0)),t.z),i(t.xy.add(Yi(h,0)),t.z),i(t.xy,t.z),i(t.xy.add(Yi(g,0)),t.z),i(t.xy.add(Yi(d,0)),t.z),i(t.xy.add(Yi(h,m)),t.z),i(t.xy.add(Yi(0,m)),t.z),i(t.xy.add(Yi(g,m)),t.z),i(t.xy.add(Yi(u,c)),t.z),i(t.xy.add(Yi(0,c)),t.z),i(t.xy.add(Yi(d,c)),t.z)).mul(1/17)})),Mb=ki((({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Zu(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=yd("mapSize","vec2",r).setGroup(Kn),a=Yi(1).div(n),o=a.x,u=a.y,l=t.xy,d=Za(l.mul(n).add(.5));return l.subAssign(d.mul(a)),oa(i(l,t.z),i(l.add(Yi(o,0)),t.z),i(l.add(Yi(0,u)),t.z),i(l.add(a),t.z),Io(i(l.add(Yi(o.negate(),0)),t.z),i(l.add(Yi(o.mul(2),0)),t.z),d.x),Io(i(l.add(Yi(o.negate(),u)),t.z),i(l.add(Yi(o.mul(2),u)),t.z),d.x),Io(i(l.add(Yi(0,u.negate())),t.z),i(l.add(Yi(0,u.mul(2))),t.z),d.y),Io(i(l.add(Yi(o,u.negate())),t.z),i(l.add(Yi(o,u.mul(2))),t.z),d.y),Io(Io(i(l.add(Yi(o.negate(),u.negate())),t.z),i(l.add(Yi(o.mul(2),u.negate())),t.z),d.x),Io(i(l.add(Yi(o.negate(),u.mul(2))),t.z),i(l.add(Yi(o.mul(2),u.mul(2))),t.z),d.x),d.y)).mul(1/9)})),Pb=ki((({depthTexture:e,shadowCoord:t,depthLayer:r})=>{const s=ji(1).toVar();let i=Zu(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=vo(t.z,i.x);return Hi(n.notEqual(ji(1)),(()=>{const e=t.z.sub(i.x),r=_o(0,i.y.mul(i.y));let a=r.div(r.add(e.mul(e)));a=Do(ua(a,.3).div(.95-.3)),s.assign(Do(_o(n,a)))})),s})),Fb=ki((([e,t,r])=>{let s=Ol.sub(e).length();return s=s.sub(t).div(r.sub(t)),s=s.saturate(),s})),Lb=e=>{let t=Ab.get(e);if(void 0===t){const r=e.isPointLight?(e=>{const t=e.shadow.camera,r=yd("near","float",t).setGroup(Kn),s=yd("far","float",t).setGroup(Kn),i=bl(e);return Fb(i,r,s)})(e):null;t=new Wh,t.colorNode=nn(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,Ab.set(e,t)}return t},Bb=new zm,Ib=[],Db=(e,t,r,s)=>{Ib[0]=e,Ib[1]=t;let i=Bb.get(Ib);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===Ie)&&(s&&(Fs(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Bb.set(Ib,i)),Ib[0]=null,Ib[1]=null,i},Vb=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanVertical"),a=ji(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ub=ki((({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=ji(0).toVar("meanHorizontal"),a=ji(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ji(1)).select(ji(0),ji(2).div(e.sub(1))),u=e.lessThanEqual(ji(1)).select(ji(0),ji(-1));Zc({start:qi(0),end:qi(e),type:"int",condition:"<"},(({i:e})=>{const l=u.add(ji(e).mul(o));let d=s.sample(oa(mh.xy,Yi(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(oa(d.y.mul(d.y),d.x.mul(d.x)))})),n.divAssign(e),a.divAssign(e);const l=qa(a.sub(n.mul(n)));return Yi(n,l)})),Ob=[Rb,Cb,Mb,Pb];let kb;const Gb=new vy;class zb extends fb{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const 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:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,ji(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=yd("bias","float",r).setGroup(Kn);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z,s.coordinateSystem===d&&(n=n.mul(2).sub(1));else{const e=a.w;a=a.xy.div(e);const t=yd("near","float",r.camera).setGroup(Kn),s=yd("far","float",r.camera).setGroup(Kn);n=Bh(e.negate(),t,s)}return a=en(a.x,a.y.oneMinus(),n.add(i)),a}getShadowFilterFn(e){return Ob[e]}setupRenderTarget(e,t){const r=new V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=De;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t}=e,{light:r,shadow:s}=this,i=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),i===Ie&&!0!==s.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ve,type:de,depthBuffer:!1}));let t=Zu(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Zu(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const i=yd("blurSamples","float",s).setGroup(Kn),o=yd("radius","float",s).setGroup(Kn),u=yd("mapSize","vec2",s).setGroup(Kn);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Wh);l.fragmentNode=Vb({samples:i,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Wh),l.fragmentNode=Ub({samples:i,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const o=yd("intensity","float",s).setGroup(Kn),u=yd("normalBias","float",s).setGroup(Kn),l=ab(r).mul(yb.add(Zl.mul(u))),d=this.setupShadowCoord(e,l),c=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const h=i===Ie&&!0!==s.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,p=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:h,shadowCoord:d,shadow:s,depthLayer:this.depthLayer});let g=Zu(a.texture,d);n.isArrayTexture&&(g=g.depth(this.depthLayer));const m=Io(1,p.rgb.mix(g,1),o.mul(g.a)).toVar();return this.shadowMap=a,this.shadow.map=a,m}setup(e){if(!1!==e.renderer.shadowMap.enabled)return ki((()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t}))()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),i.render(n,t.camera)}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");kb=Sb(i,n,kb),n.overrideMaterial=Lb(r),i.setRenderObjectFunction(Db(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===Ie&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,Eb(i,n,kb)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Gb.material=this.vsmMaterialVertical,Gb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Gb.material=this.vsmMaterialHorizontal,Gb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Hb=(e,t)=>Bi(new zb(e,t)),$b=new e,Wb=ki((([e,t])=>{const r=e.toVar(),s=no(r),i=da(1,_o(s.x,_o(s.y,s.z)));s.mulAssign(i),r.mulAssign(i.mul(t.mul(2).oneMinus()));const n=Yi(r.xy).toVar(),a=t.mul(1.5).oneMinus();return Hi(s.z.greaterThanEqual(a),(()=>{Hi(r.z.greaterThan(0),(()=>{n.x.assign(ua(4,r.x))}))})).ElseIf(s.x.greaterThanEqual(a),(()=>{const e=ao(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))})).ElseIf(s.y.greaterThanEqual(a),(()=>{const e=ao(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))})),Yi(.125,.25).mul(n).add(Yi(.375,.75)).flipY()})).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),jb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s})=>Zu(e,Wb(t,s.y)).compare(r))),qb=ki((({depthTexture:e,bd3D:t,dp:r,texelSize:s,shadow:i})=>{const n=yd("radius","float",i).setGroup(Kn),a=Yi(-1,1).mul(n).mul(s.y);return Zu(e,Wb(t.add(a.xyy),s.y)).compare(r).add(Zu(e,Wb(t.add(a.yyy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xyx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yyx),s.y)).compare(r)).add(Zu(e,Wb(t,s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxy),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.xxx),s.y)).compare(r)).add(Zu(e,Wb(t.add(a.yxx),s.y)).compare(r)).mul(1/9)})),Xb=ki((({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s})=>{const i=r.xyz.toVar(),n=i.length(),a=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.near)),o=Zn("float").setGroup(Kn).onRenderUpdate((()=>s.camera.far)),u=yd("bias","float",s).setGroup(Kn),l=Zn(s.mapSize).setGroup(Kn),d=ji(1).toVar();return Hi(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),(()=>{const r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(u);const c=i.normalize(),h=Yi(1).div(l.mul(Yi(4,2)));d.assign(e({depthTexture:t,bd3D:c,dp:r,texelSize:h,shadow:s}))})),d})),Kb=new s,Yb=new t,Qb=new t;class Zb extends zb{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===Ue?jb:qb}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n}){return Xb({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:i,shadow:n})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.getFrameExtents();Qb.copy(t.mapSize),Qb.multiply(a),r.setSize(Qb.width,Qb.height),Yb.copy(t.mapSize);const o=i.autoClear,u=i.getClearColor($b),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();const d=t.getViewportCount();for(let e=0;eBi(new Zb(e,t));class eT extends nh{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||Zn(this.color).setGroup(Kn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Vs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return db(this.light).sub(e.context.positionView||Gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Hb(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?Bi(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const tT=ki((({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)})),rT=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=tT({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class sT extends eT{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(2).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Jb(this.light)}setupDirect(e){return rT({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const iT=ki((([e=t()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()})),nT=ki((([e=$u()],{renderer:t,material:r})=>{const s=Bo(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.samples>1){const e=ji(s.fwidth()).toVar();i=Oo(e.oneMinus(),e.add(1),s).oneMinus()}else i=Xo(s.greaterThan(1),0,1);return i})),aT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Ki(e).toVar();return Xo(n,i,s)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),oT=ki((([e,t])=>{const r=Ki(t).toVar(),s=ji(e).toVar();return Xo(r,s.negate(),s)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),uT=ki((([e])=>{const t=ji(e).toVar();return qi(Ka(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),lT=ki((([e,t])=>{const r=ji(e).toVar();return t.assign(uT(r)),r.sub(ji(t))})),dT=Wf([ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=ji(s).toVar(),l=ji(r).toVar(),d=ji(t).toVar(),c=ji(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]}),ki((([e,t,r,s,i,n])=>{const a=ji(n).toVar(),o=ji(i).toVar(),u=en(s).toVar(),l=en(r).toVar(),d=en(t).toVar(),c=en(e).toVar(),h=ji(ua(1,o)).toVar();return ua(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.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"}]})]),cT=Wf([ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=ji(o).toVar(),m=ji(a).toVar(),f=ji(n).toVar(),y=ji(i).toVar(),x=ji(s).toVar(),b=ji(r).toVar(),T=ji(t).toVar(),_=ji(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]}),ki((([e,t,r,s,i,n,a,o,u,l,d])=>{const c=ji(d).toVar(),h=ji(l).toVar(),p=ji(u).toVar(),g=en(o).toVar(),m=en(a).toVar(),f=en(n).toVar(),y=en(i).toVar(),x=en(s).toVar(),b=en(r).toVar(),T=en(t).toVar(),_=en(e).toVar(),v=ji(ua(1,p)).toVar(),N=ji(ua(1,h)).toVar();return ji(ua(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(b.mul(v).add(x.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.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"}]})]),hT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=Xi(e).toVar(),a=Xi(n.bitAnd(Xi(7))).toVar(),o=ji(aT(a.lessThan(Xi(4)),i,s)).toVar(),u=ji(la(2,aT(a.lessThan(Xi(4)),s,i))).toVar();return oT(o,Ki(a.bitAnd(Xi(1)))).add(oT(u,Ki(a.bitAnd(Xi(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=Xi(e).toVar(),u=Xi(o.bitAnd(Xi(15))).toVar(),l=ji(aT(u.lessThan(Xi(8)),a,n)).toVar(),d=ji(aT(u.lessThan(Xi(4)),n,aT(u.equal(Xi(12)).or(u.equal(Xi(14))),a,i))).toVar();return oT(l,Ki(u.bitAnd(Xi(1)))).add(oT(d,Ki(u.bitAnd(Xi(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"}]}),gT=Wf([hT,pT]),mT=ki((([e,t,r])=>{const s=ji(r).toVar(),i=ji(t).toVar(),n=rn(e).toVar();return en(gT(n.x,i,s),gT(n.y,i,s),gT(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"}]}),fT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=ji(t).toVar(),o=rn(e).toVar();return en(gT(o.x,a,n,i),gT(o.y,a,n,i),gT(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"}]}),yT=Wf([mT,fT]),xT=ki((([e])=>{const t=ji(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bT=ki((([e])=>{const t=ji(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),TT=Wf([xT,ki((([e])=>{const t=en(e).toVar();return la(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),_T=Wf([bT,ki((([e])=>{const t=en(e).toVar();return la(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),vT=ki((([e,t])=>{const r=qi(t).toVar(),s=Xi(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(qi(32).sub(r)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),NT=ki((([e,t,r])=>{e.subAssign(r),e.bitXorAssign(vT(r,qi(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(vT(r,qi(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(vT(e,qi(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(vT(t,qi(4))),t.addAssign(e)})),ST=ki((([e,t,r])=>{const s=Xi(r).toVar(),i=Xi(t).toVar(),n=Xi(e).toVar();return s.bitXorAssign(i),s.subAssign(vT(i,qi(14))),n.bitXorAssign(s),n.subAssign(vT(s,qi(11))),i.bitXorAssign(n),i.subAssign(vT(n,qi(25))),s.bitXorAssign(i),s.subAssign(vT(i,qi(16))),n.bitXorAssign(s),n.subAssign(vT(s,qi(4))),i.bitXorAssign(n),i.subAssign(vT(n,qi(14))),s.bitXorAssign(i),s.subAssign(vT(i,qi(24))),s})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),ET=ki((([e])=>{const t=Xi(e).toVar();return ji(t).div(ji(Xi(qi(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),wT=ki((([e])=>{const t=ji(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),AT=Wf([ki((([e])=>{const t=qi(e).toVar(),r=Xi(Xi(1)).toVar(),s=Xi(Xi(qi(3735928559)).add(r.shiftLeft(Xi(2))).add(Xi(13))).toVar();return ST(s.add(Xi(t)),s,s)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(Xi(2)).toVar(),n=Xi().toVar(),a=Xi().toVar(),o=Xi().toVar();return n.assign(a.assign(o.assign(Xi(qi(3735928559)).add(i.shiftLeft(Xi(2))).add(Xi(13))))),n.addAssign(Xi(s)),a.addAssign(Xi(r)),ST(n,a,o)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(Xi(3)).toVar(),o=Xi().toVar(),u=Xi().toVar(),l=Xi().toVar();return o.assign(u.assign(l.assign(Xi(qi(3735928559)).add(a.shiftLeft(Xi(2))).add(Xi(13))))),o.addAssign(Xi(n)),u.addAssign(Xi(i)),l.addAssign(Xi(s)),ST(o,u,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ki((([e,t,r,s])=>{const i=qi(s).toVar(),n=qi(r).toVar(),a=qi(t).toVar(),o=qi(e).toVar(),u=Xi(Xi(4)).toVar(),l=Xi().toVar(),d=Xi().toVar(),c=Xi().toVar();return l.assign(d.assign(c.assign(Xi(qi(3735928559)).add(u.shiftLeft(Xi(2))).add(Xi(13))))),l.addAssign(Xi(o)),d.addAssign(Xi(a)),c.addAssign(Xi(n)),NT(l,d,c),l.addAssign(Xi(i)),ST(l,d,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"}]}),ki((([e,t,r,s,i])=>{const n=qi(i).toVar(),a=qi(s).toVar(),o=qi(r).toVar(),u=qi(t).toVar(),l=qi(e).toVar(),d=Xi(Xi(5)).toVar(),c=Xi().toVar(),h=Xi().toVar(),p=Xi().toVar();return c.assign(h.assign(p.assign(Xi(qi(3735928559)).add(d.shiftLeft(Xi(2))).add(Xi(13))))),c.addAssign(Xi(l)),h.addAssign(Xi(u)),p.addAssign(Xi(o)),NT(c,h,p),c.addAssign(Xi(a)),h.addAssign(Xi(n)),ST(c,h,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"}]})]),RT=Wf([ki((([e,t])=>{const r=qi(t).toVar(),s=qi(e).toVar(),i=Xi(AT(s,r)).toVar(),n=rn().toVar();return n.x.assign(i.bitAnd(qi(255))),n.y.assign(i.shiftRight(qi(8)).bitAnd(qi(255))),n.z.assign(i.shiftRight(qi(16)).bitAnd(qi(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ki((([e,t,r])=>{const s=qi(r).toVar(),i=qi(t).toVar(),n=qi(e).toVar(),a=Xi(AT(n,i,s)).toVar(),o=rn().toVar();return o.x.assign(a.bitAnd(qi(255))),o.y.assign(a.shiftRight(qi(8)).bitAnd(qi(255))),o.z.assign(a.shiftRight(qi(16)).bitAnd(qi(255))),o})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),CT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(wT(i)).toVar(),o=ji(wT(n)).toVar(),u=ji(dT(gT(AT(r,s),i,n),gT(AT(r.add(qi(1)),s),i.sub(1),n),gT(AT(r,s.add(qi(1))),i,n.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(wT(n)).toVar(),l=ji(wT(a)).toVar(),d=ji(wT(o)).toVar(),c=ji(cT(gT(AT(r,s,i),n,a,o),gT(AT(r.add(qi(1)),s,i),n.sub(1),a,o),gT(AT(r,s.add(qi(1)),i),n,a.sub(1),o),gT(AT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),gT(AT(r,s,i.add(qi(1))),n,a,o.sub(1)),gT(AT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),gT(AT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),gT(AT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),MT=Wf([ki((([e])=>{const t=Yi(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=ji(lT(t.x,r)).toVar(),n=ji(lT(t.y,s)).toVar(),a=ji(wT(i)).toVar(),o=ji(wT(n)).toVar(),u=en(dT(yT(RT(r,s),i,n),yT(RT(r.add(qi(1)),s),i.sub(1),n),yT(RT(r,s.add(qi(1))),i,n.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1))),i.sub(1),n.sub(1)),a,o)).toVar();return TT(u)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi().toVar(),s=qi().toVar(),i=qi().toVar(),n=ji(lT(t.x,r)).toVar(),a=ji(lT(t.y,s)).toVar(),o=ji(lT(t.z,i)).toVar(),u=ji(wT(n)).toVar(),l=ji(wT(a)).toVar(),d=ji(wT(o)).toVar(),c=en(cT(yT(RT(r,s,i),n,a,o),yT(RT(r.add(qi(1)),s,i),n.sub(1),a,o),yT(RT(r,s.add(qi(1)),i),n,a.sub(1),o),yT(RT(r.add(qi(1)),s.add(qi(1)),i),n.sub(1),a.sub(1),o),yT(RT(r,s,i.add(qi(1))),n,a,o.sub(1)),yT(RT(r.add(qi(1)),s,i.add(qi(1))),n.sub(1),a,o.sub(1)),yT(RT(r,s.add(qi(1)),i.add(qi(1))),n,a.sub(1),o.sub(1)),yT(RT(r.add(qi(1)),s.add(qi(1)),i.add(qi(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return _T(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),PT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return ET(AT(r))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return ET(AT(r,s))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return ET(AT(r,s,i))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return ET(AT(r,s,i,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),FT=Wf([ki((([e])=>{const t=ji(e).toVar(),r=qi(uT(t)).toVar();return en(ET(AT(r,qi(0))),ET(AT(r,qi(1))),ET(AT(r,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ki((([e])=>{const t=Yi(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar();return en(ET(AT(r,s,qi(0))),ET(AT(r,s,qi(1))),ET(AT(r,s,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ki((([e])=>{const t=en(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar();return en(ET(AT(r,s,i,qi(0))),ET(AT(r,s,i,qi(1))),ET(AT(r,s,i,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ki((([e])=>{const t=nn(e).toVar(),r=qi(uT(t.x)).toVar(),s=qi(uT(t.y)).toVar(),i=qi(uT(t.z)).toVar(),n=qi(uT(t.w)).toVar();return en(ET(AT(r,s,i,n,qi(0))),ET(AT(r,s,i,n,qi(1))),ET(AT(r,s,i,n,qi(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),LT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=ji(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(CT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),BT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(0).toVar(),l=ji(1).toVar();return Zc(a,(()=>{u.addAssign(l.mul(MT(o))),l.mulAssign(i),o.mulAssign(n)})),u})).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"}]}),IT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar();return Yi(LT(o,a,n,i),LT(o.add(en(qi(19),qi(193),qi(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"}]}),DT=ki((([e,t,r,s])=>{const i=ji(s).toVar(),n=ji(r).toVar(),a=qi(t).toVar(),o=en(e).toVar(),u=en(BT(o,a,n,i)).toVar(),l=ji(LT(o.add(en(qi(19),qi(193),qi(17))),a,n,i)).toVar();return nn(u,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),VT=Wf([ki((([e,t,r,s,i,n,a])=>{const o=qi(a).toVar(),u=ji(n).toVar(),l=qi(i).toVar(),d=qi(s).toVar(),c=qi(r).toVar(),h=qi(t).toVar(),p=Yi(e).toVar(),g=en(FT(Yi(h.add(d),c.add(l)))).toVar(),m=Yi(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Yi(Yi(ji(h),ji(c)).add(m)).toVar(),y=Yi(f.sub(p)).toVar();return Hi(o.equal(qi(2)),(()=>no(y.x).add(no(y.y)))),Hi(o.equal(qi(3)),(()=>_o(no(y.x),no(y.y)))),wo(y,y)})).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"}]}),ki((([e,t,r,s,i,n,a,o,u])=>{const l=qi(u).toVar(),d=ji(o).toVar(),c=qi(a).toVar(),h=qi(n).toVar(),p=qi(i).toVar(),g=qi(s).toVar(),m=qi(r).toVar(),f=qi(t).toVar(),y=en(e).toVar(),x=en(FT(en(f.add(p),m.add(h),g.add(c)))).toVar();x.subAssign(.5),x.mulAssign(d),x.addAssign(.5);const b=en(en(ji(f),ji(m),ji(g)).add(x)).toVar(),T=en(b.sub(y)).toVar();return Hi(l.equal(qi(2)),(()=>no(T.x).add(no(T.y)).add(no(T.z)))),Hi(l.equal(qi(3)),(()=>_o(no(T.x),no(T.y),no(T.z)))),wo(T,T)})).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"}]})]),UT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();l.assign(To(l,r))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.y.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kT=ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=Yi(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=Yi(lT(n.x,a),lT(n.y,o)).toVar(),l=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{const r=ji(VT(u,e,t,a,o,i,s)).toVar();Hi(r.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)})).ElseIf(r.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(r)})).ElseIf(r.lessThan(l.z),(()=>{l.z.assign(r)}))}))})),Hi(s.equal(qi(0)),(()=>{l.assign(qa(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),GT=Wf([UT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=ji(1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();d.assign(To(d,n))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zT=Wf([OT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=Yi(1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.y.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),HT=Wf([kT,ki((([e,t,r])=>{const s=qi(r).toVar(),i=ji(t).toVar(),n=en(e).toVar(),a=qi().toVar(),o=qi().toVar(),u=qi().toVar(),l=en(lT(n.x,a),lT(n.y,o),lT(n.z,u)).toVar(),d=en(1e6,1e6,1e6).toVar();return Zc({start:-1,end:qi(1),name:"x",condition:"<="},(({x:e})=>{Zc({start:-1,end:qi(1),name:"y",condition:"<="},(({y:t})=>{Zc({start:-1,end:qi(1),name:"z",condition:"<="},(({z:r})=>{const n=ji(VT(l,e,t,r,a,o,u,i,s)).toVar();Hi(n.lessThan(d.x),(()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)})).ElseIf(n.lessThan(d.y),(()=>{d.z.assign(d.y),d.y.assign(n)})).ElseIf(n.lessThan(d.z),(()=>{d.z.assign(n)}))}))}))})),Hi(s.equal(qi(0)),(()=>{d.assign(qa(d))})),d})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),$T=ki((([e])=>{const t=e.y,r=e.z,s=en().toVar();return Hi(t.lessThan(1e-4),(()=>{s.assign(en(r,r,r))})).Else((()=>{let i=e.x;i=i.sub(Ka(i)).mul(6).toVar();const n=qi(mo(i)),a=i.sub(ji(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());Hi(n.equal(qi(0)),(()=>{s.assign(en(r,l,o))})).ElseIf(n.equal(qi(1)),(()=>{s.assign(en(u,r,o))})).ElseIf(n.equal(qi(2)),(()=>{s.assign(en(o,r,l))})).ElseIf(n.equal(qi(3)),(()=>{s.assign(en(o,u,r))})).ElseIf(n.equal(qi(4)),(()=>{s.assign(en(l,o,r))})).Else((()=>{s.assign(en(r,o,u))}))})),s})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),WT=ki((([e])=>{const t=en(e).toVar(),r=ji(t.x).toVar(),s=ji(t.y).toVar(),i=ji(t.z).toVar(),n=ji(To(r,To(s,i))).toVar(),a=ji(_o(r,_o(s,i))).toVar(),o=ji(a.sub(n)).toVar(),u=ji().toVar(),l=ji().toVar(),d=ji().toVar();return d.assign(a),Hi(a.greaterThan(0),(()=>{l.assign(o.div(a))})).Else((()=>{l.assign(0)})),Hi(l.lessThanEqual(0),(()=>{u.assign(0)})).Else((()=>{Hi(r.greaterThanEqual(a),(()=>{u.assign(s.sub(i).div(o))})).ElseIf(s.greaterThanEqual(a),(()=>{u.assign(oa(2,i.sub(r).div(o)))})).Else((()=>{u.assign(oa(4,r.sub(s).div(o)))})),u.mulAssign(1/6),Hi(u.lessThan(0),(()=>{u.addAssign(1)}))})),en(u,l,d)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),jT=ki((([e])=>{const t=en(e).toVar(),r=sn(ma(t,en(.04045))).toVar(),s=en(t.div(12.92)).toVar(),i=en(Ro(_o(t.add(en(.055)),en(0)).div(1.055),en(2.4))).toVar();return Io(s,i,r)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qT=(e,t)=>{e=ji(e),t=ji(t);const r=Yi(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Oo(e.sub(r),e.add(r),t)},XT=(e,t,r,s)=>Io(e,t,r[s].clamp()),KT=(e,t,r,s,i)=>Io(e,t,qT(r,s[i])),YT=ki((([e,t,r])=>{const s=Qa(e).toVar(),i=ua(ji(.5).mul(t.sub(r)),Ol).div(s).toVar(),n=ua(ji(-.5).mul(t.sub(r)),Ol).div(s).toVar(),a=en().toVar();a.x=s.x.greaterThan(ji(0)).select(i.x,n.x),a.y=s.y.greaterThan(ji(0)).select(i.y,n.y),a.z=s.z.greaterThan(ji(0)).select(i.z,n.z);const o=To(a.x,a.y,a.z).toVar();return Ol.add(s.mul(o)).toVar().sub(r)})),QT=ki((([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).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(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(la(r,r).sub(la(s,s)))),n}));var ZT=Object.freeze({__proto__:null,BRDF_GGX:Bp,BRDF_Lambert:bp,BasicPointShadowFilter:jb,BasicShadowFilter:Rb,Break:Jc,Const:ru,Continue:()=>Du("continue").toStack(),DFGApprox:Ip,D_GGX:Pp,Discard:Vu,EPSILON:Ia,F_Schlick:xp,Fn:ki,INFINITY:Da,If:Hi,Loop:Zc,NodeAccess:Os,NodeShaderStage:Ds,NodeType:Us,NodeUpdateType:Vs,PCFShadowFilter:Cb,PCFSoftShadowFilter:Mb,PI:Va,PI2:Ua,PointShadowFilter:qb,Return:()=>Du("return").toStack(),Schlick_to_F0:Vp,ScriptableNodeResources:Bx,ShaderNode:Li,Stack:$i,Switch:(...e)=>ni.Switch(...e),TBNViewMatrix:Bd,VSMShadowFilter:Pb,V_GGX_SmithCorrelated:Cp,Var:tu,abs:no,acesFilmicToneMapping:Tx,acos:so,add:oa,addMethodChaining:oi,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:Sx,all:Oa,alphaT:Rn,and:xa,anisotropy:Cn,anisotropyB:Pn,anisotropyT:Mn,any:ka,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),$i(e)),array:ea,arrayBuffer:e=>Bi(new si(e,"ArrayBuffer")),asin:ro,assign:ra,atan:io,atan2:$o,atomicAdd:(e,t)=>sb(tb.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>sb(tb.ATOMIC_AND,e,t),atomicFunc:sb,atomicLoad:e=>sb(tb.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>sb(tb.ATOMIC_MAX,e,t),atomicMin:(e,t)=>sb(tb.ATOMIC_MIN,e,t),atomicOr:(e,t)=>sb(tb.ATOMIC_OR,e,t),atomicStore:(e,t)=>sb(tb.ATOMIC_STORE,e,t),atomicSub:(e,t)=>sb(tb.ATOMIC_SUB,e,t),atomicXor:(e,t)=>sb(tb.ATOMIC_XOR,e,t),attenuationColor:Hn,attenuationDistance:zn,attribute:Hu,attributeArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=ws("float")):(r=As(t),s=ws(t));const i=new My(e,r,s);return qc(i,t,e)},backgroundBlurriness:Dy,backgroundIntensity:Vy,backgroundRotation:Uy,batch:Hc,billboarding:Qf,bitAnd:va,bitNot:Na,bitOr:Sa,bitXor:Ea,bitangentGeometry:Rd,bitangentLocal:Cd,bitangentView:Md,bitangentWorld:Pd,bitcast:xo,blendBurn:Yy,blendColor:ex,blendDodge:Qy,blendOverlay:Jy,blendScreen:Zy,blur:Dg,bool:Ki,buffer:tl,bufferAttribute:_u,bumpMap:Hd,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),Yy(e)),bvec2:Ji,bvec3:sn,bvec4:un,bypass:Pu,cache:Ru,call:ia,cameraFar:ul,cameraIndex:al,cameraNear:ol,cameraNormalMatrix:pl,cameraPosition:gl,cameraProjectionMatrix:ll,cameraProjectionMatrixInverse:dl,cameraViewMatrix:cl,cameraWorldMatrix:hl,cbrt:Lo,cdl:ux,ceil:Ya,checker:iT,cineonToneMapping:xx,clamp:Do,clearcoat:_n,clearcoatRoughness:vn,code:Ax,color:Wi,colorSpaceToWorking:hu,colorToDirection:e=>Bi(e).mul(2).sub(1),compute:wu,computeSkinning:(e,t=null)=>{const r=new Kc(e);return r.positionNode=qc(new F(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Lc).toVar(),r.skinIndexNode=qc(new F(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Lc).toVar(),r.skinWeightNode=qc(new F(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Lc).toVar(),r.bindMatrixNode=Zn(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=Zn(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=tl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,Bi(r)},cond:Ko,context:Qo,convert:pn,convertColorSpace:(e,t,r)=>Bi(new du(Bi(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():Ey(e,...t),cos:eo,cross:Ao,cubeTexture:gd,cubeTextureBase:pd,cubeToUV:Wb,dFdx:co,dFdy:ho,dashSize:Dn,debug:Gu,decrement:Pa,decrementBefore:Ca,defaultBuildStages:Gs,defaultShaderStages:ks,defined:Pi,degrees:za,deltaTime:qf,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),kx(e,Ox(t))},densityFogFactor:Ox,depth:Dh,depthPass:(e,t,r)=>Bi(new gx(gx.DEPTH,e,t,r)),difference:Eo,diffuseColor:yn,directPointLight:rT,directionToColor:tp,dispersion:$n,distance:So,div:da,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),Qy(e)),dot:wo,drawIndex:Vc,dynamicBufferAttribute:vu,element:hn,emissive:xn,equal:ha,equals:bo,equirectUV:np,exp:Ha,exp2:$a,expression:Du,faceDirection:Wl,faceForward:ko,faceforward:Wo,float:ji,floor:Ka,fog:kx,fract:Za,frameGroup:Xn,frameId:Xf,frontFacing:$l,fwidth:fo,gain:(e,t)=>e.lessThan(.5)?Of(e.mul(2),t).div(2):ua(1,Of(la(ua(1,e),2),t).div(2)),gapSize:Vn,getConstNodeType:Fi,getCurrentStack:zi,getDirection:Fg,getDistanceAttenuation:tT,getGeometryRoughness:Ap,getNormalFromDepth:Ry,getParallaxCorrectNormal:YT,getRoughness:Rp,getScreenPosition:Ay,getShIrradianceAt:QT,getShadowMaterial:Lb,getShadowRenderObjectFunction:Db,getTextureIndex:If,getViewPosition:wy,globalId:Kx,glsl:(e,t)=>Ax(e,t,"glsl"),glslFn:(e,t)=>Cx(e,t,"glsl"),grayscale:sx,greaterThan:ma,greaterThanEqual:ya,hash:Uf,highpModelNormalViewMatrix:Il,highpModelViewMatrix:Bl,hue:ax,increment:Ma,incrementBefore:Ra,instance:Oc,instanceIndex:Lc,instancedArray:(e,t="float")=>{let r,s;!0===t.isStruct?(r=t.layout.getLength(),s=ws("float")):(r=As(t),s=ws(t));const i=new Cy(e,r,s);return qc(i,t,e)},instancedBufferAttribute:Nu,instancedDynamicBufferAttribute:Su,instancedMesh:Gc,int:qi,inverseSqrt:Xa,inversesqrt:jo,invocationLocalIndex:Dc,invocationSubgroupIndex:Ic,ior:On,iridescence:En,iridescenceIOR:wn,iridescenceThickness:An,ivec2:Qi,ivec3:tn,ivec4:an,js:(e,t)=>Ax(e,t,"js"),label:Zo,length:oo,lengthSq:Bo,lessThan:ga,lessThanEqual:fa,lightPosition:ub,lightProjectionUV:ob,lightShadowMatrix:ab,lightTargetDirection:cb,lightTargetPosition:lb,lightViewPosition:db,lightingContext:uh,lights:(e=[])=>Bi(new mb).setLights(e),linearDepth:Vh,linearToneMapping:fx,localId:Yx,log:Wa,log2:ja,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(Wa(r.div(t)));return ji(Math.E).pow(s).mul(t).negate()},loop:(...e)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Zc(...e)),luminance:ox,mat2:ln,mat3:dn,mat4:cn,matcapUV:Sm,materialAO:Rc,materialAlphaTest:jd,materialAnisotropy:cc,materialAnisotropyVector:Cc,materialAttenuationColor:bc,materialAttenuationDistance:xc,materialClearcoat:nc,materialClearcoatNormal:oc,materialClearcoatRoughness:ac,materialColor:qd,materialDispersion:wc,materialEmissive:Kd,materialEnvIntensity:nd,materialEnvRotation:ad,materialIOR:yc,materialIridescence:hc,materialIridescenceIOR:pc,materialIridescenceThickness:gc,materialLightMap:Ac,materialLineDashOffset:Sc,materialLineDashSize:_c,materialLineGapSize:vc,materialLineScale:Tc,materialLineWidth:Nc,materialMetalness:sc,materialNormal:ic,materialOpacity:Yd,materialPointSize:Ec,materialReference:Td,materialReflectivity:tc,materialRefractionRatio:id,materialRotation:uc,materialRoughness:rc,materialSheen:lc,materialSheenRoughness:dc,materialShininess:Xd,materialSpecular:Qd,materialSpecularColor:Jd,materialSpecularIntensity:Zd,materialSpecularStrength:ec,materialThickness:fc,materialTransmission:mc,max:_o,maxMipLevel:Xu,mediumpModelViewMatrix:Ll,metalness:Tn,min:To,mix:Io,mixElement:zo,mod:ca,modInt:La,modelDirection:Sl,modelNormalMatrix:Ml,modelPosition:wl,modelRadius:Cl,modelScale:Al,modelViewMatrix:Fl,modelViewPosition:Rl,modelViewProjection:Mc,modelWorldMatrix:El,modelWorldMatrixInverse:Pl,morphReference:ih,mrt:Vf,mul:la,mx_aastep:qT,mx_cell_noise_float:(e=$u())=>PT(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ji(e).sub(r).mul(t).add(r),mx_fractal_noise_float:(e=$u(),t=3,r=2,s=.5,i=1)=>LT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec2:(e=$u(),t=3,r=2,s=.5,i=1)=>IT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec3:(e=$u(),t=3,r=2,s=.5,i=1)=>BT(e,qi(t),r,s).mul(i),mx_fractal_noise_vec4:(e=$u(),t=3,r=2,s=.5,i=1)=>DT(e,qi(t),r,s).mul(i),mx_hsvtorgb:$T,mx_noise_float:(e=$u(),t=1,r=0)=>CT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=$u(),t=1,r=0)=>MT(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=$u(),t=1,r=0)=>{e=e.convert("vec2|vec3");return nn(MT(e),CT(e.add(Yi(19,73)))).mul(t).add(r)},mx_ramplr:(e,t,r=$u())=>XT(e,t,r,"x"),mx_ramptb:(e,t,r=$u())=>XT(e,t,r,"y"),mx_rgbtohsv:WT,mx_safepower:(e,t=1)=>(e=ji(e)).abs().pow(t).mul(e.sign()),mx_splitlr:(e,t,r,s=$u())=>KT(e,t,r,s,"x"),mx_splittb:(e,t,r,s=$u())=>KT(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:jT,mx_transform_uv:(e=1,t=0,r=$u())=>r.mul(e).add(t),mx_worley_noise_float:(e=$u(),t=1)=>GT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec2:(e=$u(),t=1)=>zT(e.convert("vec2|vec3"),t,qi(1)),mx_worley_noise_vec3:(e=$u(),t=1)=>HT(e.convert("vec2|vec3"),t,qi(1)),namespace:Cu,negate:uo,neutralToneMapping:Ex,nodeArray:Di,nodeImmutable:Ui,nodeObject:Bi,nodeObjects:Ii,nodeProxy:Vi,normalFlat:Xl,normalGeometry:jl,normalLocal:ql,normalMap:Od,normalView:Kl,normalWorld:Yl,normalize:Qa,not:Ta,notEqual:pa,numWorkgroups:qx,objectDirection:yl,objectGroup:Yn,objectPosition:bl,objectRadius:vl,objectScale:Tl,objectViewPosition:_l,objectWorldMatrix:xl,oneMinus:lo,or:ba,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=jf)=>e.fract(),oscSine:(e=jf)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=jf)=>e.fract().round(),oscTriangle:(e=jf)=>e.add(.5).fract().mul(2).sub(1).abs(),output:In,outputStruct:Bf,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Jy(e)),overloadingFn:Wf,parabola:Of,parallaxDirection:Id,parallaxUV:(e,t)=>e.sub(Id.mul(t)),parameter:(e,t)=>Bi(new Rf(e,t)),pass:(e,t,r)=>Bi(new gx(gx.COLOR,e,t,r)),passTexture:(e,t)=>Bi(new hx(e,t)),pcurve:(e,t,r)=>Ro(da(Ro(e,t),oa(Ro(e,t),Ro(ua(1,e),r))),1/t),perspectiveDepthToViewZ:Lh,pmremTexture:um,pointShadow:Jb,pointUV:Fy,pointWidth:Un,positionGeometry:Dl,positionLocal:Vl,positionPrevious:Ul,positionView:Gl,positionViewDirection:zl,positionWorld:Ol,positionWorldDirection:kl,posterize:dx,pow:Ro,pow2:Co,pow3:Mo,pow4:Po,premult:tx,property:mn,radians:Ga,rand:Go,range:$x,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),kx(e,Ux(t,r))},rangeFogFactor:Ux,reciprocal:go,reference:yd,referenceBuffer:xd,reflect:No,reflectVector:ld,reflectView:od,reflector:e=>Bi(new yy(e)),refract:Uo,refractVector:dd,refractView:ud,reinhardToneMapping:yx,remainder:Fa,remap:Lu,remapClamp:Bu,renderGroup:Kn,renderOutput:Ou,rendererReference:fu,rotate:Rm,rotateUV:Kf,roughness:bn,round:po,rtt:Ey,sRGBTransferEOTF:ou,sRGBTransferOETF:uu,sampler:e=>(!0===e.isNode?e:Zu(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Zu(e)).convert("samplerComparison"),saturate:Vo,saturation:ix,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),Zy(e)),screenCoordinate:mh,screenSize:gh,screenUV:ph,scriptable:Dx,scriptableValue:Px,select:Xo,setCurrentStack:Gi,shaderStages:zs,shadow:Hb,shadowPositionWorld:yb,shapeCircle:nT,sharedUniformGroup:qn,sheen:Nn,sheenRoughness:Sn,shiftLeft:wa,shiftRight:Aa,shininess:Bn,sign:ao,sin:Ja,sinc:(e,t)=>Ja(Va.mul(t.mul(e).sub(1))).div(Va.mul(t.mul(e).sub(1))),skinning:Yc,smoothstep:Oo,smoothstepElement:Ho,specularColor:Fn,specularF90:Ln,spherizeUV:Yf,split:(e,t)=>Bi(new Zs(Bi(e),t)),spritesheetUV:ey,sqrt:qa,stack:Mf,step:vo,storage:qc,storageBarrier:()=>Zx("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),qc(e,t,r).setPBO(!0)),storageTexture:ky,string:(e="")=>Bi(new si(e,"string")),struct:(e,t=null)=>{const r=new Pf(e,t),s=(...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eZx("texture").toStack(),textureBicubic:rg,textureCubeUV:Lg,textureLoad:Ju,textureSize:ju,textureStore:(e,t,r)=>{const s=ky(e,t,r);return null!==r&&s.toStack(),s},thickness:Gn,time:jf,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),qf.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),jf.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),jf.mul(e)),toneMapping:xu,toneMappingExposure:bu,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>Bi(new mx(t,r,Bi(s),Bi(i),Bi(n))),transformDirection:Fo,transformNormal:ed,transformNormalToView:td,transformedBentNormalView:Dd,transformedBitangentView:Fd,transformedBitangentWorld:Ld,transformedClearcoatNormalView:Jl,transformedNormalView:Ql,transformedNormalWorld:Zl,transformedTangentView:Ed,transformedTangentWorld:wd,transmission:kn,transpose:yo,triNoise3D:zf,triplanarTexture:(...e)=>ry(...e),triplanarTextures:ry,trunc:mo,tslFn:(...e)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),ki(...e)),uint:Xi,uniform:Zn,uniformArray:il,uniformCubeTexture:(e=cd)=>pd(e),uniformGroup:jn,uniformTexture:(e=Ku)=>Zu(e),uniforms:(e,t)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),Bi(new sl(e,t))),unpremult:rx,userData:(e,t,r)=>Bi(new $y(e,t,r)),uv:$u,uvec2:Zi,uvec3:rn,uvec4:on,varying:nu,varyingProperty:fn,vec2:Yi,vec3:en,vec4:nn,vectorComponents:Hs,velocity:Ky,vertexColor:$h,vertexIndex:Fc,vertexStage:au,vibrance:nx,viewZToLogarithmicDepth:Bh,viewZToOrthographicDepth:Ph,viewZToPerspectiveDepth:Fh,viewport:fh,viewportBottomLeft:vh,viewportCoordinate:xh,viewportDepthTexture:Ch,viewportLinearDepth:Uh,viewportMipTexture:wh,viewportResolution:Th,viewportSafeUV:Zf,viewportSharedTexture:Zh,viewportSize:yh,viewportTexture:Eh,viewportTopLeft:_h,viewportUV:bh,wgsl:(e,t)=>Ax(e,t,"wgsl"),wgslFn:(e,t)=>Cx(e,t,"wgsl"),workgroupArray:(e,t)=>Bi(new eb("Workgroup",e,t)),workgroupBarrier:()=>Zx("workgroup").toStack(),workgroupId:Xx,workingToColorSpace:cu,xor:_a});const JT=new Af;class e_ extends qm{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(JT),JT.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(JT),JT.a=1,n=!0;else if(!0===i.isNode){const o=this.get(e),u=i;JT.copy(s._clearColor);let l=o.backgroundMesh;if(void 0===l){const c=Qo(nn(u).mul(Vy),{getUV:()=>Uy.mul(Yl),getTextureLevel:()=>Dy});let h=Mc;h=h.setZ(h.w);const p=new Wh;function g(){i.removeEventListener("dispose",g),l.material.dispose(),l.geometry.dispose()}p.name="Background.material",p.side=S,p.depthTest=!1,p.depthWrite=!1,p.allowOverride=!1,p.fog=!1,p.lights=!1,p.vertexNode=h,p.colorNode=c,o.backgroundMeshNode=c,o.backgroundMesh=l=new q(new Oe(1,32,32),p),l.frustumCulled=!1,l.name="Background.mesh",l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},i.addEventListener("dispose",g)}const d=u.getCacheKey();o.backgroundCacheKey!==d&&(o.backgroundMeshNode.node=nn(u).mul(Vy),o.backgroundMeshNode.needsUpdate=!0,l.material.needsUpdate=!0,o.backgroundCacheKey=d),t.unshift(l,l.geometry,l.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?JT.set(0,0,0,1):"alpha-blend"===a&&JT.set(0,0,0,0),!0===s.autoClear||!0===n){const m=r.clearColorValue;m.r=JT.r,m.g=JT.g,m.b=JT.b,m.a=JT.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(m.r*=m.a,m.g*=m.a,m.b*=m.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let t_=0;class r_{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=t_++}}class s_{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new r_(t.name,[],t.index,t);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class i_{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class n_{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class a_{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class o_ extends a_{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class u_{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let l_=0;class d_{constructor(e=null){this.id=l_++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class c_{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class h_{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class p_ extends h_{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class g_ extends h_{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class m_ extends h_{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class f_ extends h_{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class y_ extends h_{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class x_ extends h_{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class b_ extends h_{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class T_ extends h_{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class __ extends p_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class v_ extends g_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class N_ extends m_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class S_ extends f_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class E_ extends y_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class w_ extends x_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class A_ extends b_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class R_ extends T_{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const C_=new WeakMap,M_=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),P_=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class F_{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mf(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new d_,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null}getBindGroupsCache(){let e=C_.get(this.renderer);return void 0===e&&(e=new zm,C_.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new oe(e,t,r)}createCubeRenderTarget(e,t){return new ap(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let i,n=!0;for(const e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?(i=r.get(s),void 0===i&&(i=new r_(e,s,this.bindingsIndexes[e].group,s),r.set(s,i))):i=new r_(e,s,this.bindingsIndexes[e].group,s),i}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of zs)for(const s in r[e]){const i=r[e][s];(t[s]||(t[s]=[])).push(...i)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort(((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order));for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${P_(n.r)}, ${P_(n.g)}, ${P_(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new i_(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===_)return"int";if(t===T)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=Es(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return M_.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof ze||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Mf(this.stack),this.stacks.push(zi()||this.stack),Gi(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Gi(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);return void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={}),s[t]}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(void 0===s){const i=this.uniforms.index++;s=new i_("nodeAttribute"+i,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const e=this.structs.index++;null===r&&(r="StructType"+e),n=new c_(r,t),this.structs[s].push(n),i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new n_(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getArrayCount(e){let t=null;return e.isArrayNode?t=e.count:e.isVarNode&&e.node.isArrayNode&&(t=e.node.count),t}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s);let a=n.variable;if(void 0===a){const o=i?"_const":"_var",u=this.vars[s]||(this.vars[s]=[]),l=this.vars[o]||(this.vars[o]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+l,this.vars[o]++);const d=this.getArrayCount(e);a=new a_(t,r,i,d),i||u.push(a),this.registerDeclaration(a),n.variable=a}return a}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any");let a=n.varying;if(void 0===a){const e=this.varyings,o=e.length;null===t&&(t="nodeVarying"+o),a=new o_(t,r,s,i),e.push(a),this.registerDeclaration(a),n.varying=a}return a}get namespace(){return this.context.namespace}getOutputNamespace(){return this.getNamespace("outputNode")}getNamespace(e=""){const t=this.namespace;let r;return r=t?e?t+"_"+e:t:e,r}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new u_("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new Rx,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new Rf(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new d_,this.stack=Mf();for(const r of Gs)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(void 0!==r)for(const e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new Wh),e.build(this)}else this.addFlow("compute",e);for(const e of Gs){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of zs){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new __(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new v_(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new N_(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new S_(e);if("color"===t)return new E_(e);if("mat2"===t)return new w_(e);if("mat3"===t)return new A_(e);if("mat4"===t)return new R_(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${He} - Node System\n`}*[Symbol.iterator](){}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class L_{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Vs.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===Vs.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===Vs.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class B_{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}B_.isNodeFunctionInput=!0;class I_ extends eT{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:cb(this.light),lightColor:e}}}const D_=new a,V_=new a;let U_=null;class O_ extends eT{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Zn(new r).setGroup(Kn),this.halfWidth=Zn(new r).setGroup(Kn),this.updateType=Vs.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;V_.identity(),D_.copy(t.matrixWorld),D_.premultiply(r),V_.extractRotation(D_),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(V_),this.halfHeight.value.applyMatrix4(V_)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Zu(U_.LTC_FLOAT_1),r=Zu(U_.LTC_FLOAT_2)):(t=Zu(U_.LTC_HALF_1),r=Zu(U_.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:db(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){U_=e}}class k_ extends eT{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Zn(0).setGroup(Kn),this.penumbraCosNode=Zn(0).setGroup(Kn),this.cutoffDistanceNode=Zn(0).setGroup(Kn),this.decayExponentNode=Zn(0).setGroup(Kn),this.colorNode=Zn(this.color).setGroup(Kn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Oo(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=ob(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(cb(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=tT({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Zu(i.map,h.xy).onRenderUpdate((()=>i.map))),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class G_ extends k_{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);s=Zu(r,Yi(e,0),0).r}else s=super.getSpotAttenuation(t);return s}}const z_=ki((([e,t])=>{const r=e.abs().sub(t);return oo(_o(r,0)).add(To(_o(r.x,r.y),0))}));class H_ extends k_{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=this.penumbraCosNode,r=this.getLightCoord(e),s=r.xyz.div(r.w),i=z_(s.xy.sub(Yi(.5)),Yi(.5)),n=da(-1,ua(1,so(t)).sub(1));return Vo(i.mul(-2).mul(n))}}class $_ extends eT{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class W_ extends eT{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=ub(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Zn(new e).setGroup(Kn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Yl.dot(s).mul(.5).add(.5),n=Io(r,t,i);e.context.irradiance.addAssign(n)}}class j_ extends eT{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=il(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=QT(Yl,this.lightProbe);e.context.irradiance.addAssign(t)}}class q_{parseFunction(){console.warn("Abstract function.")}}class X_{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){console.warn("Abstract function.")}}X_.isNodeFunction=!0;const K_=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,Y_=/[a-z_0-9]+/gi,Q_="#pragma main";class Z_ extends X_{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(Q_),r=-1!==t?e.slice(t+12):e,s=r.match(K_);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=Y_.exec(i));)n.push(a);const o=[];let u=0;for(;u0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,(()=>{if(!0===r.isCubeTexture||r.mapping===Q||r.mapping===Z||r.mapping===ce){if(e.backgroundBlurriness>0||r.mapping===ce)return um(r);{let e;return e=!0===r.isCubeTexture?gd(r):Zu(r),cp(e)}}if(!0===r.isTexture)return Zu(r,ph.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)}),s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,(()=>{if(r.isFogExp2){const e=yd("color","color",r).setGroup(Kn),t=yd("density","float",r).setGroup(Kn);return kx(e,Ox(t))}if(r.isFog){const e=yd("color","color",r).setGroup(Kn),t=yd("near","float",r).setGroup(Kn),s=yd("far","float",r).setGroup(Kn);return kx(e,Ux(t,s))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}));t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,(()=>!0===r.isCubeTexture?gd(r):!0===r.isTexture?Zu(r):void console.error("Nodes: Unsupported environment configuration.",r)));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return ev.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?Hy(e,en(ph,nl("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Zu(e,ph).renderOutput(t.toneMapping,t.currentColorSpace);return ev.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new L_,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iv=new Me;class nv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,s,r);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new pv(i.framebufferWidth,i.framebufferHeight,{format:le,type:Ce,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),n.layers.mask=2|e.layers.mask,a.layers.mask=4|e.layers.mask,i.layers.mask=n.layers.mask|a.layers.mask;const o=e.parent,u=i.cameras;yv(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function _v(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function vv(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views;null!==this._glBaseLayer&&n.setXRTarget(a.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new sv(this,r),this._animation=new Gm(this._nodes,this.info),this._attributes=new Jm(r),this._background=new e_(this,this._nodes),this._geometries=new rf(this._attributes,this.info),this._textures=new wf(this,r,this.info),this._pipelines=new df(r,this._nodes),this._bindings=new cf(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new jm(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new yf(this.lighting),this._bundles=new uv,this._renderContexts=new Sf,this._animation.start(),this._initialized=!0,e(this)}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,u=!0===e.isScene?e:Nv;null===r&&(r=e);const l=this._renderTarget,d=this._renderContexts.get(r,t,l),c=this._activeMipmapLevel,h=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=h,s.renderId++,s.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new nv),d.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(u,p,d);const g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,u,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,u,y),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(h)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=Bl,this.overrideNodes.modelNormalViewMatrix=Il):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Bl&&this.overrideNodes.modelNormalViewMatrix===Il}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i),u=this.backend.get(o);void 0===u.renderContexts&&(u.renderContexts=new Set);const l=s.version!==u.version,d=!1===u.renderContexts.has(a)||l;if(u.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=b,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(Ev),p.scissorValue.copy(y).multiplyScalar(x).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(Ev),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new nv),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?Av:wv;t.isArrayCamera||(Rv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(Rv,g));const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==h){this._textures.updateRenderTarget(h,c);const e=this._textures.get(h);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=h,p.depth=h.depthBuffer,p.stencil=h.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=d,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);const{bundles:N,lightsNode:S,transparentDoublePass:E,transparent:w,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,u,S),this.backend.finishRender(p),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,null!==s&&(this.setRenderTarget(l,d,c),this._renderOutput(h)),u.onAfterRender(this,e,t,h),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,r,s){const i=this._scissor;e.isVector4?i.copy(e):i.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,i=0,n=1){const a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,s),a.minDepth=i,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.getForClear(s),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer,i.clearColorValue=this.backend.getClearColor(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ue}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach((e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,r=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const s=this.backend,i=this._pipelines,n=this._bindings,a=this._nodes,o=Array.isArray(e)?e:[e];if(void 0===o[0]||!0!==o[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const t of o){if(!1===i.has(t)){const e=()=>{t.removeEventListener("dispose",e),i.delete(t),n.delete(t),a.delete(t)};t.addEventListener("dispose",e);const r=t.onInitFunction;null!==r&&r.call(t,{renderer:this})}a.updateForCompute(t),n.updateForCompute(t);const r=n.getForCompute(t),o=i.getForCompute(t,r);s.compute(e,t,r,o)}s.finishCompute(e),t.renderId=r}async computeAsync(e){!1===this._initialized&&await this.init(),this.compute(e)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=Cv.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=Cv.copy(t).floor()}else t=Cv.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?Av:wv;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&Cv.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Rv);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,Cv.z,null,i)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?Av:wv;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),Cv.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Rv)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=S;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=je;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=Se}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n0,e.isShadowPassMaterial&&(e.side=null===i.shadowSide?i.side:i.shadowSide,i.depthNode&&i.depthNode.isNode&&(c=e.depthNode,e.depthNode=i.depthNode),i.castShadowNode&&i.castShadowNode.isNode&&(d=e.colorNode,e.colorNode=i.castShadowNode),i.castShadowPositionNode&&i.castShadowPositionNode.isNode&&(l=e.positionNode,e.positionNode=i.castShadowPositionNode)),i=e}!0===i.transparent&&i.side===Se&&!1===i.forceSinglePass?(i.side=S,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=je,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=Se):this._handleObjectFunction(e,i,t,r,a,n,o,u),void 0!==l&&(t.overrideMaterial.positionNode=l),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==d&&(t.overrideMaterial.colorNode=d),e.onAfterRender(this,t,r,s,i,n)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n;const l=this._nodes.needsRefresh(u);if(l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}get compile(){return this.compileAsync}}class Pv{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class Fv extends Pv{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return(e=this._buffer.byteLength)+(Zm-e%Zm)%Zm;var e}get buffer(){return this._buffer}update(){return!0}}class Lv extends Fv{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Bv=0;class Iv extends Lv{constructor(e,t){super("UniformBuffer_"+Bv++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Dv extends Lv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?s:"";t=`${e.name} {\n\t${r} ${i.name}[${n}];\n};\n`}else{t=`${this.getVectorType(i.type)} ${this.getPropertyName(i,e)};`,n=!0}const a=i.node.precision;if(null!==a&&(t=Wv[a]+" "+t),n){t="\t"+t;const e=i.groupNode.name;(s[e]||(s[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let i="";for(const t in s){const r=s[t];i+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==_){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===s.length&&s.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${qv[s.interpolationType]||s.interpolationType} ${Xv[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${qv[e.interpolationType]||e.interpolationType} ${Xv[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce(((e,t)=>e*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=jv[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}jv[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${s.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${s.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new Gv(i.name,i.node,s),u.push(a);else if("cubeTexture"===t)a=new zv(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new Hv(i.name,i.node,s),u.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,i.name=`buffer${e.id}`;const t=new Iv(e,s);t.name=e.name,u.push(t),a=t}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let n=e[o];void 0===n&&(n=new Uv(r+"_"+o,s),e[o]=n,u.push(n)),a=this.getNodeUniform(i,t),n.addUniform(a)}n.uniformGPU=a}return i}}let Qv=null,Zv=null;class Jv{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void pt("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return void pt(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Qv=Qv||new t,this.renderer.getDrawingBufferSize(Qv)}setScissorTest(){}getClearColor(){const e=this.renderer;return Zv=Zv||new Af,e.getClearColor(Zv),Zv.getRGB(Zv),Zv}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:gt(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${He} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let eN,tN,rN=0;class sN{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class iN{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===_,id:rN++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new sN(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()}))}}let oN,uN,lN,dN=!1;class cN{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===dN&&(this._init(),dN=!0)}_init(){const e=this.gl;oN={[Nr]:e.REPEAT,[vr]:e.CLAMP_TO_EDGE,[_r]:e.MIRRORED_REPEAT},uN={[v]:e.NEAREST,[Sr]:e.NEAREST_MIPMAP_NEAREST,[Ge]:e.NEAREST_MIPMAP_LINEAR,[K]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[D]:e.LINEAR_MIPMAP_LINEAR},lN={[Pr]:e.NEVER,[Mr]:e.ALWAYS,[De]:e.LESS,[Cr]:e.LEQUAL,[Rr]:e.EQUAL,[Ar]:e.GEQUAL,[wr]:e.GREATER,[Er]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i=!1){const{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){const e=i?Fr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){const e=i?Fr:c.getTransfer(s);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===h?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),o!==n.R16F&&o!==n.R32F&&o!==n.RG16F&&o!==n.RG32F&&o!==n.RGBA16F&&o!==n.RGBA32F||a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,n=c.getPrimaries(c.workingColorSpace),a=t.colorSpace===x?null:c.getPrimaries(t.colorSpace),o=t.colorSpace===x||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,oN[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,oN[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,oN[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,uN[t.magFilter]);const u=void 0!==t.mipmaps&&t.mipmaps.length>0,l=t.minFilter===K&&u?D:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,uN[l]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,lN[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===v)return;if(t.minFilter!==Ge&&t.minFilter!==D)return;if(t.type===B&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i,isDefault:!0})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:i,glTextureType:n,glFormat:a,glType:o}=s.get(t),{width:u,height:l}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(n,i),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,l,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}}function hN(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class pN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class gN{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const mN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fN{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e.id);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[t,r]of this.queryStates)if("ended"===r){const r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;const t=(await Promise.all(e)).reduce(((e,t)=>e+t),0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise((t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()}))}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}const bN=new t;class TN extends Jv{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new pN(this),this.capabilities=new gN(this),this.attributeUtils=new iN(this),this.textureUtils=new cN(this),this.bufferRenderer=new fN(this),this.state=new nN(this),this.utils=new aN(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return l}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new xN(this.gl,t,2048));const r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;const t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize(bN);t.viewport(0,0,e,r)}if(e.scissor){const{x:r,y:s,width:i,height:n}=e.scissorValue;t.scissor(r,e.height-n-s,i,n)}this.initTimestampQuery(e),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e0&&!1===this._useMultisampledExtension(o)){const i=s.framebuffers[e.getCacheKey()];let n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));const a=s.msaaFrameBuffer,u=s.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),d)for(let e=0;e{let a=0;for(let t=0;t{t.isBatchedMesh?null!==t._multiDrawInstances?(pt("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),y.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?y.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):pt("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):b>1?y.renderInstances(T,x,b):y.render(T,x)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()}));t.push(i)}else this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=s.getProgramInfoLog(e).trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&console.warn("THREE.WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;emN[t]===e)),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(i),b=Tf(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[b]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[b]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[b]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}else{n.framebuffers[b]=T;for(let r=0;r0&&!1===x&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const _N="point-list",vN="line-list",NN="line-strip",SN="triangle-list",EN="triangle-strip",wN="never",AN="less",RN="equal",CN="less-equal",MN="greater",PN="not-equal",FN="greater-equal",LN="always",BN="store",IN="load",DN="clear",VN="ccw",UN="none",ON="front",kN="back",GN="uint16",zN="uint32",HN="r8unorm",$N="r8snorm",WN="r8uint",jN="r8sint",qN="r16uint",XN="r16sint",KN="r16float",YN="rg8unorm",QN="rg8snorm",ZN="rg8uint",JN="rg8sint",eS="r32uint",tS="r32sint",rS="r32float",sS="rg16uint",iS="rg16sint",nS="rg16float",aS="rgba8unorm",oS="rgba8unorm-srgb",uS="rgba8snorm",lS="rgba8uint",dS="rgba8sint",cS="bgra8unorm",hS="bgra8unorm-srgb",pS="rgb9e5ufloat",gS="rgb10a2unorm",mS="rgb10a2unorm",fS="rg32uint",yS="rg32sint",xS="rg32float",bS="rgba16uint",TS="rgba16sint",_S="rgba16float",vS="rgba32uint",NS="rgba32sint",SS="rgba32float",ES="depth16unorm",wS="depth24plus",AS="depth24plus-stencil8",RS="depth32float",CS="depth32float-stencil8",MS="bc1-rgba-unorm",PS="bc1-rgba-unorm-srgb",FS="bc2-rgba-unorm",LS="bc2-rgba-unorm-srgb",BS="bc3-rgba-unorm",IS="bc3-rgba-unorm-srgb",DS="bc4-r-unorm",VS="bc4-r-snorm",US="bc5-rg-unorm",OS="bc5-rg-snorm",kS="bc6h-rgb-ufloat",GS="bc6h-rgb-float",zS="bc7-rgba-unorm",HS="bc7-rgba-srgb",$S="etc2-rgb8unorm",WS="etc2-rgb8unorm-srgb",jS="etc2-rgb8a1unorm",qS="etc2-rgb8a1unorm-srgb",XS="etc2-rgba8unorm",KS="etc2-rgba8unorm-srgb",YS="eac-r11unorm",QS="eac-r11snorm",ZS="eac-rg11unorm",JS="eac-rg11snorm",eE="astc-4x4-unorm",tE="astc-4x4-unorm-srgb",rE="astc-5x4-unorm",sE="astc-5x4-unorm-srgb",iE="astc-5x5-unorm",nE="astc-5x5-unorm-srgb",aE="astc-6x5-unorm",oE="astc-6x5-unorm-srgb",uE="astc-6x6-unorm",lE="astc-6x6-unorm-srgb",dE="astc-8x5-unorm",cE="astc-8x5-unorm-srgb",hE="astc-8x6-unorm",pE="astc-8x6-unorm-srgb",gE="astc-8x8-unorm",mE="astc-8x8-unorm-srgb",fE="astc-10x5-unorm",yE="astc-10x5-unorm-srgb",xE="astc-10x6-unorm",bE="astc-10x6-unorm-srgb",TE="astc-10x8-unorm",_E="astc-10x8-unorm-srgb",vE="astc-10x10-unorm",NE="astc-10x10-unorm-srgb",SE="astc-12x10-unorm",EE="astc-12x10-unorm-srgb",wE="astc-12x12-unorm",AE="astc-12x12-unorm-srgb",RE="clamp-to-edge",CE="repeat",ME="mirror-repeat",PE="linear",FE="nearest",LE="zero",BE="one",IE="src",DE="one-minus-src",VE="src-alpha",UE="one-minus-src-alpha",OE="dst",kE="one-minus-dst",GE="dst-alpha",zE="one-minus-dst-alpha",HE="src-alpha-saturated",$E="constant",WE="one-minus-constant",jE="add",qE="subtract",XE="reverse-subtract",KE="min",YE="max",QE=0,ZE=15,JE="keep",ew="zero",tw="replace",rw="invert",sw="increment-clamp",iw="decrement-clamp",nw="increment-wrap",aw="decrement-wrap",ow="storage",uw="read-only-storage",lw="write-only",dw="read-only",cw="read-write",hw="non-filtering",pw="comparison",gw="float",mw="unfilterable-float",fw="depth",yw="sint",xw="uint",bw="2d",Tw="3d",_w="2d",vw="2d-array",Nw="cube",Sw="3d",Ew="all",ww="vertex",Aw="instance",Rw={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class Cw extends Pv{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.isSampler=!0}}class Mw extends Cw{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class Pw extends Fv{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let Fw=0;class Lw extends Pw{constructor(e,t){super("StorageBuffer_"+Fw++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Os.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Bw extends qm{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:PE}),this.flipYSampler=e.createSampler({minFilter:FE}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:"\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:EN,stripIndexFormat:zN},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:EN,stripIndexFormat:zN},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size,a=this.getTransferPipeline(s),o=this.getFlipYPipeline(s),u=this.device.createTexture({size:{width:i,height:n,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:r}),d=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),h=(e,t,r)=>{const s=e.getBindGroupLayout(0),i=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:r,loadOp:DN,storeOp:BN,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,i),n.draw(4,1,0,0),n.end()};h(a,l,d),h(o,d,l),this.device.queue.submit([c.finish()]),u.destroy()}generateMipmaps(e,t,r=0){const s=this.get(e);void 0===s.useCount&&(s.useCount=0,s.layers=[]);const i=s.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,i),this.device.queue.submit([n.finish()]),0!==s.useCount&&(s.layers[r]=i),s.useCount++}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),i=s.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:_w,baseArrayLayer:r});const a=[];for(let o=1;o1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,kw=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,Gw={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class zw extends X_{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(Ow);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=kw.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Hw extends q_{parseFunction(e){return new zw(e)}}const $w="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Ww={[Os.READ_ONLY]:"read",[Os.WRITE_ONLY]:"write",[Os.READ_WRITE]:"read_write"},jw={[Nr]:"repeat",[vr]:"clamp",[_r]:"mirror"},qw={vertex:$w?$w.VERTEX:1,fragment:$w?$w.FRAGMENT:2,compute:$w?$w.COMPUTE:4},Xw={instance:!0,swizzleAssign:!1,storageBuffer:!0},Kw={"^^":"tsl_xor"},Yw={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},Qw={},Zw={tsl_xor:new wx("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new wx("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new wx("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new wx("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new wx("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new wx("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new wx("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new wx("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new wx("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new wx("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new wx("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 wx("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new wx("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},Jw={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};"undefined"!=typeof navigator&&/Windows/g.test(navigator.userAgent)&&(Zw.pow_float=new wx("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),Zw.pow_vec2=new wx("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 ) ); }",[Zw.pow_float]),Zw.pow_vec3=new wx("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 ) ); }",[Zw.pow_float]),Zw.pow_vec4=new wx("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 ) ); }",[Zw.pow_float]),Jw.pow_float="tsl_pow_float",Jw.pow_vec2="tsl_pow_vec2",Jw.pow_vec3="tsl_pow_vec3",Jw.pow_vec4="tsl_pow_vec4");let eA="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(eA+="diagnostic( off, derivative_uniformity );\n");class tA extends F_{constructor(e,t){super(e,t,new Hw),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==x}_generateTextureSample(e,t,r,s,i=this.shaderStage){return"fragment"===i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this._generateTextureSampleLevel(e,t,r,"0",s)}_generateVideoSample(e,t,r=this.shaderStage){if("fragment"===r)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${r} shader.`)}_generateTextureSampleLevel(e,t,r,s,i){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,s):this.generateTextureLod(e,t,r,i,s)}generateWrapFunction(e){const t=`tsl_coord_${jw[e.wrapS]}S_${jw[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=Qw[t];if(void 0===r){const s=[],i=e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===Nr?(s.push(Zw.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===vr?(s.push(Zw.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===_r?(s.push(Zw.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",Qw[t]=r=new wx(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.isData3DTexture?"vec3":"vec2",n=u||e.isVideoTexture||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Jo(new Iu(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Jo(new Iu(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Jo(new Iu("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s="0u"){this._include("biquadraticTexture");return`tsl_biquadraticTexture( ${t}, ${this.generateWrapFunction(e)}( ${r} ), ${this.generateTextureDimension(e,t,s)}, u32( ${s} ) )`}generateTextureLod(e,t,r,s,i="0u"){const n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,i),o=e.isData3DTexture?"vec3":"vec2",u=`${o}( ${n}( ${r} ) * ${o}( ${a} ) )`;return this.generateTextureLoad(e,t,u,s,i)}generateTextureLoad(e,t,r,s,i="0u"){let n;return!0===e.isVideoTexture?n=`textureLoad( ${t}, ${r} )`:s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===B||!1===this.isSampleCompare(e)&&e.minFilter===v&&e.magFilter===v||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,r,i):this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,"0",i):this._generateTextureSample(e,t,r,s,i),n}generateTextureGrad(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,s,i,n=this.shaderStage){let a=null;return a=!0===e.isVideoTexture?this._generateVideoSample(t,r,n):this._generateTextureSampleLevel(e,t,r,s,i),a}generateTextureBias(e,t,r,s,i,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=Kw[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?Os.READ_ONLY:e.access}getStorageAccess(e,t){return Ww[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?s=new Gv(i.name,i.node,o,n):"cubeTexture"===t?s=new zv(i.name,i.node,o,n):"texture3D"===t&&(s=new Hv(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.setVisibility(qw[r]),!1===this.isUnfilterable(e.value)&&!1===s.store){const e=new Mw(`${i.name}_sampler`,i.node,o);e.setVisibility(qw[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=new("buffer"===t?Iv:Lw)(e,o);n.setVisibility(qw[r]),l.push(n),a=n,i.name=s||"NodeBuffer_"+i.id}else{const e=this.uniformGroups[r]||(this.uniformGroups[r]={});let s=e[u];void 0===s&&(s=new Uv(u,o),s.setVisibility(qw[r]),e[u]=s,l.push(s)),a=this.getNodeUniform(i,t),s.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let s=`var ${t} : `;return s+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(void 0!==r)for(const e of r)t.push(`\t${this.getVar(e.type,e.name,e.count)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];for(let i=0;ir.value.itemSize;return s&&!i}getUniforms(e){const t=this.uniforms[e],r=[],s=[],i=[],n={};for(const i of t){const t=i.groupNode.name,a=this.bindingsIndexes[t];if("texture"===i.type||"cubeTexture"===i.type||"storageTexture"===i.type||"texture3D"===i.type){const t=i.node.value;let s;!1===this.isUnfilterable(t)&&!0!==i.node.isStorageTextureNode&&(this.isSampleCompare(t)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name}_sampler : sampler;`));let n="";const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(t);if(o>1&&(n="_multisampled"),!0===t.isCubeTexture)s="texture_cube";else if(!0===t.isDepthTexture)s=this.renderer.backend.compatibilityMode&&null===t.compareFunction?`texture${n}_2d`:`texture_depth${n}_2d${!0===t.isArrayTexture?"_array":""}`;else if(!0===t.isArrayTexture||!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)s="texture_2d_array";else if(!0===t.isVideoTexture)s="texture_external";else if(!0===t.isData3DTexture)s="texture_3d";else if(!0===i.node.isStorageTextureNode){s=`texture_storage_2d<${Uw(t)}, ${this.getStorageAccess(i.node,e)}>`}else{s=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${i.name} : ${s};`)}else if("buffer"===i.type||"storageBuffer"===i.type||"indirectStorageBuffer"===i.type){const t=i.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===i.type?", "+n:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(i))s.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${u}> ${i.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${o} >`;s.push(this._getWGSLStructBinding(i.name,e,u,a.binding++,a.group))}}else{const e=this.getType(this.getVectorType(i.type)),t=i.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`\t${i.name} : ${e}`)}}for(const e in n){const t=n[e];i.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=s.join("\n"),a+=i.join("\n"),a}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];const i=this.flowNodes[t],n=i[i.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(const e of i){const i=this.getFlowData(e),u=e.name;if(u&&(s.length>0&&(s+="\n"),s+=`\t// flow -> ${u}\n`),s+=`${i.code}\n\t`,e===n&&"compute"!==t)if(s+="// result\n\n\t","vertex"===t)s+=`varyings.Vertex = ${i.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var output : "+r.returnType+";",s+=`return ${i.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar output : OutputStruct;",s+=`output.color = ${i.result};\n\n\treturn output;`}}r.flow=s}this.shaderStage=null,null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getType(e){return Yw[e]||e}isAvailable(e){let t=Xw[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),Xw[e]=t),t}_getWGSLMethod(e){return void 0!==Zw[e]&&this._include(e),Jw[e]}_include(e){const t=Zw[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${eA}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = globalId.x + globalId.y * numWorkgroups.x * u32(${t}) + globalId.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}class rA{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=AS:e.depth&&(t=wS),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?_N:e.isLineSegments||e.isMesh&&!0===t.wireframe?vN:e.isLine?NN:e.isMesh?SN:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ce)return cS;if(e===de)return _S;throw new Error("Unsupported outputType")}}const sA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),iA=new Map([[ze,["float16"]]]),nA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class aA{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e1&&(s.multisampled=!0,r.texture.isDepthTexture||(s.sampleType=mw)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?s.sampleType=mw:s.sampleType=fw;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const e=r.texture.type;e===_?s.sampleType=yw:e===T?s.sampleType=xw:e===B&&(this.backend.hasFeature("float32-filterable")?s.sampleType=gw:s.sampleType=mw)}r.isSampledCubeTexture?s.viewDimension=Nw:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?s.viewDimension=vw:r.isSampledTexture3D&&(s.viewDimension=Sw),e.texture=s}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);s.push(e)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:i,bindGroupLayoutCache:n}=this,a=i.get(e);let o,u=n.get(e.bindingsReference);void 0===u&&(u=this.createBindingsLayout(e),n.set(e.bindingsReference,u)),r>0&&(void 0===a.groups&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(o=a.groups[r])),void 0===o&&(o=this.createBindGroup(e,u),r>0&&(a.groups[r]=o,a.versions[r]=s)),a.group=o,a.layout=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+i,size:16,usage:s});r.queue.writeBuffer(n,0,e,0);const a=[{binding:0,resource:{buffer:n}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+i,layout:t,entries:a})}createBindGroup(e,t){const r=this.backend,s=r.device;let i=0;const n=[];for(const t of e.bindings){if(t.isUniformBuffer){const e=r.get(t);if(void 0===e.buffer){const r=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=s.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:i});e.buffer=n}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){const e=r.get(t);if(void 0===e.buffer){const s=t.attribute;e.buffer=r.get(s).buffer}n.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){const e=r.get(t.texture);n.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){const e=r.get(t.texture);let a;if(void 0!==e.externalTexture)a=s.importExternalTexture({source:e.externalTexture});else{const r=t.store?1:e.texture.mipLevelCount,s=`view-${e.texture.width}-${e.texture.height}-${r}`;if(a=e[s],void 0===a){const i=Ew;let n;n=t.isSampledCubeTexture?Nw:t.isSampledTexture3D?Sw:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?vw:_w,a=e[s]=e.texture.createView({aspect:i,dimension:n,mipLevelCount:r})}}n.push({binding:i,resource:a})}i++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class uA{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:o}=n,u=this.backend,l=u.device,d=u.utils,c=u.get(n),h=[];for(const t of e.getBindings()){const e=u.get(t);h.push(e.layout)}const p=u.attributeUtils.createShaderVertexBuffers(e);let g;s.blending===z||s.blending===O&&!1===s.transparent||(g=this._getBlending(s));let m={};!0===s.stencilWrite&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const f=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){const t=e.context.textures;for(let e=0;e1},layout:l.createPipelineLayout({bindGroupLayouts:h})},E={},w=e.context.depth,A=e.context.stencil;if(!0!==w&&!0!==A||(!0===w&&(E.format=v,E.depthWriteEnabled=s.depthWrite,E.depthCompare=_),!0===A&&(E.stencilFront=m,E.stencilBack={},E.stencilReadMask=s.stencilFuncMask,E.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(E.depthBias=s.polygonOffsetUnits,E.depthBiasSlopeScale=s.polygonOffsetFactor,E.depthBiasClamp=0),S.depthStencil=E),null===t)c.pipeline=l.createRenderPipeline(S);else{const e=new Promise((e=>{l.createRenderPipelineAsync(S).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a={label:t,colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:n,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(a)}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e);a.push(t.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===qe){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:jE},r={srcFactor:i,dstFactor:n,operation:jE}};if(e.premultipliedAlpha)switch(s){case O:i(BE,UE,BE,UE);break;case Ft:i(BE,BE,BE,BE);break;case Pt:i(LE,DE,LE,BE);break;case Mt:i(LE,IE,LE,VE)}else switch(s){case O:i(VE,UE,BE,UE);break;case Ft:i(VE,BE,VE,BE);break;case Pt:i(LE,DE,LE,BE);break;case Mt:i(LE,IE,LE,IE)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Ke:t=LE;break;case wt:t=BE;break;case Et:t=IE;break;case Tt:t=DE;break;case St:t=VE;break;case bt:t=UE;break;case vt:t=OE;break;case xt:t=kE;break;case _t:t=GE;break;case yt:t=zE;break;case Nt:t=HE;break;case 211:t=$E;break;case 212:t=WE;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case kr:t=wN;break;case Or:t=LN;break;case Ur:t=AN;break;case Vr:t=CN;break;case Dr:t=RN;break;case Ir:t=FN;break;case Br:t=MN;break;case Lr:t=PN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Xr:t=JE;break;case qr:t=ew;break;case jr:t=tw;break;case Wr:t=rw;break;case $r:t=sw;break;case Hr:t=iw;break;case zr:t=nw;break;case Gr:t=aw;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Xe:t=jE;break;case ft:t=qE;break;case mt:t=XE;break;case Yr:t=KE;break;case Kr:t=YE;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?GN:zN),r.side){case je:s.frontFace=VN,s.cullMode=kN;break;case S:s.frontFace=VN,s.cullMode=ON;break;case Se:s.frontFace=VN,s.cullMode=UN;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return s}_getColorWriteMask(e){return!0===e.colorWrite?ZE:QE}_getDepthCompare(e){let t;if(!1===e.depthTest)t=LN;else{const r=e.depthFunc;switch(r){case kt:t=wN;break;case Ot:t=LN;break;case Ut:t=AN;break;case Vt:t=CN;break;case Dt:t=RN;break;case It:t=FN;break;case Bt:t=MN;break;case Lt:t=PN;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class lA extends yN{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return pt(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(this.device.queue.submit([i]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r));let a=0;for(const[,t]of e){const e=n[t],r=n[t+1];a+=Number(r-e)/1e6}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class dA extends Jv{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new rA(this),this.attributeUtils=new aA(this),this.bindingUtils=new oA(this),this.pipelineUtils=new uA(this),this.textureUtils=new Vw(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===s)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const i=Object.values(Rw),n=[];for(const e of i)s.features.has(e)&&n.push(e);const a={requiredFeatures:n,requiredLimits:t.requiredLimits};r=await s.requestDevice(a)}else r=t.device;r.lost.then((t=>{const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}));const s=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=r,this.context=s;const i=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(Rw.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return d}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}]},!0!==this.renderer.depth&&!0!==this.renderer.stencil||(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let i=s.descriptors;if(void 0===i||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==e.activeMipmapLevel||s.activeCubeFace!==e.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;const e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}const n=e.getCacheKey();let a=i[n];if(void 0===a){const t=e.textures,o=[];let u;const l=this._isRenderCameraDepthArray(e);for(let s=0;s1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:IN}),this.initTimestampQuery(e,n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&(i=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,i));const n=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;ea?(u.x=Math.min(t.dispatchCount,a),u.y=Math.ceil(t.dispatchCount/a)):u.x=t.dispatchCount,i.dispatchWorkgroups(u.x,u.y,u.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:r,material:s,context:i,pipeline:n}=e,a=e.getBindings(),o=this.get(i),u=this.get(n).pipeline,l=e.getIndex(),d=null!==l,c=e.getDrawParameters();if(null===c)return;const h=(t,r)=>{this.pipelineUtils.setPipeline(t,u),r.pipeline=u;const n=r.bindingGroups;for(let e=0,r=a.length;e{if(h(s,i),!0===r.isBatchedMesh){const e=r._multiDrawStarts,i=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&pt("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o1?0:o;!0===d?s.drawIndexed(i[o],n,e[o]/l.array.BYTES_PER_ELEMENT,0,u):s.draw(i[o],n,e[o],u),t.update(r,i[o],n)}}else if(!0===d){const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndexedIndirect(e,0)}else s.drawIndexed(i,n,a,0,0);t.update(r,i,n)}else{const{vertexCount:i,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){const e=this.get(o).buffer;s.drawIndirect(e,0)}else s.draw(i,n,a,0);t.update(r,i,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const t=this.get(e.camera),s=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==s.length){const e=this.get(n),r=[],i=new Uint32Array([0,0,0,0]);for(let t=0,n=s.length;t(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new TN(e)));super(new t(e),e),this.library=new pA,this.isWebGPURenderer=!0}}class mA extends ds{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class fA{constructor(e,t=nn(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Wh;r.name="PostProcessing",this._quadMesh=new vy(r)}render(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}dispose(){this._quadMesh.material.dispose()}_update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;this._quadMesh.material.fragmentNode=!0===this.outputColorTransform?Ou(this.outputNode,t,r):this.outputNode.context({toneMapping:t,outputColorSpace:r}),this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this._update();const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=p,e.outputColorSpace=ue;const s=e.xr.enabled;e.xr.enabled=!1,await this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r}}class yA extends b{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=K,this.minFilter=K,this.isStorageTexture=!0}}class xA extends My{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class bA extends cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new hs(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):console.error(t),this.manager.itemError(e)}}),r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(console.error("THREE.NodeLoader: Node type not found:",e),ji()):Bi(new this.nodes[e])}}class TA extends ps{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class _A extends gs{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(void 0!==e){const r=new bA;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new TA;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t