@mappedin/mappedin-js 6.18.0 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/THIRD_PARTY_LICENSES.txt +408 -5
  2. package/lib/esm/GLTFExporter-G4WLRGTD.js +1 -0
  3. package/lib/esm/GLTFLoader-6KS65AUU.js +1 -0
  4. package/lib/esm/{chunk-X2XAL5AL.js → chunk-5DTIPZIM.js} +1 -1
  5. package/lib/esm/chunk-7ZLJ5BZG.js +956 -0
  6. package/lib/esm/chunk-PJFSEFCS.js +660 -0
  7. package/lib/esm/chunk-PWEV3AFA.js +1 -0
  8. package/lib/esm/chunk-S634J4FK.js +3819 -0
  9. package/lib/esm/chunk-XH3AOOQM.js +1515 -0
  10. package/lib/esm/index.css +1 -1
  11. package/lib/esm/index.d.ts +563 -87
  12. package/lib/esm/index.js +1 -1
  13. package/lib/esm/inspector-IMRVE3SS.js +482 -0
  14. package/lib/esm/inspector-PGGVNGUZ.css +1 -0
  15. package/lib/esm/internal-75ZEUF5X.js +1 -0
  16. package/lib/esm/internal-Q5HDG37N.css +1 -0
  17. package/lib/esm/{roboto-regular-OIQQVHWA.js → roboto-regular-6ZYOMS3F.js} +1 -1
  18. package/lib/esm/src-RKBRVS5G.js +1 -0
  19. package/lib/esm/src-WUAFLQGO.css +1 -0
  20. package/lib/esm/text3d-YG2QJ2JU.js +252 -0
  21. package/lib/esm/workers/collision-worker.csp.js +1 -1
  22. package/lib/index.css +1 -1
  23. package/package.json +1 -1
  24. package/lib/esm/GLTFExporter-REUTCDDJ.js +0 -1
  25. package/lib/esm/GLTFLoader-BHAZAEWN.js +0 -1
  26. package/lib/esm/chunk-FILUCKU4.js +0 -1
  27. package/lib/esm/chunk-FQILVVN4.js +0 -1
  28. package/lib/esm/chunk-KNYR4VGD.js +0 -1
  29. package/lib/esm/chunk-MCLERQTU.js +0 -1
  30. package/lib/esm/chunk-USECXCBB.js +0 -1
  31. package/lib/esm/inspector-6AQ5XCPD.js +0 -1
  32. package/lib/esm/inspector-6RM5OI6U.css +0 -1
  33. package/lib/esm/internal-I66JHO4D.js +0 -1
  34. package/lib/esm/internal-J5PK6TOB.css +0 -1
  35. package/lib/esm/src-GA2Z4OON.css +0 -1
  36. package/lib/esm/src-VUR3CJ3Y.js +0 -1
  37. package/lib/esm/text3d-WK55MUUL.js +0 -1
@@ -0,0 +1,3819 @@
1
+ import{a as nd}from"./chunk-PWEV3AFA.js";var Cc,ss=nd(()=>{Cc={env:{NODE_ENV:"production",npm_package_version:"6.19.0"}}});ss();var sd={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};var yh=0,Bl=1,Mh=2;var zl=1,Sh=2,fn=3,Tn=0,Ue=1,pn=2,In=0,si=1,kl=2,Vl=3,Hl=4,bh=5,Hn=100,Eh=101,Th=102,Ah=103,wh=104,Ch=200,Rh=201,Ih=202,Ph=203,Ur=204,Nr=205,Lh=206,Dh=207,Uh=208,Nh=209,Fh=210,Oh=211,Bh=212,zh=213,kh=214,fa=0,pa=1,ma=2,ri=3,ga=4,_a=5,xa=6,va=7,ya=0,Vh=1,Hh=2,Pn=0,Gh=1,Wh=2,Xh=3,qh=4,Yh=5,Zh=6,Jh=7,Wo="attached",$h="detached",Gl=300,mi=301,gi=302,Ma=303,Sa=304,Gs=306,Fr=1e3,kn=1001,Or=1002,Oe=1003,Kh=1004;var Ws=1005;var sn=1006,ba=1007;var qn=1008;var on=1009,Wl=1010,Xl=1011,Ji=1012,Ea=1013,Ln=1014,Be=1015,$i=1016,Ta=1017,Aa=1018,Ki=1020,ql=35902,Yl=1021,Zl=1022,De=1023,zi=1026,Qi=1027,wa=1028,Xs=1029,Jl=1030,Ca=1031;var Ra=1033,qs=33776,Ys=33777,Zs=33778,Js=33779,Ia=35840,Pa=35841,La=35842,Da=35843,Ua=36196,Na=37492,Fa=37496,Oa=37808,Ba=37809,za=37810,ka=37811,Va=37812,Ha=37813,Ga=37814,Wa=37815,Xa=37816,qa=37817,Ya=37818,Za=37819,Ja=37820,$a=37821,$s=36492,Ka=36494,Qa=36495,$l=36283,ja=36284,to=36285,eo=36286;var xs=2300,Br=2301,Dr=2302,Xo=2400,qo=2401,Yo=2402,Qh=2500;var rd=0,ad=1,od=2,jh=3200,tu=3201;var no=0,eu=1,Dn="",We="srgb",ai="srgb-linear",vs="linear",ee="srgb";var ei=7680,ld=7681;var cd=34055,hd=34056;var ud=514;var dd=517;var Zo=519,nu=512,iu=513,su=514,Kl=515,ru=516,au=517,ou=518,lu=519,zr=35044,fd=35048;var Ql="300 es",Je=2e3,ys=2001;var An=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,t);t.target=null}}},Ee=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Rc=1234567,Oi=Math.PI/180,oi=180/Math.PI;function $e(){let s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ee[s&255]+Ee[s>>8&255]+Ee[s>>16&255]+Ee[s>>24&255]+"-"+Ee[t&255]+Ee[t>>8&255]+"-"+Ee[t>>16&15|64]+Ee[t>>24&255]+"-"+Ee[e&63|128]+Ee[e>>8&255]+"-"+Ee[e>>16&255]+Ee[e>>24&255]+Ee[n&255]+Ee[n>>8&255]+Ee[n>>16&255]+Ee[n>>24&255]).toLowerCase()}function qt(s,t,e){return Math.max(t,Math.min(e,s))}function jl(s,t){return(s%t+t)%t}function pd(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function md(s,t,e){return s!==t?(e-s)/(t-s):0}function ms(s,t,e){return(1-e)*s+e*t}function gd(s,t,e,n){return ms(s,t,1-Math.exp(-e*n))}function _d(s,t=1){return t-Math.abs(jl(s,t*2)-t)}function xd(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function vd(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function yd(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Md(s,t){return s+Math.random()*(t-s)}function Sd(s){return s*(.5-Math.random())}function bd(s){s!==void 0&&(Rc=s);let t=Rc+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ed(s){return s*Oi}function Td(s){return s*oi}function Ad(s){return(s&s-1)===0&&s!==0}function wd(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Cd(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Rd(s,t,e,n,i){let r=Math.cos,a=Math.sin,o=r(e/2),l=a(e/2),c=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),p=r((n-t)/2),g=a((n-t)/2);switch(i){case"XYX":s.set(o*h,l*u,l*d,o*c);break;case"YZY":s.set(l*d,o*h,l*u,o*c);break;case"ZXZ":s.set(l*u,l*d,o*h,o*c);break;case"XZX":s.set(o*h,l*g,l*p,o*c);break;case"YXY":s.set(l*p,o*h,l*g,o*c);break;case"ZYZ":s.set(l*g,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function nn(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function te(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var Id={DEG2RAD:Oi,RAD2DEG:oi,generateUUID:$e,clamp:qt,euclideanModulo:jl,mapLinear:pd,inverseLerp:md,lerp:ms,damp:gd,pingpong:_d,smoothstep:xd,smootherstep:vd,randInt:yd,randFloat:Md,randFloatSpread:Sd,seededRandom:bd,degToRad:Ed,radToDeg:Td,isPowerOfTwo:Ad,ceilPowerOfTwo:wd,floorPowerOfTwo:Cd,setQuaternionFromProperEuler:Rd,normalize:te,denormalize:nn},ot=class s{constructor(t=0,e=0){s.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){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(qt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},wn=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=r[a+0],p=r[a+1],g=r[a+2],x=r[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=g,t[e+3]=x;return}if(u!==x||l!==d||c!==p||h!==g){let m=1-o,f=l*d+c*p+h*g+u*x,A=f>=0?1:-1,M=1-f*f;if(M>Number.EPSILON){let I=Math.sqrt(M),w=Math.atan2(I,f*A);m=Math.sin(m*w)/I,o=Math.sin(o*w)/I}let v=o*A;if(l=l*m+d*v,c=c*m+p*v,h=h*m+g*v,u=u*m+x*v,m===1-o){let I=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=I,c*=I,h*=I,u*=I}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){let o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=r[a],d=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*u+l*p-c*d,t[e+1]=l*g+h*d+c*u-o*p,t[e+2]=c*g+h*p+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(r/2),d=l(n/2),p=l(i/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"YZX":this._x=d*h*u+c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u-d*p*g;break;case"XZY":this._x=d*h*u-c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-i)*p}else if(n>o&&n>u){let p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(r+c)/p}else if(o>u){let p=2*Math.sqrt(1+o-n-u);this._w=(r-c)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+h)/p}else{let p=2*Math.sqrt(1+u-n-o);this._w=(a-i)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(qt(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+i*c-r*l,this._y=i*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,i=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;let l=1-o*o;if(l<=Number.EPSILON){let p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*i+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}let c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*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}},C=class s{constructor(t=0,e=0,n=0){s.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(Ic.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ic.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=i+l*u+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this.z=qt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this.z=qt(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(n,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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ho.copy(this).projectOnVector(t),this.sub(ho)}reflect(t){return this.sub(ho.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(qt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ho=new C,Ic=new wn,Vt=class s{constructor(t,e,n,i,r,a,o,l,c){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,l,c)}set(t,e,n,i,r,a,o,l,c){let h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],x=i[0],m=i[3],f=i[6],A=i[1],M=i[4],v=i[7],I=i[2],w=i[5],R=i[8];return r[0]=a*x+o*A+l*I,r[3]=a*m+o*M+l*w,r[6]=a*f+o*v+l*R,r[1]=c*x+h*A+u*I,r[4]=c*m+h*M+u*w,r[7]=c*f+h*v+u*R,r[2]=d*x+p*A+g*I,r[5]=d*m+p*M+g*w,r[8]=d*f+p*v+g*R,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+i*r*c-i*a*l}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*r,p=c*r-a*l,g=e*u+n*d+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return t[0]=u*x,t[1]=(i*c-h*n)*x,t[2]=(o*n-i*a)*x,t[3]=d*x,t[4]=(h*e-i*l)*x,t[5]=(i*r-o*e)*x,t[6]=p*x,t[7]=(n*l-c*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-i*c,i*l,-i*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(uo.makeScale(t,e)),this}rotate(t){return this.premultiply(uo.makeRotation(-t)),this}translate(t,e){return this.premultiply(uo.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},uo=new Vt;function tc(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function ki(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function cu(){let s=ki("canvas");return s.style.display="block",s}var Pc={};function li(s){s in Pc||(Pc[s]=!0,console.warn(s))}function hu(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}function uu(s){let t=s.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function du(s){let t=s.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}var Lc=new Vt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Dc=new Vt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pd(){let s={enabled:!0,workingColorSpace:ai,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ee&&(i.r=En(i.r),i.g=En(i.g),i.b=En(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ee&&(i.r=Bi(i.r),i.g=Bi(i.g),i.b=Bi(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Dn?vs:this.spaces[i].transfer},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return li("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return li("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ai]:{primaries:t,whitePoint:n,transfer:vs,toXYZ:Lc,fromXYZ:Dc,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:We},outputColorSpaceConfig:{drawingBufferColorSpace:We}},[We]:{primaries:t,whitePoint:n,transfer:ee,toXYZ:Lc,fromXYZ:Dc,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:We}}}),s}var Jt=Pd();function En(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Bi(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var bi,kr=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{bi===void 0&&(bi=ki("canvas")),bi.width=t.width,bi.height=t.height;let i=bi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=bi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ki("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=En(r[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(En(e[n]/255)*255):e[n]=En(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Ld=0,Vi=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ld++}),this.uuid=$e(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(fo(i[a].image)):r.push(fo(i[a]))}else r=fo(i);n.url=r}return e||(t.images[this.uuid]=n),n}};function fo(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?kr.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Dd=0,po=new C,Se=class s extends An{constructor(t=s.DEFAULT_IMAGE,e=s.DEFAULT_MAPPING,n=kn,i=kn,r=sn,a=qn,o=De,l=on,c=s.DEFAULT_ANISOTROPY,h=Dn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dd++}),this.uuid=$e(),this.name="",this.source=new Vi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ot(0,0),this.repeat=new ot(1,1),this.center=new ot(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(po).x}get height(){return this.source.getSize(po).y}get depth(){return this.source.getSize(po).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={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&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Gl)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Fr:t.x=t.x-Math.floor(t.x);break;case kn:t.x=t.x<0?0:1;break;case Or:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Fr:t.y=t.y-Math.floor(t.y);break;case kn:t.y=t.y<0?0:1;break;case Or:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Se.DEFAULT_IMAGE=null;Se.DEFAULT_MAPPING=Gl;Se.DEFAULT_ANISOTROPY=1;var Qt=class s{constructor(t=0,e=0,n=0,i=1){s.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[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);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r,l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],g=l[9],x=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let M=(c+1)/2,v=(p+1)/2,I=(f+1)/2,w=(h+d)/4,R=(u+x)/4,D=(g+m)/4;return M>v&&M>I?M<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(M),i=w/n,r=R/n):v>I?v<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(v),n=w/i,r=D/i):I<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(I),n=R/r,i=D/r),this.set(n,i,r,e),this}let A=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(u-x)/A,this.z=(d-h)/A,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=qt(this.x,t.x,e.x),this.y=qt(this.y,t.y,e.y),this.z=qt(this.z,t.z,e.z),this.w=qt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=qt(this.x,t,e),this.y=qt(this.y,t,e),this.z=qt(this.z,t,e),this.w=qt(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Vr=class extends An{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:sn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Qt(0,0,t,e),this.scissorTest=!1,this.viewport=new Qt(0,0,t,e);let i={width:t,height:e,depth:n.depth},r=new Se(i);this.textures=[];let a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){let e={minFilter:sn,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new Vi(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},dn=class extends Vr{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},Ms=class extends Se{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Oe,this.minFilter=Oe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var Hr=class extends Se{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Oe,this.minFilter=Oe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Le=class{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(je.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(je.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=je.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,je):je.fromBufferAttribute(r,a),je.applyMatrix4(t.matrixWorld),this.expandByPoint(je);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),tr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),tr.copy(n.boundingBox)),tr.applyMatrix4(t.matrixWorld),this.union(tr)}let i=t.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,je),je.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(rs),er.subVectors(this.max,rs),Ei.subVectors(t.a,rs),Ti.subVectors(t.b,rs),Ai.subVectors(t.c,rs),Un.subVectors(Ti,Ei),Nn.subVectors(Ai,Ti),Jn.subVectors(Ei,Ai);let e=[0,-Un.z,Un.y,0,-Nn.z,Nn.y,0,-Jn.z,Jn.y,Un.z,0,-Un.x,Nn.z,0,-Nn.x,Jn.z,0,-Jn.x,-Un.y,Un.x,0,-Nn.y,Nn.x,0,-Jn.y,Jn.x,0];return!mo(e,Ei,Ti,Ai,er)||(e=[1,0,0,0,1,0,0,0,1],!mo(e,Ei,Ti,Ai,er))?!1:(nr.crossVectors(Un,Nn),e=[nr.x,nr.y,nr.z],mo(e,Ei,Ti,Ai,er))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,je).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(je).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(_n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_n),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}},_n=[new C,new C,new C,new C,new C,new C,new C,new C],je=new C,tr=new Le,Ei=new C,Ti=new C,Ai=new C,Un=new C,Nn=new C,Jn=new C,rs=new C,er=new C,nr=new C,$n=new C;function mo(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){$n.fromArray(s,r);let o=i.x*Math.abs($n.x)+i.y*Math.abs($n.y)+i.z*Math.abs($n.z),l=t.dot($n),c=e.dot($n),h=n.dot($n);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}var Ud=new Le,as=new C,go=new C,Ce=class{constructor(t=new C,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):Ud.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;r<a;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;as.subVectors(t,this.center);let e=as.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(as,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(go.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(as.copy(t.center).add(go)),this.expandByPoint(as.copy(t.center).sub(go))),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}},xn=new C,_o=new C,ir=new C,Fn=new C,xo=new C,sr=new C,vo=new C,Gn=class{constructor(t=new C,e=new C(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,xn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=xn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(xn.copy(this.origin).addScaledVector(this.direction,e),xn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){_o.copy(t).add(e).multiplyScalar(.5),ir.copy(e).sub(t).normalize(),Fn.copy(this.origin).sub(_o);let r=t.distanceTo(e)*.5,a=-this.direction.dot(ir),o=Fn.dot(this.direction),l=-Fn.dot(ir),c=Fn.lengthSq(),h=Math.abs(1-a*a),u,d,p,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){let x=1/h;u*=x,d*=x,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),p=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(_o).addScaledVector(ir,d),p}intersectSphere(t,e){xn.subVectors(t.center,this.origin);let n=xn.dot(this.direction),i=xn.dot(xn)-n*n,r=t.radius*t.radius;if(i>r)return null;let a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,xn)!==null}intersectTriangle(t,e,n,i,r){xo.subVectors(e,t),sr.subVectors(n,t),vo.crossVectors(xo,sr);let a=this.direction.dot(vo),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Fn.subVectors(this.origin,t);let l=o*this.direction.dot(sr.crossVectors(Fn,sr));if(l<0)return null;let c=o*this.direction.dot(xo.cross(Fn));if(c<0||l+c>a)return null;let h=-o*Fn.dot(vo);return h<0?null:this.at(h/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)}},Wt=class s{constructor(t,e,n,i,r,a,o,l,c,h,u,d,p,g,x,m){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,l,c,h,u,d,p,g,x,m)}set(t,e,n,i,r,a,o,l,c,h,u,d,p,g,x,m){let f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=i,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=x,f[15]=m,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 s().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/wi.setFromMatrixColumn(t,0).length(),r=1/wi.setFromMatrixColumn(t,1).length(),a=1/wi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){let d=a*h,p=a*u,g=o*h,x=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=p+g*c,e[5]=d-x*c,e[9]=-o*l,e[2]=x-d*c,e[6]=g+p*c,e[10]=a*l}else if(t.order==="YXZ"){let d=l*h,p=l*u,g=c*h,x=c*u;e[0]=d+x*o,e[4]=g*o-p,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=x+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*h,p=l*u,g=c*h,x=c*u;e[0]=d-x*o,e[4]=-a*u,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*h,p=a*u,g=o*h,x=o*u;e[0]=l*h,e[4]=g*c-p,e[8]=d*c+x,e[1]=l*u,e[5]=x*c+d,e[9]=p*c-g,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*c,g=o*l,x=o*c;e[0]=l*h,e[4]=x-d*u,e[8]=g*u+p,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=p*u+g,e[10]=d-x*u}else if(t.order==="XZY"){let d=a*l,p=a*c,g=o*l,x=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+x,e[5]=a*h,e[9]=p*u-g,e[2]=g*u-p,e[6]=o*h,e[10]=x*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Nd,t,Fd)}lookAt(t,e,n){let i=this.elements;return He.subVectors(t,e),He.lengthSq()===0&&(He.z=1),He.normalize(),On.crossVectors(n,He),On.lengthSq()===0&&(Math.abs(n.z)===1?He.x+=1e-4:He.z+=1e-4,He.normalize(),On.crossVectors(n,He)),On.normalize(),rr.crossVectors(He,On),i[0]=On.x,i[4]=rr.x,i[8]=He.x,i[1]=On.y,i[5]=rr.y,i[9]=He.y,i[2]=On.z,i[6]=rr.z,i[10]=He.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],x=n[6],m=n[10],f=n[14],A=n[3],M=n[7],v=n[11],I=n[15],w=i[0],R=i[4],D=i[8],E=i[12],S=i[1],P=i[5],Y=i[9],z=i[13],X=i[2],J=i[6],G=i[10],tt=i[14],k=i[3],lt=i[7],mt=i[11],Mt=i[15];return r[0]=a*w+o*S+l*X+c*k,r[4]=a*R+o*P+l*J+c*lt,r[8]=a*D+o*Y+l*G+c*mt,r[12]=a*E+o*z+l*tt+c*Mt,r[1]=h*w+u*S+d*X+p*k,r[5]=h*R+u*P+d*J+p*lt,r[9]=h*D+u*Y+d*G+p*mt,r[13]=h*E+u*z+d*tt+p*Mt,r[2]=g*w+x*S+m*X+f*k,r[6]=g*R+x*P+m*J+f*lt,r[10]=g*D+x*Y+m*G+f*mt,r[14]=g*E+x*z+m*tt+f*Mt,r[3]=A*w+M*S+v*X+I*k,r[7]=A*R+M*P+v*J+I*lt,r[11]=A*D+M*Y+v*G+I*mt,r[15]=A*E+M*z+v*tt+I*Mt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],p=t[14],g=t[3],x=t[7],m=t[11],f=t[15];return g*(+r*l*u-i*c*u-r*o*d+n*c*d+i*o*p-n*l*p)+x*(+e*l*p-e*c*d+r*a*d-i*a*p+i*c*h-r*l*h)+m*(+e*c*u-e*o*p-r*a*u+n*a*p+r*o*h-n*c*h)+f*(-i*o*h-e*l*u+e*o*d+i*a*u-n*a*d+n*l*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],g=t[12],x=t[13],m=t[14],f=t[15],A=u*m*c-x*d*c+x*l*p-o*m*p-u*l*f+o*d*f,M=g*d*c-h*m*c-g*l*p+a*m*p+h*l*f-a*d*f,v=h*x*c-g*u*c+g*o*p-a*x*p-h*o*f+a*u*f,I=g*u*l-h*x*l-g*o*d+a*x*d+h*o*m-a*u*m,w=e*A+n*M+i*v+r*I;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/w;return t[0]=A*R,t[1]=(x*d*r-u*m*r-x*i*p+n*m*p+u*i*f-n*d*f)*R,t[2]=(o*m*r-x*l*r+x*i*c-n*m*c-o*i*f+n*l*f)*R,t[3]=(u*l*r-o*d*r-u*i*c+n*d*c+o*i*p-n*l*p)*R,t[4]=M*R,t[5]=(h*m*r-g*d*r+g*i*p-e*m*p-h*i*f+e*d*f)*R,t[6]=(g*l*r-a*m*r-g*i*c+e*m*c+a*i*f-e*l*f)*R,t[7]=(a*d*r-h*l*r+h*i*c-e*d*c-a*i*p+e*l*p)*R,t[8]=v*R,t[9]=(g*u*r-h*x*r-g*n*p+e*x*p+h*n*f-e*u*f)*R,t[10]=(a*x*r-g*o*r+g*n*c-e*x*c-a*n*f+e*o*f)*R,t[11]=(h*o*r-a*u*r-h*n*c+e*u*c+a*n*p-e*o*p)*R,t[12]=I*R,t[13]=(h*x*i-g*u*i+g*n*d-e*x*d-h*n*m+e*u*m)*R,t[14]=(g*o*i-a*x*i-g*n*l+e*x*l+a*n*m-e*o*m)*R,t[15]=(a*u*i-h*o*i+h*n*l-e*u*l-a*n*d+e*o*d)*R,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,u=o+o,d=r*c,p=r*h,g=r*u,x=a*h,m=a*u,f=o*u,A=l*c,M=l*h,v=l*u,I=n.x,w=n.y,R=n.z;return i[0]=(1-(x+f))*I,i[1]=(p+v)*I,i[2]=(g-M)*I,i[3]=0,i[4]=(p-v)*w,i[5]=(1-(d+f))*w,i[6]=(m+A)*w,i[7]=0,i[8]=(g+M)*R,i[9]=(m-A)*R,i[10]=(1-(d+x))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=wi.set(i[0],i[1],i[2]).length(),a=wi.set(i[4],i[5],i[6]).length(),o=wi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],tn.copy(this);let c=1/r,h=1/a,u=1/o;return tn.elements[0]*=c,tn.elements[1]*=c,tn.elements[2]*=c,tn.elements[4]*=h,tn.elements[5]*=h,tn.elements[6]*=h,tn.elements[8]*=u,tn.elements[9]*=u,tn.elements[10]*=u,e.setFromRotationMatrix(tn),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,r,a,o=Je){let l=this.elements,c=2*r/(e-t),h=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i),p,g;if(o===Je)p=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===ys)p=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=Je){let l=this.elements,c=1/(e-t),h=1/(n-i),u=1/(a-r),d=(e+t)*c,p=(n+i)*h,g,x;if(o===Je)g=(a+r)*u,x=-2*u;else if(o===ys)g=r*u,x=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=x,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},wi=new C,tn=new Wt,Nd=new C(0,0,0),Fd=new C(1,1,1),On=new C,rr=new C,He=new C,Uc=new Wt,Nc=new wn,Ke=class s{constructor(t=0,e=0,n=0,i=s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(qt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-qt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(qt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-qt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(qt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-qt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Uc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Uc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Nc.setFromEuler(this),this.setFromQuaternion(Nc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ke.DEFAULT_ORDER="XYZ";var Hi=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},Od=0,Fc=new C,Ci=new wn,vn=new Wt,ar=new C,os=new C,Bd=new C,zd=new wn,Oc=new C(1,0,0),Bc=new C(0,1,0),zc=new C(0,0,1),kc={type:"added"},kd={type:"removed"},Ri={type:"childadded",child:null},yo={type:"childremoved",child:null},ge=class s extends An{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Od++}),this.uuid=$e(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=s.DEFAULT_UP.clone();let t=new C,e=new Ke,n=new wn,i=new C(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Wt},normalMatrix:{value:new Vt}}),this.matrix=new Wt,this.matrixWorld=new Wt,this.matrixAutoUpdate=s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Hi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ci.setFromAxisAngle(t,e),this.quaternion.multiply(Ci),this}rotateOnWorldAxis(t,e){return Ci.setFromAxisAngle(t,e),this.quaternion.premultiply(Ci),this}rotateX(t){return this.rotateOnAxis(Oc,t)}rotateY(t){return this.rotateOnAxis(Bc,t)}rotateZ(t){return this.rotateOnAxis(zc,t)}translateOnAxis(t,e){return Fc.copy(t).applyQuaternion(this.quaternion),this.position.add(Fc.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Oc,t)}translateY(t){return this.translateOnAxis(Bc,t)}translateZ(t){return this.translateOnAxis(zc,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(vn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ar.copy(t):ar.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),os.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vn.lookAt(os,ar,this.up):vn.lookAt(ar,os,this.up),this.quaternion.setFromRotationMatrix(vn),i&&(vn.extractRotation(i.matrixWorld),Ci.setFromRotationMatrix(vn),this.quaternion.premultiply(Ci.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(kc),Ri.child=t,this.dispatchEvent(Ri),Ri.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(kd),yo.child=t,this.dispatchEvent(yo),yo.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),vn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),vn.multiply(t.parent.matrixWorld)),t.applyMatrix4(vn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(kc),Ri.child=t,this.dispatchEvent(Ri),Ri.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(os,t,Bd),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(os,zd,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let u=l[c];r(t.shapes,u)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));i.material=o}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];i.animations.push(r(t.animations,l))}}if(e){let o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),p=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){let l=[];for(let c in o){let h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};ge.DEFAULT_UP=new C(0,1,0);ge.DEFAULT_MATRIX_AUTO_UPDATE=!0;ge.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var en=new C,yn=new C,Mo=new C,Mn=new C,Ii=new C,Pi=new C,Vc=new C,So=new C,bo=new C,Eo=new C,To=new Qt,Ao=new Qt,wo=new Qt,bn=class s{constructor(t=new C,e=new C,n=new C){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),en.subVectors(t,e),i.cross(en);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){en.subVectors(i,e),yn.subVectors(n,e),Mo.subVectors(t,e);let a=en.dot(en),o=en.dot(yn),l=en.dot(Mo),c=yn.dot(yn),h=yn.dot(Mo),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,p=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Mn)===null?!1:Mn.x>=0&&Mn.y>=0&&Mn.x+Mn.y<=1}static getInterpolation(t,e,n,i,r,a,o,l){return this.getBarycoord(t,e,n,i,Mn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Mn.x),l.addScaledVector(a,Mn.y),l.addScaledVector(o,Mn.z),l)}static getInterpolatedAttribute(t,e,n,i,r,a){return To.setScalar(0),Ao.setScalar(0),wo.setScalar(0),To.fromBufferAttribute(t,e),Ao.fromBufferAttribute(t,n),wo.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(To,r.x),a.addScaledVector(Ao,r.y),a.addScaledVector(wo,r.z),a}static isFrontFacing(t,e,n,i){return en.subVectors(n,e),yn.subVectors(t,e),en.cross(yn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return en.subVectors(this.c,this.b),yn.subVectors(this.a,this.b),en.cross(yn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return s.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,a,o;Ii.subVectors(i,n),Pi.subVectors(r,n),So.subVectors(t,n);let l=Ii.dot(So),c=Pi.dot(So);if(l<=0&&c<=0)return e.copy(n);bo.subVectors(t,i);let h=Ii.dot(bo),u=Pi.dot(bo);if(h>=0&&u<=h)return e.copy(i);let d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Ii,a);Eo.subVectors(t,r);let p=Ii.dot(Eo),g=Pi.dot(Eo);if(g>=0&&p<=g)return e.copy(r);let x=p*c-l*g;if(x<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Pi,o);let m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return Vc.subVectors(r,i),o=(u-h)/(u-h+(p-g)),e.copy(i).addScaledVector(Vc,o);let f=1/(m+x+d);return a=x*f,o=d*f,e.copy(n).addScaledVector(Ii,a).addScaledVector(Pi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},fu={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Bn={h:0,s:0,l:0},or={h:0,s:0,l:0};function Co(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}var Ut=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=We){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Jt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Jt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Jt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Jt.workingColorSpace){if(t=jl(t,1),e=qt(e,0,1),n=qt(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Co(a,r,t+1/3),this.g=Co(a,r,t),this.b=Co(a,r,t-1/3)}return Jt.colorSpaceToWorking(this,i),this}setStyle(t,e=We){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(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(o))return n(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(o))return n(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(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,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=We){let n=fu[t.toLowerCase()];return n!==void 0?this.setHex(n,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=En(t.r),this.g=En(t.g),this.b=En(t.b),this}copyLinearToSRGB(t){return this.r=Bi(t.r),this.g=Bi(t.g),this.b=Bi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=We){return Jt.workingToColorSpace(Te.copy(this),t),Math.round(qt(Te.r*255,0,255))*65536+Math.round(qt(Te.g*255,0,255))*256+Math.round(qt(Te.b*255,0,255))}getHexString(t=We){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Jt.workingColorSpace){Jt.workingToColorSpace(Te.copy(this),e);let n=Te.r,i=Te.g,r=Te.b,a=Math.max(n,i,r),o=Math.min(n,i,r),l,c,h=(o+a)/2;if(o===a)l=0,c=0;else{let u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-r)/u+(i<r?6:0);break;case i:l=(r-n)/u+2;break;case r:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Jt.workingColorSpace){return Jt.workingToColorSpace(Te.copy(this),e),t.r=Te.r,t.g=Te.g,t.b=Te.b,t}getStyle(t=We){Jt.workingToColorSpace(Te.copy(this),t);let e=Te.r,n=Te.g,i=Te.b;return t!==We?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Bn),this.setHSL(Bn.h+t,Bn.s+e,Bn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Bn),t.getHSL(or);let n=ms(Bn.h,or.h,e),i=ms(Bn.s,or.s,e),r=ms(Bn.l,or.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Te=new Ut;Ut.NAMES=fu;var Vd=0,rn=class extends An{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vd++}),this.uuid=$e(),this.name="",this.type="Material",this.blending=si,this.side=Tn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ur,this.blendDst=Nr,this.blendEquation=Hn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ut(0,0,0),this.blendAlpha=0,this.depthFunc=ri,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Zo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ei,this.stencilZFail=ei,this.stencilZPass=ei,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==si&&(n.blending=this.blending),this.side!==Tn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ur&&(n.blendSrc=this.blendSrc),this.blendDst!==Nr&&(n.blendDst=this.blendDst),this.blendEquation!==Hn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ri&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Zo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ei&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ei&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ei&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){let a=[];for(let o in r){let l=r[o];delete l.metadata,a.push(l)}return a}if(e){let r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Ss=class extends rn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ut(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 Ke,this.combine=ya,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}};var me=new C,lr=new ot,Hd=0,Me=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Hd++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=zr,this.updateRanges=[],this.gpuType=Be,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)lr.fromBufferAttribute(this,e),lr.applyMatrix3(t),this.setXY(e,lr.x,lr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=nn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=te(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=nn(e,this.array)),e}setX(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=nn(e,this.array)),e}setY(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=nn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=nn(e,this.array)),e}setW(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),i=te(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),i=te(i,this.array),r=te(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==zr&&(t.usage=this.usage),t}};var bs=class extends Me{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var Es=class extends Me{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var le=class extends Me{constructor(t,e,n){super(new Float32Array(t),e,n)}},Gd=0,Ze=new Wt,Ro=new ge,Li=new C,Ge=new Le,ls=new Le,ye=new C,_e=class s extends An{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Gd++}),this.uuid=$e(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(tc(t)?Es:bs)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Vt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ze.makeRotationFromQuaternion(t),this.applyMatrix4(Ze),this}rotateX(t){return Ze.makeRotationX(t),this.applyMatrix4(Ze),this}rotateY(t){return Ze.makeRotationY(t),this.applyMatrix4(Ze),this}rotateZ(t){return Ze.makeRotationZ(t),this.applyMatrix4(Ze),this}translate(t,e,n){return Ze.makeTranslation(t,e,n),this.applyMatrix4(Ze),this}scale(t,e,n){return Ze.makeScale(t,e,n),this.applyMatrix4(Ze),this}lookAt(t){return Ro.lookAt(t),Ro.updateMatrix(),this.applyMatrix4(Ro.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Li).negate(),this.translate(Li.x,Li.y,Li.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,r=t.length;i<r;i++){let a=t[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new le(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Le);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let r=e[n];Ge.setFromBufferAttribute(r),this.morphTargetsRelative?(ye.addVectors(this.boundingBox.min,Ge.min),this.boundingBox.expandByPoint(ye),ye.addVectors(this.boundingBox.max,Ge.max),this.boundingBox.expandByPoint(ye)):(this.boundingBox.expandByPoint(Ge.min),this.boundingBox.expandByPoint(Ge.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ce);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(t){let n=this.boundingSphere.center;if(Ge.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];ls.setFromBufferAttribute(o),this.morphTargetsRelative?(ye.addVectors(Ge.min,ls.min),Ge.expandByPoint(ye),ye.addVectors(Ge.max,ls.max),Ge.expandByPoint(ye)):(Ge.expandByPoint(ls.min),Ge.expandByPoint(ls.max))}Ge.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)ye.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(ye));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ye.fromBufferAttribute(o,c),l&&(Li.fromBufferAttribute(t,c),ye.add(Li)),i=Math.max(i,n.distanceToSquared(ye))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Me(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let D=0;D<n.count;D++)o[D]=new C,l[D]=new C;let c=new C,h=new C,u=new C,d=new ot,p=new ot,g=new ot,x=new C,m=new C;function f(D,E,S){c.fromBufferAttribute(n,D),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,S),d.fromBufferAttribute(r,D),p.fromBufferAttribute(r,E),g.fromBufferAttribute(r,S),h.sub(c),u.sub(c),p.sub(d),g.sub(d);let P=1/(p.x*g.y-g.x*p.y);isFinite(P)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(P),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(P),o[D].add(x),o[E].add(x),o[S].add(x),l[D].add(m),l[E].add(m),l[S].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let D=0,E=A.length;D<E;++D){let S=A[D],P=S.start,Y=S.count;for(let z=P,X=P+Y;z<X;z+=3)f(t.getX(z+0),t.getX(z+1),t.getX(z+2))}let M=new C,v=new C,I=new C,w=new C;function R(D){I.fromBufferAttribute(i,D),w.copy(I);let E=o[D];M.copy(E),M.sub(I.multiplyScalar(I.dot(E))).normalize(),v.crossVectors(w,E);let P=v.dot(l[D])<0?-1:1;a.setXYZW(D,M.x,M.y,M.z,P)}for(let D=0,E=A.length;D<E;++D){let S=A[D],P=S.start,Y=S.count;for(let z=P,X=P+Y;z<X;z+=3)R(t.getX(z+0)),R(t.getX(z+1)),R(t.getX(z+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Me(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);let i=new C,r=new C,a=new C,o=new C,l=new C,c=new C,h=new C,u=new C;if(t)for(let d=0,p=t.count;d<p;d+=3){let g=t.getX(d+0),x=t.getX(d+1),m=t.getX(d+2);i.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=e.count;d<p;d+=3)i.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ye.fromBufferAttribute(t,e),ye.normalize(),t.setXYZ(e,ye.x,ye.y,ye.z)}toNonIndexed(){function t(o,l){let c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h),p=0,g=0;for(let x=0,m=l.length;x<m;x++){o.isInterleavedBufferAttribute?p=l[x]*o.data.stride+o.offset:p=l[x]*h;for(let f=0;f<h;f++)d[g++]=c[p++]}return new Me(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new s,n=this.index.array,i=this.attributes;for(let o in i){let l=i[o],c=t(l,n);e.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){let d=c[h],p=t(d,n);l.push(p)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let i={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){let p=c[u];h.push(p.toJSON(t.data))}h.length>0&&(i[l]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let i=t.attributes;for(let c in i){let h=i[c];this.setAttribute(c,h.clone(e))}let r=t.morphAttributes;for(let c in r){let h=[],u=r[c];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let c=0,h=a.length;c<h;c++){let u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Hc=new Wt,Kn=new Gn,cr=new Ce,Gc=new C,hr=new C,ur=new C,dr=new C,Io=new C,fr=new C,Wc=new C,pr=new C,be=class extends ge{constructor(t=new _e,e=new Ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let o=this.morphTargetInfluences;if(r&&o){fr.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=o[l],u=r[l];h!==0&&(Io.fromBufferAttribute(u,t),a?fr.addScaledVector(Io,h):fr.addScaledVector(Io.sub(e),h))}e.add(fr)}return e}raycast(t,e){let n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),cr.copy(n.boundingSphere),cr.applyMatrix4(r),Kn.copy(t.ray).recast(t.near),!(cr.containsPoint(Kn.origin)===!1&&(Kn.intersectSphere(cr,Gc)===null||Kn.origin.distanceToSquared(Gc)>(t.far-t.near)**2))&&(Hc.copy(r).invert(),Kn.copy(t.ray).applyMatrix4(Hc),!(n.boundingBox!==null&&Kn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Kn)))}_computeIntersections(t,e,n){let i,r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){let m=d[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),M=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let v=A,I=M;v<I;v+=3){let w=o.getX(v),R=o.getX(v+1),D=o.getX(v+2);i=mr(this,f,t,n,c,h,u,w,R,D),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,e.push(i))}}else{let g=Math.max(0,p.start),x=Math.min(o.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){let A=o.getX(m),M=o.getX(m+1),v=o.getX(m+2);i=mr(this,a,t,n,c,h,u,A,M,v),i&&(i.faceIndex=Math.floor(m/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){let m=d[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),M=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let v=A,I=M;v<I;v+=3){let w=v,R=v+1,D=v+2;i=mr(this,f,t,n,c,h,u,w,R,D),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,e.push(i))}}else{let g=Math.max(0,p.start),x=Math.min(l.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){let A=m,M=m+1,v=m+2;i=mr(this,a,t,n,c,h,u,A,M,v),i&&(i.faceIndex=Math.floor(m/3),e.push(i))}}}};function Wd(s,t,e,n,i,r,a,o){let l;if(t.side===Ue?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,t.side===Tn,o),l===null)return null;pr.copy(o),pr.applyMatrix4(s.matrixWorld);let c=e.ray.origin.distanceTo(pr);return c<e.near||c>e.far?null:{distance:c,point:pr.clone(),object:s}}function mr(s,t,e,n,i,r,a,o,l,c){s.getVertexPosition(o,hr),s.getVertexPosition(l,ur),s.getVertexPosition(c,dr);let h=Wd(s,t,e,n,hr,ur,dr,Wc);if(h){let u=new C;bn.getBarycoord(Wc,hr,ur,dr,u),i&&(h.uv=bn.getInterpolatedAttribute(i,o,l,c,u,new ot)),r&&(h.uv1=bn.getInterpolatedAttribute(r,o,l,c,u,new ot)),a&&(h.normal=bn.getInterpolatedAttribute(a,o,l,c,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:l,c,normal:new C,materialIndex:0};bn.getNormal(hr,ur,dr,d.normal),h.face=d,h.barycoord=u}return h}var Gi=class s extends _e{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let l=[],c=[],h=[],u=[],d=0,p=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,i,a,2),g("x","z","y",1,-1,t,n,-e,i,a,3),g("x","y","z",1,-1,t,e,n,i,r,4),g("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new le(c,3)),this.setAttribute("normal",new le(h,3)),this.setAttribute("uv",new le(u,2));function g(x,m,f,A,M,v,I,w,R,D,E){let S=v/R,P=I/D,Y=v/2,z=I/2,X=w/2,J=R+1,G=D+1,tt=0,k=0,lt=new C;for(let mt=0;mt<G;mt++){let Mt=mt*P-z;for(let kt=0;kt<J;kt++){let Zt=kt*S-Y;lt[x]=Zt*A,lt[m]=Mt*M,lt[f]=X,c.push(lt.x,lt.y,lt.z),lt[x]=0,lt[m]=0,lt[f]=w>0?1:-1,h.push(lt.x,lt.y,lt.z),u.push(kt/R),u.push(1-mt/D),tt+=1}}for(let mt=0;mt<D;mt++)for(let Mt=0;Mt<R;Mt++){let kt=d+Mt+J*mt,Zt=d+Mt+J*(mt+1),W=d+(Mt+1)+J*(mt+1),st=d+(Mt+1)+J*mt;l.push(kt,Zt,st),l.push(Zt,W,st),k+=6}o.addGroup(p,k,E),p+=k,d+=tt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function _i(s){let t={};for(let e in s){t[e]={};for(let n in s[e]){let i=s[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function Re(s){let t={};for(let e=0;e<s.length;e++){let n=_i(s[e]);for(let i in n)t[i]=n[i]}return t}function Xd(s){let t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function ec(s){let t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Jt.workingColorSpace}var pu={clone:_i,merge:Re},qd=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,Yd=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`,an=class extends rn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=qd,this.fragmentShader=Yd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=_i(t.uniforms),this.uniformsGroups=Xd(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let i in this.uniforms){let a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Wi=class extends ge{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Wt,this.projectionMatrix=new Wt,this.projectionMatrixInverse=new Wt,this.coordinateSystem=Je}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)}},zn=new C,Xc=new ot,qc=new ot,we=class extends Wi{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=oi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Oi*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return oi*2*Math.atan(Math.tan(Oi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){zn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(zn.x,zn.y).multiplyScalar(-t/zn.z),zn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(zn.x,zn.y).multiplyScalar(-t/zn.z)}getViewSize(t,e){return this.getViewBounds(t,Xc,qc),e.subVectors(qc,Xc)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Oi*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,e-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},Di=-90,Ui=1,Gr=class extends ge{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new we(Di,Ui,t,e);i.layers=this.layers,this.add(i);let r=new we(Di,Ui,t,e);r.layers=this.layers,this.add(r);let a=new we(Di,Ui,t,e);a.layers=this.layers,this.add(a);let o=new we(Di,Ui,t,e);o.layers=this.layers,this.add(o);let l=new we(Di,Ui,t,e);l.layers=this.layers,this.add(l);let c=new we(Di,Ui,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,l]=e;for(let c of e)this.remove(c);if(t===Je)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===ys)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;let x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,l),t.setRenderTarget(n,4,i),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Ts=class extends Se{constructor(t=[],e=mi,n,i,r,a,o,l,c,h){super(t,e,n,i,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},Wr=class extends dn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Ts(i),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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},i=new Gi(5,5,5),r=new an({name:"CubemapFromEquirect",uniforms:_i(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ue,blending:In});r.uniforms.tEquirect.value=e;let a=new be(i,r),o=e.minFilter;return e.minFilter===qn&&(e.minFilter=sn),new Gr(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}},ni=class extends ge{constructor(){super(),this.isGroup=!0,this.type="Group"}},Zd={type:"move"},Xi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ni,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ni,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ni,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null,o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(let x of t.hand.values()){let m=e.getJointPose(x,n),f=this._getHandJoint(c,x);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Zd)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new ni;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}};var Jo=class extends ge{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 Ke,this.environmentIntensity=1,this.environmentRotation=new Ke,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(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),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},$o=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=zr,this.updateRanges=[],this.version=0,this.uuid=$e()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$e()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$e()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Pe=new C,Ko=class s{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pe.fromBufferAttribute(this,e),Pe.applyMatrix4(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pe.fromBufferAttribute(this,e),Pe.applyNormalMatrix(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pe.fromBufferAttribute(this,e),Pe.transformDirection(t),this.setXYZ(e,Pe.x,Pe.y,Pe.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=nn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=te(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=nn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=nn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=nn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=nn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),i=te(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),i=te(i,this.array),r=te(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new Me(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new s(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Yc=new C,Zc=new Qt,Jc=new Qt,Jd=new C,$c=new Wt,gr=new C,Po=new Ce,Kc=new Wt,Lo=new Gn,Qo=class extends be{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Wo,this.bindMatrix=new Wt,this.bindMatrixInverse=new Wt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Le),this.boundingBox.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,gr),this.boundingBox.expandByPoint(gr)}computeBoundingSphere(){let t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ce),this.boundingSphere.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,gr),this.boundingSphere.expandByPoint(gr)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){let n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Po.copy(this.boundingSphere),Po.applyMatrix4(i),t.ray.intersectsSphere(Po)!==!1&&(Kc.copy(i).invert(),Lo.copy(t.ray).applyMatrix4(Kc),!(this.boundingBox!==null&&Lo.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Lo)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let t=new Qt,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);let r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===Wo?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$h?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){let n=this.skeleton,i=this.geometry;Zc.fromBufferAttribute(i.attributes.skinIndex,t),Jc.fromBufferAttribute(i.attributes.skinWeight,t),Yc.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let a=Jc.getComponent(r);if(a!==0){let o=Zc.getComponent(r);$c.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(Jd.copy(Yc).applyMatrix4($c),a)}}return e.applyMatrix4(this.bindMatrixInverse)}},Xr=class extends ge{constructor(){super(),this.isBone=!0,this.type="Bone"}},Vn=class extends Se{constructor(t=null,e=1,n=1,i,r,a,o,l,c=Oe,h=Oe,u,d){super(null,a,o,l,c,h,i,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Qc=new Wt,$d=new Wt,jo=class s{constructor(t=[],e=[]){this.uuid=$e(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Wt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new Wt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=t.length;r<a;r++){let o=t[r]?t[r].matrixWorld:$d;Qc.multiplyMatrices(o,e[r]),Qc.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new s(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new Vn(e,t,t,De,Be);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){let r=t.bones[n],a=e[r];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new Xr),this.bones.push(a),this.boneInverses.push(new Wt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){let a=e[i];t.bones.push(a.uuid);let o=n[i];t.boneInverses.push(o.toArray())}return t}},As=class extends Me{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},Ni=new Wt,jc=new Wt,_r=[],th=new Le,Kd=new Wt,cs=new be,hs=new Ce,tl=class extends be{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new As(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Kd)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Le),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ni),th.copy(t.boundingBox).applyMatrix4(Ni),this.boundingBox.union(th)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ce),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,Ni),hs.copy(t.boundingSphere).applyMatrix4(Ni),this.boundingSphere.union(hs)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=t*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){let n=this.matrixWorld,i=this.count;if(cs.geometry=this.geometry,cs.material=this.material,cs.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hs.copy(this.boundingSphere),hs.applyMatrix4(n),t.ray.intersectsSphere(hs)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Ni),jc.multiplyMatrices(n,Ni),cs.matrixWorld=jc,cs.raycast(t,_r);for(let a=0,o=_r.length;a<o;a++){let l=_r[a];l.instanceId=r,l.object=this,e.push(l)}_r.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new As(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Vn(new Float32Array(i*this.count),i,this.count,wa,Be));let r=this.morphTexture.source.data.data,a=0;for(let c=0;c<n.length;c++)a+=n[c];let o=this.geometry.morphTargetsRelative?1:1-a,l=i*t;r[l]=o,r.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Do=new C,Qd=new C,jd=new Vt,hn=class{constructor(t=new C(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=Do.subVectors(n,e).cross(Qd.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Do),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<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){let n=e||jd.getNormalMatrix(t),i=this.coplanarPoint(Do).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}},Qn=new Ce,tf=new ot(.5,.5),xr=new C,Wn=class{constructor(t=new hn,e=new hn,n=new hn,i=new hn,r=new hn,a=new hn){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Je){let n=this.planes,i=t.elements,r=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],p=i[8],g=i[9],x=i[10],m=i[11],f=i[12],A=i[13],M=i[14],v=i[15];if(n[0].setComponents(l-r,d-c,m-p,v-f).normalize(),n[1].setComponents(l+r,d+c,m+p,v+f).normalize(),n[2].setComponents(l+a,d+h,m+g,v+A).normalize(),n[3].setComponents(l-a,d-h,m-g,v-A).normalize(),n[4].setComponents(l-o,d-u,m-x,v-M).normalize(),e===Je)n[5].setComponents(l+o,d+u,m+x,v+M).normalize();else if(e===ys)n[5].setComponents(o,u,x,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Qn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Qn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Qn)}intersectsSprite(t){Qn.center.set(0,0,0);let e=tf.distanceTo(t.center);return Qn.radius=.7071067811865476+e,Qn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Qn)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(xr.x=i.normal.x>0?t.max.x:t.min.x,xr.y=i.normal.y>0?t.max.y:t.min.y,xr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(xr)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},ln=new Wt,cn=new Wn,qr=class s{constructor(){this.coordinateSystem=Je}intersectsObject(t,e){if(!e.isArrayCamera||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(ln.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),cn.setFromProjectionMatrix(ln,this.coordinateSystem),cn.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(ln.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),cn.setFromProjectionMatrix(ln,this.coordinateSystem),cn.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(ln.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),cn.setFromProjectionMatrix(ln,this.coordinateSystem),cn.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(ln.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),cn.setFromProjectionMatrix(ln,this.coordinateSystem),cn.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(ln.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),cn.setFromProjectionMatrix(ln,this.coordinateSystem),cn.containsPoint(t))return!0}return!1}clone(){return new s}};function Uo(s,t){return s-t}function ef(s,t){return s.z-t.z}function nf(s,t){return t.z-s.z}var el=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){let r=this.pool,a=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let o=r[this.index];a.push(o),this.index++,o.start=t,o.count=e,o.z=n,o.index=i}reset(){this.list.length=0,this.index=0}},Fe=new Wt,sf=new Ut(1,1,1),eh=new Wn,rf=new qr,vr=new Le,jn=new Ce,us=new C,nh=new C,af=new C,No=new el,Ae=new be,yr=[];function of(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r<i;r++)for(let a=0;a<n;a++)t.setComponent(r+e,a,s.getComponent(r,a))}else t.array.set(s.array,e*n);t.needsUpdate=!0}function ti(s,t){if(s.constructor!==t.constructor){let e=Math.min(s.length,t.length);for(let n=0;n<e;n++)t[n]=s[n]}else{let e=Math.min(s.length,t.length);t.set(new s.constructor(s.buffer,0,e))}}var nl=class extends be{constructor(t,e,n=e*2,i){super(new _e,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4),n=new Vn(e,t,t,De,Be);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Uint32Array(t*t),n=new Vn(e,t,t,Xs,Ln);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Float32Array(t*t*4).fill(1),n=new Vn(e,t,t,De,Be);n.colorSpace=Jt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){let e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in t.attributes){let a=t.getAttribute(r),{array:o,itemSize:l,normalized:c}=a,h=new o.constructor(n*l),u=new Me(h,l,c);e.setAttribute(r,u)}if(t.getIndex()!==null){let r=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new Me(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){let e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){let e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)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(){this.boundingBox===null&&(this.boundingBox=new Le);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Fe),this.getBoundingBoxAt(r,vr).applyMatrix4(Fe),t.union(vr)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ce);let t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Fe),this.getBoundingSphereAt(r,jn).applyMatrix4(Fe),t.union(jn)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Uo),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let r=this._matricesTexture;Fe.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;let a=this._colorsTexture;return a&&(sf.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);let i={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;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;let a=t.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?a.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Uo),l=this._availableGeometryIds.shift(),r[l]=i):(l=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(l,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),a=e.getIndex(),o=this._geometryInfo[t];if(i&&a.count>o.reservedIndexCount||e.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=e.getAttribute("position").count;for(let h in n.attributes){let u=e.getAttribute(h),d=n.getAttribute(h);of(u,d,l);let p=u.itemSize;for(let g=u.count,x=c;g<x;g++){let m=l+g;for(let f=0;f<p;f++)d.setComponent(m,f,0)}d.needsUpdate=!0,d.addUpdateRange(l*p,c*p)}if(i){let h=o.indexStart,u=o.reservedIndexCount;o.indexCount=e.getIndex().count;for(let d=0;d<a.count;d++)r.setX(h+d,l+a.getX(d));for(let d=a.count,p=u;d<p;d++)r.setX(h+d,l);r.needsUpdate=!0,r.addUpdateRange(h,o.reservedIndexCount)}return o.start=i?o.indexStart:o.vertexStart,o.count=i?o.indexCount:o.vertexCount,o.boundingBox=null,e.boundingBox!==null&&(o.boundingBox=e.boundingBox.clone()),o.boundingSphere=null,e.boundingSphere!==null&&(o.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){let e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;let n=this._instanceInfo;for(let i=0,r=n.length;i<r;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0,n=this._geometryInfo,i=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),r=this.geometry;for(let a=0,o=n.length;a<o;a++){let l=i[a],c=n[l];if(c.active!==!1){if(r.index!==null){if(c.indexStart!==e){let{indexStart:h,vertexStart:u,reservedIndexCount:d}=c,p=r.index,g=p.array,x=t-u;for(let m=h;m<h+d;m++)g[m]=g[m]+x;p.array.copyWithin(e,h,h+d),p.addUpdateRange(e,d),c.indexStart=e}e+=c.reservedIndexCount}if(c.vertexStart!==t){let{vertexStart:h,reservedVertexCount:u}=c,d=r.attributes;for(let p in d){let g=d[p],{array:x,itemSize:m}=g;x.copyWithin(t*m,h*m,(h+u)*m),g.addUpdateRange(t*m,u*m)}c.vertexStart=t}t+=c.reservedVertexCount,c.start=r.index?c.indexStart:c.vertexStart,this._nextIndexStart=r.index?c.indexStart+c.reservedIndexCount:0,this._nextVertexStart=c.vertexStart+c.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){let r=new Le,a=n.index,o=n.attributes.position;for(let l=i.start,c=i.start+i.count;l<c;l++){let h=l;a&&(h=a.getX(h)),r.expandByPoint(us.fromBufferAttribute(o,h))}i.boundingBox=r}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){let r=new Ce;this.getBoundingBoxAt(t,vr),vr.getCenter(r.center);let a=n.index,o=n.attributes.position,l=0;for(let c=i.start,h=i.start+i.count;c<h;c++){let u=c;a&&(u=a.getX(u)),us.fromBufferAttribute(o,u),l=Math.max(l,r.center.distanceToSquared(us))}r.radius=Math.sqrt(l),i.boundingSphere=r}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);let n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,t*16),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);let n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){let e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(Uo);e[e.length-1]===n.length;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);let i=new Int32Array(t),r=new Int32Array(t);ti(this._multiDrawCounts,i),ti(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;let a=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;a.dispose(),this._initIndirectTexture(),ti(a.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),ti(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),ti(l.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){let n=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new _e,this._initializeGeometry(r));let a=this.geometry;r.index&&ti(r.index.array,a.index.array);for(let o in r.attributes)ti(r.attributes[o].array,a.attributes[o].array)}raycast(t,e){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;Ae.material=this.material,Ae.geometry.index=a.index,Ae.geometry.attributes=a.attributes,Ae.geometry.boundingBox===null&&(Ae.geometry.boundingBox=new Le),Ae.geometry.boundingSphere===null&&(Ae.geometry.boundingSphere=new Ce);for(let o=0,l=n.length;o<l;o++){if(!n[o].visible||!n[o].active)continue;let c=n[o].geometryIndex,h=i[c];Ae.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(o,Ae.matrixWorld).premultiply(r),this.getBoundingBoxAt(c,Ae.geometry.boundingBox),this.getBoundingSphereAt(c,Ae.geometry.boundingSphere),Ae.raycast(t,yr);for(let u=0,d=yr.length;u<d;u++){let p=yr[u];p.object=this,p.batchId=o,e.push(p)}yr.length=0}Ae.material=null,Ae.geometry.index=null,Ae.geometry.attributes={},Ae.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),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(),this._colorsTexture!==null&&(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,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,p=this._indirectTexture,g=p.image.data,x=n.isArrayCamera?rf:eh;d&&!n.isArrayCamera&&(Fe.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),eh.setFromProjectionMatrix(Fe,t.coordinateSystem));let m=0;if(this.sortObjects){Fe.copy(this.matrixWorld).invert(),us.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Fe),nh.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Fe);for(let M=0,v=l.length;M<v;M++)if(l[M].visible&&l[M].active){let I=l[M].geometryIndex;this.getMatrixAt(M,Fe),this.getBoundingSphereAt(I,jn).applyMatrix4(Fe);let w=!1;if(d&&(w=!x.intersectsSphere(jn,n)),!w){let R=u[I],D=af.subVectors(jn.center,us).dot(nh);No.push(R.start,R.count,D,M)}}let f=No.list,A=this.customSort;A===null?f.sort(r.transparent?nf:ef):A.call(this,f,n);for(let M=0,v=f.length;M<v;M++){let I=f[M];c[m]=I.start*o,h[m]=I.count,g[m]=I.index,m++}No.reset()}else for(let f=0,A=l.length;f<A;f++)if(l[f].visible&&l[f].active){let M=l[f].geometryIndex,v=!1;if(d&&(this.getMatrixAt(f,Fe),this.getBoundingSphereAt(M,jn).applyMatrix4(Fe),v=!x.intersectsSphere(jn,n)),!v){let I=u[M];c[m]=I.start*o,h[m]=I.count,g[m]=f,m++}}p.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,a){this.onBeforeRender(t,null,i,r,a)}},qi=class extends rn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ut(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},Yr=new C,Zr=new C,ih=new Wt,ds=new Gn,Mr=new Ce,Fo=new C,sh=new C,ws=class extends ge{constructor(t=new _e,e=new qi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)Yr.fromBufferAttribute(e,i-1),Zr.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=Yr.distanceTo(Zr);t.setAttribute("lineDistance",new le(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Mr.copy(n.boundingSphere),Mr.applyMatrix4(i),Mr.radius+=r,t.ray.intersectsSphere(Mr)===!1)return;ih.copy(i).invert(),ds.copy(t.ray).applyMatrix4(ih);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let x=p,m=g-1;x<m;x+=c){let f=h.getX(x),A=h.getX(x+1),M=Sr(this,t,ds,l,f,A,x);M&&e.push(M)}if(this.isLineLoop){let x=h.getX(g-1),m=h.getX(p),f=Sr(this,t,ds,l,x,m,g-1);f&&e.push(f)}}else{let p=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let x=p,m=g-1;x<m;x+=c){let f=Sr(this,t,ds,l,x,x+1,x);f&&e.push(f)}if(this.isLineLoop){let x=Sr(this,t,ds,l,g-1,p,g-1);x&&e.push(x)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function Sr(s,t,e,n,i,r,a){let o=s.geometry.attributes.position;if(Yr.fromBufferAttribute(o,i),Zr.fromBufferAttribute(o,r),e.distanceSqToSegment(Yr,Zr,Fo,sh)>n)return;Fo.applyMatrix4(s.matrixWorld);let c=t.ray.origin.distanceTo(Fo);if(!(c<t.near||c>t.far))return{distance:c,point:sh.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}var rh=new C,ah=new C,Cs=class extends ws{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)rh.fromBufferAttribute(e,i),ah.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+rh.distanceTo(ah);t.setAttribute("lineDistance",new le(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},il=class extends ws{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}},Jr=class extends rn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ut(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},oh=new Wt,sl=new Gn,br=new Ce,Er=new C,rl=class extends ge{constructor(t=new _e,e=new Jr){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),br.copy(n.boundingSphere),br.applyMatrix4(i),br.radius+=r,t.ray.intersectsSphere(br)===!1)return;oh.copy(i).invert(),sl.copy(t.ray).applyMatrix4(oh);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let g=d,x=p;g<x;g++){let m=c.getX(g);Er.fromBufferAttribute(u,m),lh(Er,m,l,i,t,e,this)}}else{let d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let g=d,x=p;g<x;g++)Er.fromBufferAttribute(u,g),lh(Er,g,l,i,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function lh(s,t,e,n,i,r,a){let o=sl.distanceSqToPoint(s);if(o<e){let l=new C;sl.closestPointToPoint(s,l),l.applyMatrix4(n);let c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}var al=class extends Se{constructor(t,e,n,i,r,a,o,l,c,h,u,d){super(null,a,o,l,c,h,i,r,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}};var ol=class extends Se{constructor(t,e,n,i,r,a,o,l,c){super(t,e,n,i,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Rs=class extends Se{constructor(t,e,n=Ln,i,r,a,o=Oe,l=Oe,c,h=zi,u=1){if(h!==zi&&h!==Qi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:t,height:e,depth:u};super(d,i,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Vi(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}};var Tr=new C,Ar=new C,Oo=new C,wr=new bn,ll=class extends _e{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){let i=Math.pow(10,4),r=Math.cos(Oi*e),a=t.getIndex(),o=t.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),d={},p=[];for(let g=0;g<l;g+=3){a?(c[0]=a.getX(g),c[1]=a.getX(g+1),c[2]=a.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);let{a:x,b:m,c:f}=wr;if(x.fromBufferAttribute(o,c[0]),m.fromBufferAttribute(o,c[1]),f.fromBufferAttribute(o,c[2]),wr.getNormal(Oo),u[0]=`${Math.round(x.x*i)},${Math.round(x.y*i)},${Math.round(x.z*i)}`,u[1]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let A=0;A<3;A++){let M=(A+1)%3,v=u[A],I=u[M],w=wr[h[A]],R=wr[h[M]],D=`${v}_${I}`,E=`${I}_${v}`;E in d&&d[E]?(Oo.dot(d[E].normal)<=r&&(p.push(w.x,w.y,w.z),p.push(R.x,R.y,R.z)),d[E]=null):D in d||(d[D]={index0:c[A],index1:c[M],normal:Oo.clone()})}}for(let g in d)if(d[g]){let{index0:x,index1:m}=d[g];Tr.fromBufferAttribute(o,x),Ar.fromBufferAttribute(o,m),p.push(Tr.x,Tr.y,Tr.z),p.push(Ar.x,Ar.y,Ar.z)}this.setAttribute("position",new le(p,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}},Xe=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){let n=this.getLengths(),i=0,r=n.length,a;e?a=e:a=t*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(r-1);let h=n[i],d=n[i+1]-h,p=(a-h)/d;return(i+p)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),o=this.getPoint(r),l=e||(a.isVector2?new ot:new C);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){let n=new C,i=[],r=[],a=[],o=new C,l=new Wt;for(let p=0;p<=t;p++){let g=p/t;i[p]=this.getTangentAt(g,new C)}r[0]=new C,a[0]=new C;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let p=1;p<=t;p++){if(r[p]=r[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(i[p-1],i[p]),o.length()>Number.EPSILON){o.normalize();let g=Math.acos(qt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(o,g))}a[p].crossVectors(i[p],r[p])}if(e===!0){let p=Math.acos(qt(r[0].dot(r[t]),-1,1));p/=t,i[0].dot(o.crossVectors(r[0],r[t]))>0&&(p=-p);for(let g=1;g<=t;g++)r[g].applyMatrix4(l.makeRotationAxis(i[g],p*g)),a[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let 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}},Yi=class extends Xe{constructor(t=0,e=0,n=1,i=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new ot){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(a?r=0:r=i),this.aClockwise===!0&&!a&&(r===i?r=-i:r=r-i);let o=this.aStartAngle+t*r,l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*h-p*u+this.aX,c=d*u+p*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},$r=class extends Yi{constructor(t,e,n,i,r,a){super(t,e,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function nc(){let s=0,t=0,e=0,n=0;function i(r,a,o,l){s=r,t=o,e=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){i(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,u){let d=(a-r)/c-(o-r)/(c+h)+(o-a)/h,p=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,p*=h,i(a,o,d,p)},calc:function(r){let a=r*r,o=a*r;return s+t*r+e*a+n*o}}}var Cr=new C,Bo=new nc,zo=new nc,ko=new nc,Kr=class extends Xe{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new C){let n=e,i=this.points,r=i.length,a=(r-(this.closed?0:1))*t,o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%r]:(Cr.subVectors(i[0],i[1]).add(i[0]),c=Cr);let u=i[o%r],d=i[(o+1)%r];if(this.closed||o+2<r?h=i[(o+2)%r]:(Cr.subVectors(i[r-1],i[r-2]).add(i[r-1]),h=Cr),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(u),p),x=Math.pow(u.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(h),p);x<1e-4&&(x=1),g<1e-4&&(g=x),m<1e-4&&(m=x),Bo.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,x,m),zo.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,x,m),ko.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,x,m)}else this.curveType==="catmullrom"&&(Bo.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),zo.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),ko.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Bo.calc(l),zo.calc(l),ko.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new C().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function ch(s,t,e,n,i){let r=(n-t)*.5,a=(i-e)*.5,o=s*s,l=s*o;return(2*e-2*n+r+a)*l+(-3*e+3*n-2*r-a)*o+r*s+e}function lf(s,t){let e=1-s;return e*e*t}function cf(s,t){return 2*(1-s)*s*t}function hf(s,t){return s*s*t}function gs(s,t,e,n){return lf(s,t)+cf(s,e)+hf(s,n)}function uf(s,t){let e=1-s;return e*e*e*t}function df(s,t){let e=1-s;return 3*e*e*s*t}function ff(s,t){return 3*(1-s)*s*s*t}function pf(s,t){return s*s*s*t}function _s(s,t,e,n,i){return uf(s,t)+df(s,e)+ff(s,n)+pf(s,i)}var Is=class extends Xe{constructor(t=new ot,e=new ot,n=new ot,i=new ot){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new ot){let n=e,i=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(_s(t,i.x,r.x,a.x,o.x),_s(t,i.y,r.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Qr=class extends Xe{constructor(t=new C,e=new C,n=new C,i=new C){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new C){let n=e,i=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(_s(t,i.x,r.x,a.x,o.x),_s(t,i.y,r.y,a.y,o.y),_s(t,i.z,r.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Ps=class extends Xe{constructor(t=new ot,e=new ot){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ot){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new ot){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},jr=class extends Xe{constructor(t=new C,e=new C){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new C){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new C){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ls=class extends Xe{constructor(t=new ot,e=new ot,n=new ot){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new ot){let n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(gs(t,i.x,r.x,a.x),gs(t,i.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ds=class extends Xe{constructor(t=new C,e=new C,n=new C){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new C){let n=e,i=this.v0,r=this.v1,a=this.v2;return n.set(gs(t,i.x,r.x,a.x),gs(t,i.y,r.y,a.y),gs(t,i.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Us=class extends Xe{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ot){let n=e,i=this.points,r=(i.length-1)*t,a=Math.floor(r),o=r-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(ch(o,l.x,c.x,h.x,u.x),ch(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new ot().fromArray(i))}return this}},ta=Object.freeze({__proto__:null,ArcCurve:$r,CatmullRomCurve3:Kr,CubicBezierCurve:Is,CubicBezierCurve3:Qr,EllipseCurve:Yi,LineCurve:Ps,LineCurve3:jr,QuadraticBezierCurve:Ls,QuadraticBezierCurve3:Ds,SplineCurve:Us}),ea=class extends Xe{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ta[n](e,t))}return this}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let a=i[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}r++}return null}getLength(){let 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;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,r=this.curves;i<r.length;i++){let a=r[i],o=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,l=a.getPoints(o);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new ta[i.type]().fromJSON(i))}return this}},Ns=class extends ea{constructor(t){super(),this.type="Path",this.currentPoint=new ot,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Ps(this.currentPoint.clone(),new ot(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let r=new Ls(this.currentPoint.clone(),new ot(t,e),new ot(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,a){let o=new Is(this.currentPoint.clone(),new ot(t,e),new ot(n,i),new ot(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Us(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,a){let o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,i,r,a),this}absarc(t,e,n,i,r,a){return this.absellipse(t,e,n,n,i,r,a),this}ellipse(t,e,n,i,r,a,o,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,i,r,a,o,l),this}absellipse(t,e,n,i,r,a,o,l){let c=new Yi(t,e,n,i,r,a,o,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},na=class extends Ns{constructor(t){super(t),this.uuid=$e(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new Ns().fromJSON(i))}return this}};function mf(s,t,e=2){let n=t&&t.length,i=n?t[0]*e:s.length,r=mu(s,0,i,e,!0),a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(n&&(r=yf(s,t,r,e)),s.length>80*e){o=1/0,l=1/0;let h=-1/0,u=-1/0;for(let d=e;d<i;d+=e){let p=s[d],g=s[d+1];p<o&&(o=p),g<l&&(l=g),p>h&&(h=p),g>u&&(u=g)}c=Math.max(h-o,u-l),c=c!==0?32767/c:0}return Fs(r,a,e,o,l,c,0),a}function mu(s,t,e,n,i){let r;if(i===Pf(s,t,e,n)>0)for(let a=t;a<e;a+=n)r=hh(a/n|0,s[a],s[a+1],r);else for(let a=e-n;a>=t;a-=n)r=hh(a/n|0,s[a],s[a+1],r);return r&&Zi(r,r.next)&&(Bs(r),r=r.next),r}function ci(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Zi(e,e.next)||ue(e.prev,e,e.next)===0)){if(Bs(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Fs(s,t,e,n,i,r,a){if(!s)return;!a&&r&&Tf(s,n,i,r);let o=s;for(;s.prev!==s.next;){let l=s.prev,c=s.next;if(r?_f(s,n,i,r):gf(s)){t.push(l.i,s.i,c.i),Bs(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=xf(ci(s),t),Fs(s,t,e,n,i,r,2)):a===2&&vf(s,t,e,n,i,r):Fs(ci(s),t,e,n,i,r,1);break}}}function gf(s){let t=s.prev,e=s,n=s.next;if(ue(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,o=t.y,l=e.y,c=n.y,h=Math.min(i,r,a),u=Math.min(o,l,c),d=Math.max(i,r,a),p=Math.max(o,l,c),g=n.next;for(;g!==t;){if(g.x>=h&&g.x<=d&&g.y>=u&&g.y<=p&&ps(i,o,r,l,a,c,g.x,g.y)&&ue(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function _f(s,t,e,n){let i=s.prev,r=s,a=s.next;if(ue(i,r,a)>=0)return!1;let o=i.x,l=r.x,c=a.x,h=i.y,u=r.y,d=a.y,p=Math.min(o,l,c),g=Math.min(h,u,d),x=Math.max(o,l,c),m=Math.max(h,u,d),f=cl(p,g,t,e,n),A=cl(x,m,t,e,n),M=s.prevZ,v=s.nextZ;for(;M&&M.z>=f&&v&&v.z<=A;){if(M.x>=p&&M.x<=x&&M.y>=g&&M.y<=m&&M!==i&&M!==a&&ps(o,h,l,u,c,d,M.x,M.y)&&ue(M.prev,M,M.next)>=0||(M=M.prevZ,v.x>=p&&v.x<=x&&v.y>=g&&v.y<=m&&v!==i&&v!==a&&ps(o,h,l,u,c,d,v.x,v.y)&&ue(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;M&&M.z>=f;){if(M.x>=p&&M.x<=x&&M.y>=g&&M.y<=m&&M!==i&&M!==a&&ps(o,h,l,u,c,d,M.x,M.y)&&ue(M.prev,M,M.next)>=0)return!1;M=M.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=x&&v.y>=g&&v.y<=m&&v!==i&&v!==a&&ps(o,h,l,u,c,d,v.x,v.y)&&ue(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function xf(s,t){let e=s;do{let n=e.prev,i=e.next.next;!Zi(n,i)&&_u(n,e,e.next,i)&&Os(n,i)&&Os(i,n)&&(t.push(n.i,e.i,i.i),Bs(e),Bs(e.next),e=s=i),e=e.next}while(e!==s);return ci(e)}function vf(s,t,e,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Cf(a,o)){let l=xu(a,o);a=ci(a,a.next),l=ci(l,l.next),Fs(a,t,e,n,i,r,0),Fs(l,t,e,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function yf(s,t,e,n){let i=[];for(let r=0,a=t.length;r<a;r++){let o=t[r]*n,l=r<a-1?t[r+1]*n:s.length,c=mu(s,o,l,n,!1);c===c.next&&(c.steiner=!0),i.push(wf(c))}i.sort(Mf);for(let r=0;r<i.length;r++)e=Sf(i[r],e);return e}function Mf(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){let n=(s.next.y-s.y)/(s.next.x-s.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=n-i}return e}function Sf(s,t){let e=bf(s,t);if(!e)return t;let n=xu(e,s);return ci(n,n.next),ci(e,e.next)}function bf(s,t){let e=t,n=s.x,i=s.y,r=-1/0,a;if(Zi(s,e))return e;do{if(Zi(s,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let u=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=n&&u>r&&(r=u,a=e.x<e.next.x?e:e.next,u===n))return a}e=e.next}while(e!==t);if(!a)return null;let o=a,l=a.x,c=a.y,h=1/0;e=a;do{if(n>=e.x&&e.x>=l&&n!==e.x&&gu(i<c?n:r,i,l,c,i<c?r:n,i,e.x,e.y)){let u=Math.abs(i-e.y)/(n-e.x);Os(e,s)&&(u<h||u===h&&(e.x>a.x||e.x===a.x&&Ef(a,e)))&&(a=e,h=u)}e=e.next}while(e!==o);return a}function Ef(s,t){return ue(s.prev,s,t.prev)<0&&ue(t.next,s,s.next)<0}function Tf(s,t,e,n){let i=s;do i.z===0&&(i.z=cl(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Af(i)}function Af(s){let t,e=1;do{let n=s,i;s=null;let r=null;for(t=0;n;){t++;let a=n,o=0;for(let c=0;c<e&&(o++,a=a.nextZ,!!a);c++);let l=e;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=a}r.nextZ=null,e*=2}while(t>1);return s}function cl(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function wf(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function gu(s,t,e,n,i,r,a,o){return(i-a)*(t-o)>=(s-a)*(r-o)&&(s-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(i-a)*(n-o)}function ps(s,t,e,n,i,r,a,o){return!(s===a&&t===o)&&gu(s,t,e,n,i,r,a,o)}function Cf(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Rf(s,t)&&(Os(s,t)&&Os(t,s)&&If(s,t)&&(ue(s.prev,s,t.prev)||ue(s,t.prev,t))||Zi(s,t)&&ue(s.prev,s,s.next)>0&&ue(t.prev,t,t.next)>0)}function ue(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Zi(s,t){return s.x===t.x&&s.y===t.y}function _u(s,t,e,n){let i=Ir(ue(s,t,e)),r=Ir(ue(s,t,n)),a=Ir(ue(e,n,s)),o=Ir(ue(e,n,t));return!!(i!==r&&a!==o||i===0&&Rr(s,e,t)||r===0&&Rr(s,n,t)||a===0&&Rr(e,s,n)||o===0&&Rr(e,t,n))}function Rr(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Ir(s){return s>0?1:s<0?-1:0}function Rf(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&_u(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Os(s,t){return ue(s.prev,s,s.next)<0?ue(s,t,s.next)>=0&&ue(s,s.prev,t)>=0:ue(s,t,s.prev)<0||ue(s,s.next,t)<0}function If(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function xu(s,t){let e=hl(s.i,s.x,s.y),n=hl(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function hh(s,t,e,n){let i=hl(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Bs(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function hl(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Pf(s,t,e,n){let i=0;for(let r=t,a=e-n;r<e;r+=n)i+=(s[a]-s[r])*(s[r+1]+s[a+1]),a=r;return i}var ul=class{static triangulate(t,e,n=2){return mf(t,e,n)}},ii=class s{static area(t){let e=t.length,n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return n*.5}static isClockWise(t){return s.area(t)<0}static triangulateShape(t,e){let n=[],i=[],r=[];uh(t),dh(n,t);let a=t.length;e.forEach(uh);for(let l=0;l<e.length;l++)i.push(a),a+=e[l].length,dh(n,e[l]);let o=ul.triangulate(n,i);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}};function uh(s){let t=s.length;t>2&&s[t-1].equals(s[0])&&s.pop()}function dh(s,t){for(let e=0;e<t.length;e++)s.push(t[e].x),s.push(t[e].y)}var dl=class s extends _e{constructor(t=new na([new ot(.5,.5),new ot(-.5,.5),new ot(-.5,-.5),new ot(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let n=this,i=[],r=[];for(let o=0,l=t.length;o<l;o++){let c=t[o];a(c)}this.setAttribute("position",new le(i,3)),this.setAttribute("uv",new le(r,2)),this.computeVertexNormals();function a(o){let l=[],c=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1,d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,p=e.bevelThickness!==void 0?e.bevelThickness:.2,g=e.bevelSize!==void 0?e.bevelSize:p-.1,x=e.bevelOffset!==void 0?e.bevelOffset:0,m=e.bevelSegments!==void 0?e.bevelSegments:3,f=e.extrudePath,A=e.UVGenerator!==void 0?e.UVGenerator:Lf,M,v=!1,I,w,R,D;f&&(M=f.getSpacedPoints(h),v=!0,d=!1,I=f.computeFrenetFrames(h,!1),w=new C,R=new C,D=new C),d||(m=0,p=0,g=0,x=0);let E=o.extractPoints(c),S=E.shape,P=E.holes;if(!ii.isClockWise(S)){S=S.reverse();for(let b=0,rt=P.length;b<rt;b++){let Q=P[b];ii.isClockWise(Q)&&(P[b]=Q.reverse())}}function z(b){let Q=10000000000000001e-36,at=b[0];for(let q=1;q<=b.length;q++){let gt=q%b.length,et=b[gt],_t=et.x-at.x,Bt=et.y-at.y,T=_t*_t+Bt*Bt,_=Math.max(Math.abs(et.x),Math.abs(et.y),Math.abs(at.x),Math.abs(at.y)),F=Q*_*_;if(T<=F){b.splice(gt,1),q--;continue}at=et}}z(S),P.forEach(z);let X=P.length,J=S;for(let b=0;b<X;b++){let rt=P[b];S=S.concat(rt)}function G(b,rt,Q){return rt||console.error("THREE.ExtrudeGeometry: vec does not exist"),b.clone().addScaledVector(rt,Q)}let tt=S.length;function k(b,rt,Q){let at,q,gt,et=b.x-rt.x,_t=b.y-rt.y,Bt=Q.x-b.x,T=Q.y-b.y,_=et*et+_t*_t,F=et*T-_t*Bt;if(Math.abs(F)>Number.EPSILON){let V=Math.sqrt(_),$=Math.sqrt(Bt*Bt+T*T),H=rt.x-_t/V,Tt=rt.y+et/V,ct=Q.x-T/$,St=Q.y+Bt/$,At=((ct-H)*T-(St-Tt)*Bt)/(et*T-_t*Bt);at=H+et*At-b.x,q=Tt+_t*At-b.y;let K=at*at+q*q;if(K<=2)return new ot(at,q);gt=Math.sqrt(K/2)}else{let V=!1;et>Number.EPSILON?Bt>Number.EPSILON&&(V=!0):et<-Number.EPSILON?Bt<-Number.EPSILON&&(V=!0):Math.sign(_t)===Math.sign(T)&&(V=!0),V?(at=-_t,q=et,gt=Math.sqrt(_)):(at=et,q=_t,gt=Math.sqrt(_/2))}return new ot(at/gt,q/gt)}let lt=[];for(let b=0,rt=J.length,Q=rt-1,at=b+1;b<rt;b++,Q++,at++)Q===rt&&(Q=0),at===rt&&(at=0),lt[b]=k(J[b],J[Q],J[at]);let mt=[],Mt,kt=lt.concat();for(let b=0,rt=X;b<rt;b++){let Q=P[b];Mt=[];for(let at=0,q=Q.length,gt=q-1,et=at+1;at<q;at++,gt++,et++)gt===q&&(gt=0),et===q&&(et=0),Mt[at]=k(Q[at],Q[gt],Q[et]);mt.push(Mt),kt=kt.concat(Mt)}let Zt;if(m===0)Zt=ii.triangulateShape(J,P);else{let b=[],rt=[];for(let Q=0;Q<m;Q++){let at=Q/m,q=p*Math.cos(at*Math.PI/2),gt=g*Math.sin(at*Math.PI/2)+x;for(let et=0,_t=J.length;et<_t;et++){let Bt=G(J[et],lt[et],gt);Ht(Bt.x,Bt.y,-q),at===0&&b.push(Bt)}for(let et=0,_t=X;et<_t;et++){let Bt=P[et];Mt=mt[et];let T=[];for(let _=0,F=Bt.length;_<F;_++){let V=G(Bt[_],Mt[_],gt);Ht(V.x,V.y,-q),at===0&&T.push(V)}at===0&&rt.push(T)}}Zt=ii.triangulateShape(b,rt)}let W=Zt.length,st=g+x;for(let b=0;b<tt;b++){let rt=d?G(S[b],kt[b],st):S[b];v?(R.copy(I.normals[0]).multiplyScalar(rt.x),w.copy(I.binormals[0]).multiplyScalar(rt.y),D.copy(M[0]).add(R).add(w),Ht(D.x,D.y,D.z)):Ht(rt.x,rt.y,0)}for(let b=1;b<=h;b++)for(let rt=0;rt<tt;rt++){let Q=d?G(S[rt],kt[rt],st):S[rt];v?(R.copy(I.normals[b]).multiplyScalar(Q.x),w.copy(I.binormals[b]).multiplyScalar(Q.y),D.copy(M[b]).add(R).add(w),Ht(D.x,D.y,D.z)):Ht(Q.x,Q.y,u/h*b)}for(let b=m-1;b>=0;b--){let rt=b/m,Q=p*Math.cos(rt*Math.PI/2),at=g*Math.sin(rt*Math.PI/2)+x;for(let q=0,gt=J.length;q<gt;q++){let et=G(J[q],lt[q],at);Ht(et.x,et.y,u+Q)}for(let q=0,gt=P.length;q<gt;q++){let et=P[q];Mt=mt[q];for(let _t=0,Bt=et.length;_t<Bt;_t++){let T=G(et[_t],Mt[_t],at);v?Ht(T.x,T.y+M[h-1].y,M[h-1].x+Q):Ht(T.x,T.y,u+Q)}}}wt(),pt();function wt(){let b=i.length/3;if(d){let rt=0,Q=tt*rt;for(let at=0;at<W;at++){let q=Zt[at];It(q[2]+Q,q[1]+Q,q[0]+Q)}rt=h+m*2,Q=tt*rt;for(let at=0;at<W;at++){let q=Zt[at];It(q[0]+Q,q[1]+Q,q[2]+Q)}}else{for(let rt=0;rt<W;rt++){let Q=Zt[rt];It(Q[2],Q[1],Q[0])}for(let rt=0;rt<W;rt++){let Q=Zt[rt];It(Q[0]+tt*h,Q[1]+tt*h,Q[2]+tt*h)}}n.addGroup(b,i.length/3-b,0)}function pt(){let b=i.length/3,rt=0;Ct(J,rt),rt+=J.length;for(let Q=0,at=P.length;Q<at;Q++){let q=P[Q];Ct(q,rt),rt+=q.length}n.addGroup(b,i.length/3-b,1)}function Ct(b,rt){let Q=b.length;for(;--Q>=0;){let at=Q,q=Q-1;q<0&&(q=b.length-1);for(let gt=0,et=h+m*2;gt<et;gt++){let _t=tt*gt,Bt=tt*(gt+1),T=rt+at+_t,_=rt+q+_t,F=rt+q+Bt,V=rt+at+Bt;se(T,_,F,V)}}}function Ht(b,rt,Q){l.push(b),l.push(rt),l.push(Q)}function It(b,rt,Q){$t(b),$t(rt),$t(Q);let at=i.length/3,q=A.generateTopUV(n,i,at-3,at-2,at-1);Gt(q[0]),Gt(q[1]),Gt(q[2])}function se(b,rt,Q,at){$t(b),$t(rt),$t(at),$t(rt),$t(Q),$t(at);let q=i.length/3,gt=A.generateSideWallUV(n,i,q-6,q-3,q-2,q-1);Gt(gt[0]),Gt(gt[1]),Gt(gt[3]),Gt(gt[1]),Gt(gt[2]),Gt(gt[3])}function $t(b){i.push(l[b*3+0]),i.push(l[b*3+1]),i.push(l[b*3+2])}function Gt(b){r.push(b.x),r.push(b.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return Df(e,n,t)}static fromJSON(t,e){let n=[];for(let r=0,a=t.shapes.length;r<a;r++){let o=e[t.shapes[r]];n.push(o)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new ta[i.type]().fromJSON(i)),new s(n,t.options)}},Lf={generateTopUV:function(s,t,e,n,i){let r=t[e*3],a=t[e*3+1],o=t[n*3],l=t[n*3+1],c=t[i*3],h=t[i*3+1];return[new ot(r,a),new ot(o,l),new ot(c,h)]},generateSideWallUV:function(s,t,e,n,i,r){let a=t[e*3],o=t[e*3+1],l=t[e*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[i*3],p=t[i*3+1],g=t[i*3+2],x=t[r*3],m=t[r*3+1],f=t[r*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new ot(a,1-l),new ot(c,1-u),new ot(d,1-g),new ot(x,1-f)]:[new ot(o,1-l),new ot(h,1-u),new ot(p,1-g),new ot(m,1-f)]}};function Df(s,t,e){if(e.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){let r=s[n];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}var zs=class s extends _e{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let r=t/2,a=e/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,u=t/o,d=e/l,p=[],g=[],x=[],m=[];for(let f=0;f<h;f++){let A=f*d-a;for(let M=0;M<c;M++){let v=M*u-r;g.push(v,-A,0),x.push(0,0,1),m.push(M/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let A=0;A<o;A++){let M=A+c*f,v=A+c*(f+1),I=A+1+c*(f+1),w=A+1+c*f;p.push(M,v,w),p.push(v,I,w)}this.setIndex(p),this.setAttribute("position",new le(g,3)),this.setAttribute("normal",new le(x,3)),this.setAttribute("uv",new le(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.widthSegments,t.heightSegments)}};var fl=class s extends _e{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let l=Math.min(a+o,Math.PI),c=0,h=[],u=new C,d=new C,p=[],g=[],x=[],m=[];for(let f=0;f<=n;f++){let A=[],M=f/n,v=0;f===0&&a===0?v=.5/e:f===n&&l===Math.PI&&(v=-.5/e);for(let I=0;I<=e;I++){let w=I/e;u.x=-t*Math.cos(i+w*r)*Math.sin(a+M*o),u.y=t*Math.cos(a+M*o),u.z=t*Math.sin(i+w*r)*Math.sin(a+M*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(w+v,1-M),A.push(c++)}h.push(A)}for(let f=0;f<n;f++)for(let A=0;A<e;A++){let M=h[f][A+1],v=h[f][A],I=h[f+1][A],w=h[f+1][A+1];(f!==0||a>0)&&p.push(M,v,w),(f!==n-1||l<Math.PI)&&p.push(v,I,w)}this.setIndex(p),this.setAttribute("position",new le(g,3)),this.setAttribute("normal",new le(x,3)),this.setAttribute("uv",new le(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var pl=class s extends _e{constructor(t=new Ds(new C(-1,-1,0),new C(-1,1,0),new C(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};let a=t.computeFrenetFrames(e,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new C,l=new C,c=new ot,h=new C,u=[],d=[],p=[],g=[];x(),this.setIndex(g),this.setAttribute("position",new le(u,3)),this.setAttribute("normal",new le(d,3)),this.setAttribute("uv",new le(p,2));function x(){for(let M=0;M<e;M++)m(M);m(r===!1?e:0),A(),f()}function m(M){h=t.getPointAt(M/e,h);let v=a.normals[M],I=a.binormals[M];for(let w=0;w<=i;w++){let R=w/i*Math.PI*2,D=Math.sin(R),E=-Math.cos(R);l.x=E*v.x+D*I.x,l.y=E*v.y+D*I.y,l.z=E*v.z+D*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=h.x+n*l.x,o.y=h.y+n*l.y,o.z=h.z+n*l.z,u.push(o.x,o.y,o.z)}}function f(){for(let M=1;M<=e;M++)for(let v=1;v<=i;v++){let I=(i+1)*(M-1)+(v-1),w=(i+1)*M+(v-1),R=(i+1)*M+v,D=(i+1)*(M-1)+v;g.push(I,w,D),g.push(w,R,D)}}function A(){for(let M=0;M<=e;M++)for(let v=0;v<=i;v++)c.x=M/e,c.y=v/i,p.push(c.x,c.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new s(new ta[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}};var ia=class extends rn{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ut(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=no,this.normalScale=new ot(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ke,this.envMapIntensity=1,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.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,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.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,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}},ml=class extends ia{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ot(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ut(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ut(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ut(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=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}};var gl=class extends rn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ut(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=no,this.normalScale=new ot(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ke,this.combine=ya,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}},sa=class extends rn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=jh,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}},ra=class extends rn{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}};function Pr(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function Uf(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Nf(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function fh(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){let o=e[r]*t;for(let l=0;l!==t;++l)i[a++]=s[o+l]}return i}function vu(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}var hi=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let a=0;a!==i;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},aa=class extends hi{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Xo,endingEnd:Xo}}intervalChanged_(t,e,n){let i=this.parameterPositions,r=t-2,a=t+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case qo:r=t,o=2*e-n;break;case Yo:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case qo:a=t,l=2*n-e;break;case Yo:a=1,l=n+i[1]-i[0];break;default:a=t-1,l=e}let c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,i){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,g=(n-e)/(i-e),x=g*g,m=x*g,f=-d*m+2*d*x-d*g,A=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*g+1,M=(-1-p)*m+(1.5+p)*x+.5*g,v=p*m-p*x;for(let I=0;I!==o;++I)r[I]=f*a[h+I]+A*a[c+I]+M*a[l+I]+v*a[u+I];return r}},oa=class extends hi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[c+d]*u+a[l+d]*h;return r}},la=class extends hi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},ze=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Pr(e,this.TimeBufferType),this.values=Pr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Pr(t.times,Array),values:Pr(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new la(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new oa(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new aa(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case xs:e=this.InterpolantFactoryMethodDiscrete;break;case Br:e=this.InterpolantFactoryMethodLinear;break;case Dr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return xs;case this.InterpolantFactoryMethodLinear:return Br;case this.InterpolantFactoryMethodSmooth:return Dr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(i!==void 0&&Uf(i))for(let o=0,l=i.length;o!==l;++o){let c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Dr,r=t.length-1,a=1;for(let o=1;o<r;++o){let l=!1,c=t[o],h=t[o+1];if(c!==h&&(o!==1||c!==t[0]))if(i)l=!0;else{let u=o*n,d=u-n,p=u+n;for(let g=0;g!==n;++g){let x=e[u+g];if(x!==e[d+g]||x!==e[p+g]){l=!0;break}}}if(l){if(o!==a){t[a]=t[o];let u=o*n,d=a*n;for(let p=0;p!==n;++p)e[d+p]=e[u+p]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};ze.prototype.ValueTypeName="";ze.prototype.TimeBufferType=Float32Array;ze.prototype.ValueBufferType=Float32Array;ze.prototype.DefaultInterpolation=Br;var Cn=class extends ze{constructor(t,e,n){super(t,e,n)}};Cn.prototype.ValueTypeName="bool";Cn.prototype.ValueBufferType=Array;Cn.prototype.DefaultInterpolation=xs;Cn.prototype.InterpolantFactoryMethodLinear=void 0;Cn.prototype.InterpolantFactoryMethodSmooth=void 0;var ks=class extends ze{constructor(t,e,n,i){super(t,e,n,i)}};ks.prototype.ValueTypeName="color";var ui=class extends ze{constructor(t,e,n,i){super(t,e,n,i)}};ui.prototype.ValueTypeName="number";var ca=class extends hi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(i-e),c=t*o;for(let h=c+o;c!==h;c+=4)wn.slerpFlat(r,0,a,c-o,a,c,l);return r}},di=class extends ze{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new ca(this.times,this.values,this.getValueSize(),t)}};di.prototype.ValueTypeName="quaternion";di.prototype.InterpolantFactoryMethodSmooth=void 0;var Rn=class extends ze{constructor(t,e,n){super(t,e,n)}};Rn.prototype.ValueTypeName="string";Rn.prototype.ValueBufferType=Array;Rn.prototype.DefaultInterpolation=xs;Rn.prototype.InterpolantFactoryMethodLinear=void 0;Rn.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends ze{constructor(t,e,n,i){super(t,e,n,i)}};fi.prototype.ValueTypeName="vector";var _l=class{constructor(t="",e=-1,n=[],i=Qh){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=$e(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(Of(n[a]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,a=n.length;r!==a;++r)e.push(ze.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let h=Nf(l);l=fh(l,1,h),c=fh(c,1,h),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new ui(".morphTargetInfluences["+e[o].name+"]",l,c).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=t.length;o<l;o++){let c=t[o],h=c.name.match(r);if(h&&h.length>1){let u=h[1],d=i[u];d||(i[u]=d=[]),d.push(c)}}let a=[];for(let o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}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;let n=function(u,d,p,g,x){if(p.length!==0){let m=[],f=[];vu(p,m,f,g),m.length!==0&&x.push(new u(d,m,f))}},i=[],r=t.name||"default",a=t.fps||30,o=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let u=0;u<c.length;u++){let d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let p={},g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let x=0;x<d[g].morphTargets.length;x++)p[d[g].morphTargets[x]]=-1;for(let x in p){let m=[],f=[];for(let A=0;A!==d[g].morphTargets.length;++A){let M=d[g];m.push(M.time),f.push(M.morphTarget===x?1:0)}i.push(new ui(".morphTargetInfluence["+x+"]",m,f))}l=p.length*a}else{let p=".bones["+e[u].name+"]";n(fi,p+".position",d,"pos",i),n(di,p+".quaternion",d,"rot",i),n(fi,p+".scale",d,"scl",i)}}return i.length===0?null:new this(r,l,i,o)}resetDuration(){let t=this.tracks,e=0;for(let n=0,i=t.length;n!==i;++n){let r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Ff(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ui;case"vector":case"vector2":case"vector3":case"vector4":return fi;case"color":return ks;case"quaternion":return di;case"bool":case"boolean":return Cn;case"string":return Rn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Of(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Ff(s.type);if(s.times===void 0){let e=[],n=[];vu(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}var un={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(this.files[s]=t)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}},ha=class{constructor(t,e,n){let i=this,r=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){let p=c[u],g=c[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null}}},yu=new ha,Xn=class{constructor(t){this.manager=t!==void 0?t:yu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};Xn.DEFAULT_MATERIAL_NAME="__DEFAULT";var Sn={},xl=class extends Error{constructor(t,e){super(t),this.response=e}},vl=class extends Xn{constructor(t){super(t),this.mimeType="",this.responseType=""}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=un.get(`file:${t}`);if(r!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(Sn[t]!==void 0){Sn[t].push({onLoad:e,onProgress:n,onError:i});return}Sn[t]=[],Sn[t].push({onLoad:e,onProgress:n,onError:i});let a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Sn[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,g=p!==0,x=0,m=new ReadableStream({start(f){A();function A(){u.read().then(({done:M,value:v})=>{if(M)f.close();else{x+=v.byteLength;let I=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:p});for(let w=0,R=h.length;w<R;w++){let D=h[w];D.onProgress&&D.onProgress(I)}f.enqueue(v),A()}},M=>{f.error(M)})}}});return new Response(m)}else throw new xl(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{un.add(`file:${t}`,c);let h=Sn[t];delete Sn[t];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onLoad&&p.onLoad(c)}}).catch(c=>{let h=Sn[t];if(h===void 0)throw this.manager.itemError(t),c;delete Sn[t];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onError&&p.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Fi=new WeakMap,ua=class extends Xn{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,a=un.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);else{let u=Fi.get(a);u===void 0&&(u=[],Fi.set(a,u)),u.push({onLoad:e,onError:i})}return a}let o=ki("img");function l(){h(),e&&e(this);let u=Fi.get(this)||[];for(let d=0;d<u.length;d++){let p=u[d];p.onLoad&&p.onLoad(this)}Fi.delete(this),r.manager.itemEnd(t)}function c(u){h(),i&&i(u),un.remove(`image:${t}`);let d=Fi.get(this)||[];for(let p=0;p<d.length;p++){let g=d[p];g.onError&&g.onError(u)}Fi.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),un.add(`image:${t}`,o),r.manager.itemStart(t),o.src=t,o}};var yl=class extends Xn{constructor(t){super(t)}load(t,e,n,i){let r=new Se,a=new ua(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}},pi=class extends ge{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ut(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}};var Vo=new Wt,ph=new C,mh=new C,Vs=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ot(512,512),this.mapType=on,this.map=null,this.mapPass=null,this.matrix=new Wt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wn,this._frameExtents=new ot(1,1),this._viewportCount=1,this._viewports=[new Qt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;ph.setFromMatrixPosition(t.matrixWorld),e.position.copy(ph),mh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(mh),e.updateMatrixWorld(),Vo.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vo),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Vo)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Ml=class extends Vs{constructor(){super(new we(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){let e=this.camera,n=oi*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Sl=class extends pi{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Ml}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},gh=new Wt,fs=new C,Ho=new C,bl=class extends Vs{constructor(){super(new we(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ot(4,2),this._viewportCount=6,this._viewports=[new Qt(2,1,1,1),new Qt(0,1,1,1),new Qt(3,1,1,1),new Qt(1,1,1,1),new Qt(3,0,1,1),new Qt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),fs.setFromMatrixPosition(t.matrixWorld),n.position.copy(fs),Ho.copy(n.position),Ho.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Ho),n.updateMatrixWorld(),i.makeTranslation(-fs.x,-fs.y,-fs.z),gh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gh)}},El=class extends pi{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new bl}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Hs=class extends Wi{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,a=n+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},Tl=class extends Vs{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Al=class extends pi{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.shadow=new Tl}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},wl=class extends pi{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}};var Cl=class{static extractUrlBase(t){let e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||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)}},Rl=class extends _e{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}};var Go=new WeakMap,Il=class extends Xn{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,a=un.get(`image-bitmap:${t}`);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(c=>{if(Go.has(a)===!0)i&&i(Go.get(a)),r.manager.itemError(t),r.manager.itemEnd(t);else return e&&e(c),r.manager.itemEnd(t),c});return}return setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0),a}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;let l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return un.add(`image-bitmap:${t}`,c),e&&e(c),r.manager.itemEnd(t),c}).catch(function(c){i&&i(c),Go.set(l,c),un.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});un.add(`image-bitmap:${t}`,l),r.manager.itemStart(t)}};var da=class extends we{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}},Pl=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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){let e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};var ic="\\[\\]\\.:\\/",Bf=new RegExp("["+ic+"]","g"),sc="[^"+ic+"]",zf="[^"+ic.replace("\\.","")+"]",kf=/((?:WC+[\/:])*)/.source.replace("WC",sc),Vf=/(WCOD+)?/.source.replace("WCOD",zf),Hf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",sc),Gf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",sc),Wf=new RegExp("^"+kf+Vf+Hf+Gf+"$"),Xf=["material","materials","bones","map"],Ll=class{constructor(t,e,n){let i=n||oe.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},oe=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Bf,"")}static parseTrackName(t){let e=Wf.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);Xf.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let l=n(o.children);if(l)return l}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=s.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let a=t[i];if(a===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};oe.Composite=Ll;oe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};oe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};oe.prototype.GetterByBindingType=[oe.prototype._getValue_direct,oe.prototype._getValue_array,oe.prototype._getValue_arrayElement,oe.prototype._getValue_toArray];oe.prototype.SetterByBindingTypeAndVersioning=[[oe.prototype._setValue_direct,oe.prototype._setValue_direct_setNeedsUpdate,oe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[oe.prototype._setValue_array,oe.prototype._setValue_array_setNeedsUpdate,oe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[oe.prototype._setValue_arrayElement,oe.prototype._setValue_arrayElement_setNeedsUpdate,oe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[oe.prototype._setValue_fromArray,oe.prototype._setValue_fromArray_setNeedsUpdate,oe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var bx=new Float32Array(1);var _h=new Wt,Dl=class{constructor(t,e,n=0,i=1/0){this.ray=new Gn(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Hi,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return _h.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_h),this}intersectObject(t,e=!0,n=[]){return Ul(t,this,n,e),n.sort(xh),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Ul(t[i],this,n,e);return n.sort(xh),n}};function xh(s,t){return s.distance-t.distance}function Ul(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){let r=s.children;for(let a=0,o=r.length;a<o;a++)Ul(r[a],t,e,!0)}}var vh=new ot,Nl=class{constructor(t=new ot(1/0,1/0),e=new ot(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=vh.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=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,vh).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)}};var Lr=new C,fe=new Wi,Fl=class extends Cs{constructor(t){let e=new _e,n=new qi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(g,x){l(g),l(x)}function l(g){i.push(0,0,0),r.push(0,0,0),a[g]===void 0&&(a[g]=[]),a[g].push(i.length/3-1)}e.setAttribute("position",new le(i,3)),e.setAttribute("color",new le(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let c=new Ut(16755200),h=new Ut(16711680),u=new Ut(43775),d=new Ut(16777215),p=new Ut(3355443);this.setColors(c,h,u,d,p)}setColors(t,e,n,i,r){let o=this.geometry.getAttribute("color");o.setXYZ(0,t.r,t.g,t.b),o.setXYZ(1,t.r,t.g,t.b),o.setXYZ(2,t.r,t.g,t.b),o.setXYZ(3,t.r,t.g,t.b),o.setXYZ(4,t.r,t.g,t.b),o.setXYZ(5,t.r,t.g,t.b),o.setXYZ(6,t.r,t.g,t.b),o.setXYZ(7,t.r,t.g,t.b),o.setXYZ(8,t.r,t.g,t.b),o.setXYZ(9,t.r,t.g,t.b),o.setXYZ(10,t.r,t.g,t.b),o.setXYZ(11,t.r,t.g,t.b),o.setXYZ(12,t.r,t.g,t.b),o.setXYZ(13,t.r,t.g,t.b),o.setXYZ(14,t.r,t.g,t.b),o.setXYZ(15,t.r,t.g,t.b),o.setXYZ(16,t.r,t.g,t.b),o.setXYZ(17,t.r,t.g,t.b),o.setXYZ(18,t.r,t.g,t.b),o.setXYZ(19,t.r,t.g,t.b),o.setXYZ(20,t.r,t.g,t.b),o.setXYZ(21,t.r,t.g,t.b),o.setXYZ(22,t.r,t.g,t.b),o.setXYZ(23,t.r,t.g,t.b),o.setXYZ(24,e.r,e.g,e.b),o.setXYZ(25,e.r,e.g,e.b),o.setXYZ(26,e.r,e.g,e.b),o.setXYZ(27,e.r,e.g,e.b),o.setXYZ(28,e.r,e.g,e.b),o.setXYZ(29,e.r,e.g,e.b),o.setXYZ(30,e.r,e.g,e.b),o.setXYZ(31,e.r,e.g,e.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,n=1,i=1;fe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);let r=this.camera.coordinateSystem===Je?-1:0;pe("c",e,t,fe,0,0,r),pe("t",e,t,fe,0,0,1),pe("n1",e,t,fe,-n,-i,r),pe("n2",e,t,fe,n,-i,r),pe("n3",e,t,fe,-n,i,r),pe("n4",e,t,fe,n,i,r),pe("f1",e,t,fe,-n,-i,1),pe("f2",e,t,fe,n,-i,1),pe("f3",e,t,fe,-n,i,1),pe("f4",e,t,fe,n,i,1),pe("u1",e,t,fe,n*.7,i*1.1,r),pe("u2",e,t,fe,-n*.7,i*1.1,r),pe("u3",e,t,fe,0,i*2,r),pe("cf1",e,t,fe,-n,0,1),pe("cf2",e,t,fe,n,0,1),pe("cf3",e,t,fe,0,-i,1),pe("cf4",e,t,fe,0,i,1),pe("cn1",e,t,fe,-n,0,r),pe("cn2",e,t,fe,n,0,r),pe("cn3",e,t,fe,0,-i,r),pe("cn4",e,t,fe,0,i,r),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pe(s,t,e,n,i,r,a){Lr.set(i,r,a).unproject(n);let o=t[s];if(o!==void 0){let l=e.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],Lr.x,Lr.y,Lr.z)}}var Ol=class extends Cs{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new _e;i.setAttribute("position",new le(e,3)),i.setAttribute("color",new le(n,3));let r=new qi({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new Ut,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};function rc(s,t,e,n){let i=qf(n);switch(e){case Yl:return s*t;case wa:return s*t/i.components*i.byteLength;case Xs:return s*t/i.components*i.byteLength;case Jl:return s*t*2/i.components*i.byteLength;case Ca:return s*t*2/i.components*i.byteLength;case Zl:return s*t*3/i.components*i.byteLength;case De:return s*t*4/i.components*i.byteLength;case Ra:return s*t*4/i.components*i.byteLength;case qs:case Ys:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Zs:case Js:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Pa:case Da:return Math.max(s,16)*Math.max(t,8)/4;case Ia:case La:return Math.max(s,8)*Math.max(t,8)/2;case Ua:case Na:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Fa:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Oa:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Ba:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case za:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case ka:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case Va:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case Ha:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case Ga:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case Wa:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case Xa:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case qa:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case Ya:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case Za:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case Ja:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case $a:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case $s:case Ka:case Qa:return Math.ceil(s/4)*Math.ceil(t/4)*16;case $l:case ja:return Math.ceil(s/4)*Math.ceil(t/4)*8;case to:case eo:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function qf(s){switch(s){case on:case Wl:return{byteLength:1,components:1};case Ji:case Xl:case $i:return{byteLength:2,components:1};case Ta:case Aa:return{byteLength:2,components:4};case Ln:case Ea:case Be:return{byteLength:4,components:1};case ql:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"178"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="178");ss();function Xu(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function Zf(s){let t=new WeakMap;function e(o,l){let c=o.array,h=o.usage,u=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=s.SHORT;else if(c instanceof Uint32Array)p=s.UNSIGNED_INT;else if(c instanceof Int32Array)p=s.INT;else if(c instanceof Int8Array)p=s.BYTE;else if(c instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){let h=l.array,u=l.updateRanges;if(s.bindBuffer(c,o),u.length===0)s.bufferSubData(c,0,h);else{u.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<u.length;p++){let g=u[d],x=u[p];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,u[d]=x)}u.length=d+1;for(let p=0,g=u.length;p<g;p++){let x=u[p];s.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=t.get(o);l&&(s.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var Jf=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,$f=`#ifdef USE_ALPHAHASH
43
+ const float ALPHA_HASH_SCALE = 0.05;
44
+ float hash2D( vec2 value ) {
45
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
+ }
47
+ float hash3D( vec3 value ) {
48
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
+ }
50
+ float getAlphaHashThreshold( vec3 position ) {
51
+ float maxDeriv = max(
52
+ length( dFdx( position.xyz ) ),
53
+ length( dFdy( position.xyz ) )
54
+ );
55
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
+ vec2 pixScales = vec2(
57
+ exp2( floor( log2( pixScale ) ) ),
58
+ exp2( ceil( log2( pixScale ) ) )
59
+ );
60
+ vec2 alpha = vec2(
61
+ hash3D( floor( pixScales.x * position.xyz ) ),
62
+ hash3D( floor( pixScales.y * position.xyz ) )
63
+ );
64
+ float lerpFactor = fract( log2( pixScale ) );
65
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
+ float a = min( lerpFactor, 1.0 - lerpFactor );
67
+ vec3 cases = vec3(
68
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
+ ( x - 0.5 * a ) / ( 1.0 - a ),
70
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
+ );
72
+ float threshold = ( x < ( 1.0 - a ) )
73
+ ? ( ( x < a ) ? cases.x : cases.y )
74
+ : cases.z;
75
+ return clamp( threshold , 1.0e-6, 1.0 );
76
+ }
77
+ #endif`,Kf=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,Qf=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,jf=`#ifdef USE_ALPHATEST
82
+ #ifdef ALPHA_TO_COVERAGE
83
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
+ if ( diffuseColor.a == 0.0 ) discard;
85
+ #else
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif
88
+ #endif`,tp=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,ep=`#ifdef USE_AOMAP
91
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
93
+ #if defined( USE_CLEARCOAT )
94
+ clearcoatSpecularIndirect *= ambientOcclusion;
95
+ #endif
96
+ #if defined( USE_SHEEN )
97
+ sheenSpecularIndirect *= ambientOcclusion;
98
+ #endif
99
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
100
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
+ #endif
103
+ #endif`,np=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,ip=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,sp=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,rp=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,ap=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,op=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,lp=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,cp=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,hp=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,up=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,dp=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,fp=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,pp=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,mp=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,gp=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,_p=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,xp=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ mat3 transposeMat3( const in mat3 m ) {
375
+ mat3 tmp;
376
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
377
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
378
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
379
+ return tmp;
380
+ }
381
+ bool isPerspectiveMatrix( mat4 m ) {
382
+ return m[ 2 ][ 3 ] == - 1.0;
383
+ }
384
+ vec2 equirectUv( in vec3 dir ) {
385
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
386
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
387
+ return vec2( u, v );
388
+ }
389
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
390
+ return RECIPROCAL_PI * diffuseColor;
391
+ }
392
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
393
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
394
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
395
+ }
396
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
+ } // validated`,vp=`#ifdef ENVMAP_TYPE_CUBE_UV
400
+ #define cubeUV_minMipLevel 4.0
401
+ #define cubeUV_minTileSize 16.0
402
+ float getFace( vec3 direction ) {
403
+ vec3 absDirection = abs( direction );
404
+ float face = - 1.0;
405
+ if ( absDirection.x > absDirection.z ) {
406
+ if ( absDirection.x > absDirection.y )
407
+ face = direction.x > 0.0 ? 0.0 : 3.0;
408
+ else
409
+ face = direction.y > 0.0 ? 1.0 : 4.0;
410
+ } else {
411
+ if ( absDirection.z > absDirection.y )
412
+ face = direction.z > 0.0 ? 2.0 : 5.0;
413
+ else
414
+ face = direction.y > 0.0 ? 1.0 : 4.0;
415
+ }
416
+ return face;
417
+ }
418
+ vec2 getUV( vec3 direction, float face ) {
419
+ vec2 uv;
420
+ if ( face == 0.0 ) {
421
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
422
+ } else if ( face == 1.0 ) {
423
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
424
+ } else if ( face == 2.0 ) {
425
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
426
+ } else if ( face == 3.0 ) {
427
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
428
+ } else if ( face == 4.0 ) {
429
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
430
+ } else {
431
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
432
+ }
433
+ return 0.5 * ( uv + 1.0 );
434
+ }
435
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
436
+ float face = getFace( direction );
437
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
438
+ mipInt = max( mipInt, cubeUV_minMipLevel );
439
+ float faceSize = exp2( mipInt );
440
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
441
+ if ( face > 2.0 ) {
442
+ uv.y += faceSize;
443
+ face -= 3.0;
444
+ }
445
+ uv.x += face * faceSize;
446
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
447
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
448
+ uv.x *= CUBEUV_TEXEL_WIDTH;
449
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
450
+ #ifdef texture2DGradEXT
451
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
452
+ #else
453
+ return texture2D( envMap, uv ).rgb;
454
+ #endif
455
+ }
456
+ #define cubeUV_r0 1.0
457
+ #define cubeUV_m0 - 2.0
458
+ #define cubeUV_r1 0.8
459
+ #define cubeUV_m1 - 1.0
460
+ #define cubeUV_r4 0.4
461
+ #define cubeUV_m4 2.0
462
+ #define cubeUV_r5 0.305
463
+ #define cubeUV_m5 3.0
464
+ #define cubeUV_r6 0.21
465
+ #define cubeUV_m6 4.0
466
+ float roughnessToMip( float roughness ) {
467
+ float mip = 0.0;
468
+ if ( roughness >= cubeUV_r1 ) {
469
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
470
+ } else if ( roughness >= cubeUV_r4 ) {
471
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
472
+ } else if ( roughness >= cubeUV_r5 ) {
473
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
474
+ } else if ( roughness >= cubeUV_r6 ) {
475
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
476
+ } else {
477
+ mip = - 2.0 * log2( 1.16 * roughness ); }
478
+ return mip;
479
+ }
480
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
481
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
482
+ float mipF = fract( mip );
483
+ float mipInt = floor( mip );
484
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
485
+ if ( mipF == 0.0 ) {
486
+ return vec4( color0, 1.0 );
487
+ } else {
488
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
489
+ return vec4( mix( color0, color1, mipF ), 1.0 );
490
+ }
491
+ }
492
+ #endif`,yp=`vec3 transformedNormal = objectNormal;
493
+ #ifdef USE_TANGENT
494
+ vec3 transformedTangent = objectTangent;
495
+ #endif
496
+ #ifdef USE_BATCHING
497
+ mat3 bm = mat3( batchingMatrix );
498
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
499
+ transformedNormal = bm * transformedNormal;
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = bm * transformedTangent;
502
+ #endif
503
+ #endif
504
+ #ifdef USE_INSTANCING
505
+ mat3 im = mat3( instanceMatrix );
506
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
507
+ transformedNormal = im * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = im * transformedTangent;
510
+ #endif
511
+ #endif
512
+ transformedNormal = normalMatrix * transformedNormal;
513
+ #ifdef FLIP_SIDED
514
+ transformedNormal = - transformedNormal;
515
+ #endif
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
518
+ #ifdef FLIP_SIDED
519
+ transformedTangent = - transformedTangent;
520
+ #endif
521
+ #endif`,Mp=`#ifdef USE_DISPLACEMENTMAP
522
+ uniform sampler2D displacementMap;
523
+ uniform float displacementScale;
524
+ uniform float displacementBias;
525
+ #endif`,Sp=`#ifdef USE_DISPLACEMENTMAP
526
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
+ #endif`,bp=`#ifdef USE_EMISSIVEMAP
528
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
530
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
531
+ #endif
532
+ totalEmissiveRadiance *= emissiveColor.rgb;
533
+ #endif`,Ep=`#ifdef USE_EMISSIVEMAP
534
+ uniform sampler2D emissiveMap;
535
+ #endif`,Tp="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ap=`vec4 LinearTransferOETF( in vec4 value ) {
536
+ return value;
537
+ }
538
+ vec4 sRGBTransferEOTF( in vec4 value ) {
539
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
540
+ }
541
+ vec4 sRGBTransferOETF( in vec4 value ) {
542
+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
543
+ }`,wp=`#ifdef USE_ENVMAP
544
+ #ifdef ENV_WORLDPOS
545
+ vec3 cameraToFrag;
546
+ if ( isOrthographic ) {
547
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
548
+ } else {
549
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
550
+ }
551
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
552
+ #ifdef ENVMAP_MODE_REFLECTION
553
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
554
+ #else
555
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
556
+ #endif
557
+ #else
558
+ vec3 reflectVec = vReflect;
559
+ #endif
560
+ #ifdef ENVMAP_TYPE_CUBE
561
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
562
+ #else
563
+ vec4 envColor = vec4( 0.0 );
564
+ #endif
565
+ #ifdef ENVMAP_BLENDING_MULTIPLY
566
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
567
+ #elif defined( ENVMAP_BLENDING_MIX )
568
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
569
+ #elif defined( ENVMAP_BLENDING_ADD )
570
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
571
+ #endif
572
+ #endif`,Cp=`#ifdef USE_ENVMAP
573
+ uniform float envMapIntensity;
574
+ uniform float flipEnvMap;
575
+ uniform mat3 envMapRotation;
576
+ #ifdef ENVMAP_TYPE_CUBE
577
+ uniform samplerCube envMap;
578
+ #else
579
+ uniform sampler2D envMap;
580
+ #endif
581
+
582
+ #endif`,Rp=`#ifdef USE_ENVMAP
583
+ uniform float reflectivity;
584
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
585
+ #define ENV_WORLDPOS
586
+ #endif
587
+ #ifdef ENV_WORLDPOS
588
+ varying vec3 vWorldPosition;
589
+ uniform float refractionRatio;
590
+ #else
591
+ varying vec3 vReflect;
592
+ #endif
593
+ #endif`,Ip=`#ifdef USE_ENVMAP
594
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
595
+ #define ENV_WORLDPOS
596
+ #endif
597
+ #ifdef ENV_WORLDPOS
598
+
599
+ varying vec3 vWorldPosition;
600
+ #else
601
+ varying vec3 vReflect;
602
+ uniform float refractionRatio;
603
+ #endif
604
+ #endif`,Pp=`#ifdef USE_ENVMAP
605
+ #ifdef ENV_WORLDPOS
606
+ vWorldPosition = worldPosition.xyz;
607
+ #else
608
+ vec3 cameraToVertex;
609
+ if ( isOrthographic ) {
610
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
611
+ } else {
612
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
613
+ }
614
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
615
+ #ifdef ENVMAP_MODE_REFLECTION
616
+ vReflect = reflect( cameraToVertex, worldNormal );
617
+ #else
618
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
619
+ #endif
620
+ #endif
621
+ #endif`,Lp=`#ifdef USE_FOG
622
+ vFogDepth = - mvPosition.z;
623
+ #endif`,Dp=`#ifdef USE_FOG
624
+ varying float vFogDepth;
625
+ #endif`,Up=`#ifdef USE_FOG
626
+ #ifdef FOG_EXP2
627
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
628
+ #else
629
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
630
+ #endif
631
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
632
+ #endif`,Np=`#ifdef USE_FOG
633
+ uniform vec3 fogColor;
634
+ varying float vFogDepth;
635
+ #ifdef FOG_EXP2
636
+ uniform float fogDensity;
637
+ #else
638
+ uniform float fogNear;
639
+ uniform float fogFar;
640
+ #endif
641
+ #endif`,Fp=`#ifdef USE_GRADIENTMAP
642
+ uniform sampler2D gradientMap;
643
+ #endif
644
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
645
+ float dotNL = dot( normal, lightDirection );
646
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
647
+ #ifdef USE_GRADIENTMAP
648
+ return vec3( texture2D( gradientMap, coord ).r );
649
+ #else
650
+ vec2 fw = fwidth( coord ) * 0.5;
651
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
652
+ #endif
653
+ }`,Op=`#ifdef USE_LIGHTMAP
654
+ uniform sampler2D lightMap;
655
+ uniform float lightMapIntensity;
656
+ #endif`,Bp=`LambertMaterial material;
657
+ material.diffuseColor = diffuseColor.rgb;
658
+ material.specularStrength = specularStrength;`,zp=`varying vec3 vViewPosition;
659
+ struct LambertMaterial {
660
+ vec3 diffuseColor;
661
+ float specularStrength;
662
+ };
663
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
664
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
665
+ vec3 irradiance = dotNL * directLight.color;
666
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
667
+ }
668
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
669
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
670
+ }
671
+ #define RE_Direct RE_Direct_Lambert
672
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,kp=`uniform bool receiveShadow;
673
+ uniform vec3 ambientLightColor;
674
+ #if defined( USE_LIGHT_PROBES )
675
+ uniform vec3 lightProbe[ 9 ];
676
+ #endif
677
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
678
+ float x = normal.x, y = normal.y, z = normal.z;
679
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
680
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
681
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
682
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
683
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
684
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
685
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
686
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
687
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
688
+ return result;
689
+ }
690
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
691
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
692
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
693
+ return irradiance;
694
+ }
695
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
696
+ vec3 irradiance = ambientLightColor;
697
+ return irradiance;
698
+ }
699
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
700
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
701
+ if ( cutoffDistance > 0.0 ) {
702
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
703
+ }
704
+ return distanceFalloff;
705
+ }
706
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
707
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
708
+ }
709
+ #if NUM_DIR_LIGHTS > 0
710
+ struct DirectionalLight {
711
+ vec3 direction;
712
+ vec3 color;
713
+ };
714
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
715
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
716
+ light.color = directionalLight.color;
717
+ light.direction = directionalLight.direction;
718
+ light.visible = true;
719
+ }
720
+ #endif
721
+ #if NUM_POINT_LIGHTS > 0
722
+ struct PointLight {
723
+ vec3 position;
724
+ vec3 color;
725
+ float distance;
726
+ float decay;
727
+ };
728
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
729
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
730
+ vec3 lVector = pointLight.position - geometryPosition;
731
+ light.direction = normalize( lVector );
732
+ float lightDistance = length( lVector );
733
+ light.color = pointLight.color;
734
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
735
+ light.visible = ( light.color != vec3( 0.0 ) );
736
+ }
737
+ #endif
738
+ #if NUM_SPOT_LIGHTS > 0
739
+ struct SpotLight {
740
+ vec3 position;
741
+ vec3 direction;
742
+ vec3 color;
743
+ float distance;
744
+ float decay;
745
+ float coneCos;
746
+ float penumbraCos;
747
+ };
748
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
749
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
750
+ vec3 lVector = spotLight.position - geometryPosition;
751
+ light.direction = normalize( lVector );
752
+ float angleCos = dot( light.direction, spotLight.direction );
753
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
754
+ if ( spotAttenuation > 0.0 ) {
755
+ float lightDistance = length( lVector );
756
+ light.color = spotLight.color * spotAttenuation;
757
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
758
+ light.visible = ( light.color != vec3( 0.0 ) );
759
+ } else {
760
+ light.color = vec3( 0.0 );
761
+ light.visible = false;
762
+ }
763
+ }
764
+ #endif
765
+ #if NUM_RECT_AREA_LIGHTS > 0
766
+ struct RectAreaLight {
767
+ vec3 color;
768
+ vec3 position;
769
+ vec3 halfWidth;
770
+ vec3 halfHeight;
771
+ };
772
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
773
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
774
+ #endif
775
+ #if NUM_HEMI_LIGHTS > 0
776
+ struct HemisphereLight {
777
+ vec3 direction;
778
+ vec3 skyColor;
779
+ vec3 groundColor;
780
+ };
781
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
782
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
783
+ float dotNL = dot( normal, hemiLight.direction );
784
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
785
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
786
+ return irradiance;
787
+ }
788
+ #endif`,Vp=`#ifdef USE_ENVMAP
789
+ vec3 getIBLIrradiance( const in vec3 normal ) {
790
+ #ifdef ENVMAP_TYPE_CUBE_UV
791
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
792
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
793
+ return PI * envMapColor.rgb * envMapIntensity;
794
+ #else
795
+ return vec3( 0.0 );
796
+ #endif
797
+ }
798
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
799
+ #ifdef ENVMAP_TYPE_CUBE_UV
800
+ vec3 reflectVec = reflect( - viewDir, normal );
801
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
802
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
803
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
804
+ return envMapColor.rgb * envMapIntensity;
805
+ #else
806
+ return vec3( 0.0 );
807
+ #endif
808
+ }
809
+ #ifdef USE_ANISOTROPY
810
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
811
+ #ifdef ENVMAP_TYPE_CUBE_UV
812
+ vec3 bentNormal = cross( bitangent, viewDir );
813
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
814
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
815
+ return getIBLRadiance( viewDir, bentNormal, roughness );
816
+ #else
817
+ return vec3( 0.0 );
818
+ #endif
819
+ }
820
+ #endif
821
+ #endif`,Hp=`ToonMaterial material;
822
+ material.diffuseColor = diffuseColor.rgb;`,Gp=`varying vec3 vViewPosition;
823
+ struct ToonMaterial {
824
+ vec3 diffuseColor;
825
+ };
826
+ void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
827
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
828
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
829
+ }
830
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
831
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
832
+ }
833
+ #define RE_Direct RE_Direct_Toon
834
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Wp=`BlinnPhongMaterial material;
835
+ material.diffuseColor = diffuseColor.rgb;
836
+ material.specularColor = specular;
837
+ material.specularShininess = shininess;
838
+ material.specularStrength = specularStrength;`,Xp=`varying vec3 vViewPosition;
839
+ struct BlinnPhongMaterial {
840
+ vec3 diffuseColor;
841
+ vec3 specularColor;
842
+ float specularShininess;
843
+ float specularStrength;
844
+ };
845
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
846
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
847
+ vec3 irradiance = dotNL * directLight.color;
848
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
849
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
850
+ }
851
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
852
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
+ }
854
+ #define RE_Direct RE_Direct_BlinnPhong
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qp=`PhysicalMaterial material;
856
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
857
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
858
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
859
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
860
+ material.roughness = min( material.roughness, 1.0 );
861
+ #ifdef IOR
862
+ material.ior = ior;
863
+ #ifdef USE_SPECULAR
864
+ float specularIntensityFactor = specularIntensity;
865
+ vec3 specularColorFactor = specularColor;
866
+ #ifdef USE_SPECULAR_COLORMAP
867
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
868
+ #endif
869
+ #ifdef USE_SPECULAR_INTENSITYMAP
870
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
871
+ #endif
872
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
873
+ #else
874
+ float specularIntensityFactor = 1.0;
875
+ vec3 specularColorFactor = vec3( 1.0 );
876
+ material.specularF90 = 1.0;
877
+ #endif
878
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
879
+ #else
880
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
881
+ material.specularF90 = 1.0;
882
+ #endif
883
+ #ifdef USE_CLEARCOAT
884
+ material.clearcoat = clearcoat;
885
+ material.clearcoatRoughness = clearcoatRoughness;
886
+ material.clearcoatF0 = vec3( 0.04 );
887
+ material.clearcoatF90 = 1.0;
888
+ #ifdef USE_CLEARCOATMAP
889
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
890
+ #endif
891
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
892
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
893
+ #endif
894
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
895
+ material.clearcoatRoughness += geometryRoughness;
896
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
897
+ #endif
898
+ #ifdef USE_DISPERSION
899
+ material.dispersion = dispersion;
900
+ #endif
901
+ #ifdef USE_IRIDESCENCE
902
+ material.iridescence = iridescence;
903
+ material.iridescenceIOR = iridescenceIOR;
904
+ #ifdef USE_IRIDESCENCEMAP
905
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
906
+ #endif
907
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
908
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
909
+ #else
910
+ material.iridescenceThickness = iridescenceThicknessMaximum;
911
+ #endif
912
+ #endif
913
+ #ifdef USE_SHEEN
914
+ material.sheenColor = sheenColor;
915
+ #ifdef USE_SHEEN_COLORMAP
916
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
917
+ #endif
918
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
919
+ #ifdef USE_SHEEN_ROUGHNESSMAP
920
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
921
+ #endif
922
+ #endif
923
+ #ifdef USE_ANISOTROPY
924
+ #ifdef USE_ANISOTROPYMAP
925
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
926
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
927
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
928
+ #else
929
+ vec2 anisotropyV = anisotropyVector;
930
+ #endif
931
+ material.anisotropy = length( anisotropyV );
932
+ if( material.anisotropy == 0.0 ) {
933
+ anisotropyV = vec2( 1.0, 0.0 );
934
+ } else {
935
+ anisotropyV /= material.anisotropy;
936
+ material.anisotropy = saturate( material.anisotropy );
937
+ }
938
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
939
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
940
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
941
+ #endif`,Yp=`struct PhysicalMaterial {
942
+ vec3 diffuseColor;
943
+ float roughness;
944
+ vec3 specularColor;
945
+ float specularF90;
946
+ float dispersion;
947
+ #ifdef USE_CLEARCOAT
948
+ float clearcoat;
949
+ float clearcoatRoughness;
950
+ vec3 clearcoatF0;
951
+ float clearcoatF90;
952
+ #endif
953
+ #ifdef USE_IRIDESCENCE
954
+ float iridescence;
955
+ float iridescenceIOR;
956
+ float iridescenceThickness;
957
+ vec3 iridescenceFresnel;
958
+ vec3 iridescenceF0;
959
+ #endif
960
+ #ifdef USE_SHEEN
961
+ vec3 sheenColor;
962
+ float sheenRoughness;
963
+ #endif
964
+ #ifdef IOR
965
+ float ior;
966
+ #endif
967
+ #ifdef USE_TRANSMISSION
968
+ float transmission;
969
+ float transmissionAlpha;
970
+ float thickness;
971
+ float attenuationDistance;
972
+ vec3 attenuationColor;
973
+ #endif
974
+ #ifdef USE_ANISOTROPY
975
+ float anisotropy;
976
+ float alphaT;
977
+ vec3 anisotropyT;
978
+ vec3 anisotropyB;
979
+ #endif
980
+ };
981
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
982
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
983
+ vec3 sheenSpecularDirect = vec3( 0.0 );
984
+ vec3 sheenSpecularIndirect = vec3(0.0 );
985
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
986
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
987
+ float x2 = x * x;
988
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
989
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
990
+ }
991
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
992
+ float a2 = pow2( alpha );
993
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
994
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
995
+ return 0.5 / max( gv + gl, EPSILON );
996
+ }
997
+ float D_GGX( const in float alpha, const in float dotNH ) {
998
+ float a2 = pow2( alpha );
999
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1000
+ return RECIPROCAL_PI * a2 / pow2( denom );
1001
+ }
1002
+ #ifdef USE_ANISOTROPY
1003
+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1004
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1005
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1006
+ float v = 0.5 / ( gv + gl );
1007
+ return saturate(v);
1008
+ }
1009
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1010
+ float a2 = alphaT * alphaB;
1011
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1012
+ highp float v2 = dot( v, v );
1013
+ float w2 = a2 / v2;
1014
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1015
+ }
1016
+ #endif
1017
+ #ifdef USE_CLEARCOAT
1018
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1019
+ vec3 f0 = material.clearcoatF0;
1020
+ float f90 = material.clearcoatF90;
1021
+ float roughness = material.clearcoatRoughness;
1022
+ float alpha = pow2( roughness );
1023
+ vec3 halfDir = normalize( lightDir + viewDir );
1024
+ float dotNL = saturate( dot( normal, lightDir ) );
1025
+ float dotNV = saturate( dot( normal, viewDir ) );
1026
+ float dotNH = saturate( dot( normal, halfDir ) );
1027
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1028
+ vec3 F = F_Schlick( f0, f90, dotVH );
1029
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1030
+ float D = D_GGX( alpha, dotNH );
1031
+ return F * ( V * D );
1032
+ }
1033
+ #endif
1034
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1035
+ vec3 f0 = material.specularColor;
1036
+ float f90 = material.specularF90;
1037
+ float roughness = material.roughness;
1038
+ float alpha = pow2( roughness );
1039
+ vec3 halfDir = normalize( lightDir + viewDir );
1040
+ float dotNL = saturate( dot( normal, lightDir ) );
1041
+ float dotNV = saturate( dot( normal, viewDir ) );
1042
+ float dotNH = saturate( dot( normal, halfDir ) );
1043
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1044
+ vec3 F = F_Schlick( f0, f90, dotVH );
1045
+ #ifdef USE_IRIDESCENCE
1046
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1047
+ #endif
1048
+ #ifdef USE_ANISOTROPY
1049
+ float dotTL = dot( material.anisotropyT, lightDir );
1050
+ float dotTV = dot( material.anisotropyT, viewDir );
1051
+ float dotTH = dot( material.anisotropyT, halfDir );
1052
+ float dotBL = dot( material.anisotropyB, lightDir );
1053
+ float dotBV = dot( material.anisotropyB, viewDir );
1054
+ float dotBH = dot( material.anisotropyB, halfDir );
1055
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1056
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1057
+ #else
1058
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1059
+ float D = D_GGX( alpha, dotNH );
1060
+ #endif
1061
+ return F * ( V * D );
1062
+ }
1063
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1064
+ const float LUT_SIZE = 64.0;
1065
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1066
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1067
+ float dotNV = saturate( dot( N, V ) );
1068
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1069
+ uv = uv * LUT_SCALE + LUT_BIAS;
1070
+ return uv;
1071
+ }
1072
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1073
+ float l = length( f );
1074
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1075
+ }
1076
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1077
+ float x = dot( v1, v2 );
1078
+ float y = abs( x );
1079
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1080
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1081
+ float v = a / b;
1082
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1083
+ return cross( v1, v2 ) * theta_sintheta;
1084
+ }
1085
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1086
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1087
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1088
+ vec3 lightNormal = cross( v1, v2 );
1089
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1090
+ vec3 T1, T2;
1091
+ T1 = normalize( V - N * dot( V, N ) );
1092
+ T2 = - cross( N, T1 );
1093
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1094
+ vec3 coords[ 4 ];
1095
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1096
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1097
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1098
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1099
+ coords[ 0 ] = normalize( coords[ 0 ] );
1100
+ coords[ 1 ] = normalize( coords[ 1 ] );
1101
+ coords[ 2 ] = normalize( coords[ 2 ] );
1102
+ coords[ 3 ] = normalize( coords[ 3 ] );
1103
+ vec3 vectorFormFactor = vec3( 0.0 );
1104
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1105
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1106
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1107
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1108
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1109
+ return vec3( result );
1110
+ }
1111
+ #if defined( USE_SHEEN )
1112
+ float D_Charlie( float roughness, float dotNH ) {
1113
+ float alpha = pow2( roughness );
1114
+ float invAlpha = 1.0 / alpha;
1115
+ float cos2h = dotNH * dotNH;
1116
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1117
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1118
+ }
1119
+ float V_Neubelt( float dotNV, float dotNL ) {
1120
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1121
+ }
1122
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1123
+ vec3 halfDir = normalize( lightDir + viewDir );
1124
+ float dotNL = saturate( dot( normal, lightDir ) );
1125
+ float dotNV = saturate( dot( normal, viewDir ) );
1126
+ float dotNH = saturate( dot( normal, halfDir ) );
1127
+ float D = D_Charlie( sheenRoughness, dotNH );
1128
+ float V = V_Neubelt( dotNV, dotNL );
1129
+ return sheenColor * ( D * V );
1130
+ }
1131
+ #endif
1132
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float r2 = roughness * roughness;
1135
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1136
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1137
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1138
+ return saturate( DG * RECIPROCAL_PI );
1139
+ }
1140
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1143
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1144
+ vec4 r = roughness * c0 + c1;
1145
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1146
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1147
+ return fab;
1148
+ }
1149
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1150
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1151
+ return specularColor * fab.x + specularF90 * fab.y;
1152
+ }
1153
+ #ifdef USE_IRIDESCENCE
1154
+ void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1155
+ #else
1156
+ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1157
+ #endif
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ #ifdef USE_IRIDESCENCE
1160
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1161
+ #else
1162
+ vec3 Fr = specularColor;
1163
+ #endif
1164
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1165
+ float Ess = fab.x + fab.y;
1166
+ float Ems = 1.0 - Ess;
1167
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1168
+ singleScatter += FssEss;
1169
+ multiScatter += Fms * Ems;
1170
+ }
1171
+ #if NUM_RECT_AREA_LIGHTS > 0
1172
+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1173
+ vec3 normal = geometryNormal;
1174
+ vec3 viewDir = geometryViewDir;
1175
+ vec3 position = geometryPosition;
1176
+ vec3 lightPos = rectAreaLight.position;
1177
+ vec3 halfWidth = rectAreaLight.halfWidth;
1178
+ vec3 halfHeight = rectAreaLight.halfHeight;
1179
+ vec3 lightColor = rectAreaLight.color;
1180
+ float roughness = material.roughness;
1181
+ vec3 rectCoords[ 4 ];
1182
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1183
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1184
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1185
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1186
+ vec4 t1 = texture2D( ltc_1, uv );
1187
+ vec4 t2 = texture2D( ltc_2, uv );
1188
+ mat3 mInv = mat3(
1189
+ vec3( t1.x, 0, t1.y ),
1190
+ vec3( 0, 1, 0 ),
1191
+ vec3( t1.z, 0, t1.w )
1192
+ );
1193
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1194
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1195
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1196
+ }
1197
+ #endif
1198
+ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1199
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1200
+ vec3 irradiance = dotNL * directLight.color;
1201
+ #ifdef USE_CLEARCOAT
1202
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1203
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1204
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1205
+ #endif
1206
+ #ifdef USE_SHEEN
1207
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1208
+ #endif
1209
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1210
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1211
+ }
1212
+ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1213
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1214
+ }
1215
+ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1216
+ #ifdef USE_CLEARCOAT
1217
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1218
+ #endif
1219
+ #ifdef USE_SHEEN
1220
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1221
+ #endif
1222
+ vec3 singleScattering = vec3( 0.0 );
1223
+ vec3 multiScattering = vec3( 0.0 );
1224
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1225
+ #ifdef USE_IRIDESCENCE
1226
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1227
+ #else
1228
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1229
+ #endif
1230
+ vec3 totalScattering = singleScattering + multiScattering;
1231
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1232
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1233
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1234
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1235
+ }
1236
+ #define RE_Direct RE_Direct_Physical
1237
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1238
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1239
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1240
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1241
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1242
+ }`,Zp=`
1243
+ vec3 geometryPosition = - vViewPosition;
1244
+ vec3 geometryNormal = normal;
1245
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1246
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1247
+ #ifdef USE_CLEARCOAT
1248
+ geometryClearcoatNormal = clearcoatNormal;
1249
+ #endif
1250
+ #ifdef USE_IRIDESCENCE
1251
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1252
+ if ( material.iridescenceThickness == 0.0 ) {
1253
+ material.iridescence = 0.0;
1254
+ } else {
1255
+ material.iridescence = saturate( material.iridescence );
1256
+ }
1257
+ if ( material.iridescence > 0.0 ) {
1258
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1259
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1260
+ }
1261
+ #endif
1262
+ IncidentLight directLight;
1263
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1264
+ PointLight pointLight;
1265
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1266
+ PointLightShadow pointLightShadow;
1267
+ #endif
1268
+ #pragma unroll_loop_start
1269
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1270
+ pointLight = pointLights[ i ];
1271
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1272
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1273
+ pointLightShadow = pointLightShadows[ i ];
1274
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1275
+ #endif
1276
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1277
+ }
1278
+ #pragma unroll_loop_end
1279
+ #endif
1280
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1281
+ SpotLight spotLight;
1282
+ vec4 spotColor;
1283
+ vec3 spotLightCoord;
1284
+ bool inSpotLightMap;
1285
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1286
+ SpotLightShadow spotLightShadow;
1287
+ #endif
1288
+ #pragma unroll_loop_start
1289
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1290
+ spotLight = spotLights[ i ];
1291
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1292
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1293
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1294
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1295
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1296
+ #else
1297
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1298
+ #endif
1299
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1300
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1301
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1302
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1303
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1304
+ #endif
1305
+ #undef SPOT_LIGHT_MAP_INDEX
1306
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1307
+ spotLightShadow = spotLightShadows[ i ];
1308
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1309
+ #endif
1310
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1311
+ }
1312
+ #pragma unroll_loop_end
1313
+ #endif
1314
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1315
+ DirectionalLight directionalLight;
1316
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1317
+ DirectionalLightShadow directionalLightShadow;
1318
+ #endif
1319
+ #pragma unroll_loop_start
1320
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1321
+ directionalLight = directionalLights[ i ];
1322
+ getDirectionalLightInfo( directionalLight, directLight );
1323
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1324
+ directionalLightShadow = directionalLightShadows[ i ];
1325
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1326
+ #endif
1327
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1328
+ }
1329
+ #pragma unroll_loop_end
1330
+ #endif
1331
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1332
+ RectAreaLight rectAreaLight;
1333
+ #pragma unroll_loop_start
1334
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1335
+ rectAreaLight = rectAreaLights[ i ];
1336
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1337
+ }
1338
+ #pragma unroll_loop_end
1339
+ #endif
1340
+ #if defined( RE_IndirectDiffuse )
1341
+ vec3 iblIrradiance = vec3( 0.0 );
1342
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1343
+ #if defined( USE_LIGHT_PROBES )
1344
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1345
+ #endif
1346
+ #if ( NUM_HEMI_LIGHTS > 0 )
1347
+ #pragma unroll_loop_start
1348
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1349
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1350
+ }
1351
+ #pragma unroll_loop_end
1352
+ #endif
1353
+ #endif
1354
+ #if defined( RE_IndirectSpecular )
1355
+ vec3 radiance = vec3( 0.0 );
1356
+ vec3 clearcoatRadiance = vec3( 0.0 );
1357
+ #endif`,Jp=`#if defined( RE_IndirectDiffuse )
1358
+ #ifdef USE_LIGHTMAP
1359
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1360
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1361
+ irradiance += lightMapIrradiance;
1362
+ #endif
1363
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1364
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1365
+ #endif
1366
+ #endif
1367
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1368
+ #ifdef USE_ANISOTROPY
1369
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1370
+ #else
1371
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1372
+ #endif
1373
+ #ifdef USE_CLEARCOAT
1374
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1375
+ #endif
1376
+ #endif`,$p=`#if defined( RE_IndirectDiffuse )
1377
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1378
+ #endif
1379
+ #if defined( RE_IndirectSpecular )
1380
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1381
+ #endif`,Kp=`#if defined( USE_LOGDEPTHBUF )
1382
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1383
+ #endif`,Qp=`#if defined( USE_LOGDEPTHBUF )
1384
+ uniform float logDepthBufFC;
1385
+ varying float vFragDepth;
1386
+ varying float vIsPerspective;
1387
+ #endif`,jp=`#ifdef USE_LOGDEPTHBUF
1388
+ varying float vFragDepth;
1389
+ varying float vIsPerspective;
1390
+ #endif`,tm=`#ifdef USE_LOGDEPTHBUF
1391
+ vFragDepth = 1.0 + gl_Position.w;
1392
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1393
+ #endif`,em=`#ifdef USE_MAP
1394
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1395
+ #ifdef DECODE_VIDEO_TEXTURE
1396
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1397
+ #endif
1398
+ diffuseColor *= sampledDiffuseColor;
1399
+ #endif`,nm=`#ifdef USE_MAP
1400
+ uniform sampler2D map;
1401
+ #endif`,im=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1402
+ #if defined( USE_POINTS_UV )
1403
+ vec2 uv = vUv;
1404
+ #else
1405
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1406
+ #endif
1407
+ #endif
1408
+ #ifdef USE_MAP
1409
+ diffuseColor *= texture2D( map, uv );
1410
+ #endif
1411
+ #ifdef USE_ALPHAMAP
1412
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1413
+ #endif`,sm=`#if defined( USE_POINTS_UV )
1414
+ varying vec2 vUv;
1415
+ #else
1416
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1417
+ uniform mat3 uvTransform;
1418
+ #endif
1419
+ #endif
1420
+ #ifdef USE_MAP
1421
+ uniform sampler2D map;
1422
+ #endif
1423
+ #ifdef USE_ALPHAMAP
1424
+ uniform sampler2D alphaMap;
1425
+ #endif`,rm=`float metalnessFactor = metalness;
1426
+ #ifdef USE_METALNESSMAP
1427
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1428
+ metalnessFactor *= texelMetalness.b;
1429
+ #endif`,am=`#ifdef USE_METALNESSMAP
1430
+ uniform sampler2D metalnessMap;
1431
+ #endif`,om=`#ifdef USE_INSTANCING_MORPH
1432
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1433
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1434
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1435
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1436
+ }
1437
+ #endif`,lm=`#if defined( USE_MORPHCOLORS )
1438
+ vColor *= morphTargetBaseInfluence;
1439
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1440
+ #if defined( USE_COLOR_ALPHA )
1441
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1442
+ #elif defined( USE_COLOR )
1443
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1444
+ #endif
1445
+ }
1446
+ #endif`,cm=`#ifdef USE_MORPHNORMALS
1447
+ objectNormal *= morphTargetBaseInfluence;
1448
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1449
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1450
+ }
1451
+ #endif`,hm=`#ifdef USE_MORPHTARGETS
1452
+ #ifndef USE_INSTANCING_MORPH
1453
+ uniform float morphTargetBaseInfluence;
1454
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1455
+ #endif
1456
+ uniform sampler2DArray morphTargetsTexture;
1457
+ uniform ivec2 morphTargetsTextureSize;
1458
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1459
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1460
+ int y = texelIndex / morphTargetsTextureSize.x;
1461
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1462
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1463
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1464
+ }
1465
+ #endif`,um=`#ifdef USE_MORPHTARGETS
1466
+ transformed *= morphTargetBaseInfluence;
1467
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1469
+ }
1470
+ #endif`,dm=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1471
+ #ifdef FLAT_SHADED
1472
+ vec3 fdx = dFdx( vViewPosition );
1473
+ vec3 fdy = dFdy( vViewPosition );
1474
+ vec3 normal = normalize( cross( fdx, fdy ) );
1475
+ #else
1476
+ vec3 normal = normalize( vNormal );
1477
+ #ifdef DOUBLE_SIDED
1478
+ normal *= faceDirection;
1479
+ #endif
1480
+ #endif
1481
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1482
+ #ifdef USE_TANGENT
1483
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1484
+ #else
1485
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1486
+ #if defined( USE_NORMALMAP )
1487
+ vNormalMapUv
1488
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1489
+ vClearcoatNormalMapUv
1490
+ #else
1491
+ vUv
1492
+ #endif
1493
+ );
1494
+ #endif
1495
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1496
+ tbn[0] *= faceDirection;
1497
+ tbn[1] *= faceDirection;
1498
+ #endif
1499
+ #endif
1500
+ #ifdef USE_CLEARCOAT_NORMALMAP
1501
+ #ifdef USE_TANGENT
1502
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1503
+ #else
1504
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1505
+ #endif
1506
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1507
+ tbn2[0] *= faceDirection;
1508
+ tbn2[1] *= faceDirection;
1509
+ #endif
1510
+ #endif
1511
+ vec3 nonPerturbedNormal = normal;`,fm=`#ifdef USE_NORMALMAP_OBJECTSPACE
1512
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1513
+ #ifdef FLIP_SIDED
1514
+ normal = - normal;
1515
+ #endif
1516
+ #ifdef DOUBLE_SIDED
1517
+ normal = normal * faceDirection;
1518
+ #endif
1519
+ normal = normalize( normalMatrix * normal );
1520
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1521
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1522
+ mapN.xy *= normalScale;
1523
+ normal = normalize( tbn * mapN );
1524
+ #elif defined( USE_BUMPMAP )
1525
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1526
+ #endif`,pm=`#ifndef FLAT_SHADED
1527
+ varying vec3 vNormal;
1528
+ #ifdef USE_TANGENT
1529
+ varying vec3 vTangent;
1530
+ varying vec3 vBitangent;
1531
+ #endif
1532
+ #endif`,mm=`#ifndef FLAT_SHADED
1533
+ varying vec3 vNormal;
1534
+ #ifdef USE_TANGENT
1535
+ varying vec3 vTangent;
1536
+ varying vec3 vBitangent;
1537
+ #endif
1538
+ #endif`,gm=`#ifndef FLAT_SHADED
1539
+ vNormal = normalize( transformedNormal );
1540
+ #ifdef USE_TANGENT
1541
+ vTangent = normalize( transformedTangent );
1542
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1543
+ #endif
1544
+ #endif`,_m=`#ifdef USE_NORMALMAP
1545
+ uniform sampler2D normalMap;
1546
+ uniform vec2 normalScale;
1547
+ #endif
1548
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1549
+ uniform mat3 normalMatrix;
1550
+ #endif
1551
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1552
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1553
+ vec3 q0 = dFdx( eye_pos.xyz );
1554
+ vec3 q1 = dFdy( eye_pos.xyz );
1555
+ vec2 st0 = dFdx( uv.st );
1556
+ vec2 st1 = dFdy( uv.st );
1557
+ vec3 N = surf_norm;
1558
+ vec3 q1perp = cross( q1, N );
1559
+ vec3 q0perp = cross( N, q0 );
1560
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1561
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1562
+ float det = max( dot( T, T ), dot( B, B ) );
1563
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1564
+ return mat3( T * scale, B * scale, N );
1565
+ }
1566
+ #endif`,xm=`#ifdef USE_CLEARCOAT
1567
+ vec3 clearcoatNormal = nonPerturbedNormal;
1568
+ #endif`,vm=`#ifdef USE_CLEARCOAT_NORMALMAP
1569
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1570
+ clearcoatMapN.xy *= clearcoatNormalScale;
1571
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1572
+ #endif`,ym=`#ifdef USE_CLEARCOATMAP
1573
+ uniform sampler2D clearcoatMap;
1574
+ #endif
1575
+ #ifdef USE_CLEARCOAT_NORMALMAP
1576
+ uniform sampler2D clearcoatNormalMap;
1577
+ uniform vec2 clearcoatNormalScale;
1578
+ #endif
1579
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1580
+ uniform sampler2D clearcoatRoughnessMap;
1581
+ #endif`,Mm=`#ifdef USE_IRIDESCENCEMAP
1582
+ uniform sampler2D iridescenceMap;
1583
+ #endif
1584
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1585
+ uniform sampler2D iridescenceThicknessMap;
1586
+ #endif`,Sm=`#ifdef OPAQUE
1587
+ diffuseColor.a = 1.0;
1588
+ #endif
1589
+ #ifdef USE_TRANSMISSION
1590
+ diffuseColor.a *= material.transmissionAlpha;
1591
+ #endif
1592
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bm=`vec3 packNormalToRGB( const in vec3 normal ) {
1593
+ return normalize( normal ) * 0.5 + 0.5;
1594
+ }
1595
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1596
+ return 2.0 * rgb.xyz - 1.0;
1597
+ }
1598
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1599
+ const float Inv255 = 1. / 255.;
1600
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1601
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1602
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1603
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1604
+ vec4 packDepthToRGBA( const in float v ) {
1605
+ if( v <= 0.0 )
1606
+ return vec4( 0., 0., 0., 0. );
1607
+ if( v >= 1.0 )
1608
+ return vec4( 1., 1., 1., 1. );
1609
+ float vuf;
1610
+ float af = modf( v * PackFactors.a, vuf );
1611
+ float bf = modf( vuf * ShiftRight8, vuf );
1612
+ float gf = modf( vuf * ShiftRight8, vuf );
1613
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1614
+ }
1615
+ vec3 packDepthToRGB( const in float v ) {
1616
+ if( v <= 0.0 )
1617
+ return vec3( 0., 0., 0. );
1618
+ if( v >= 1.0 )
1619
+ return vec3( 1., 1., 1. );
1620
+ float vuf;
1621
+ float bf = modf( v * PackFactors.b, vuf );
1622
+ float gf = modf( vuf * ShiftRight8, vuf );
1623
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1624
+ }
1625
+ vec2 packDepthToRG( const in float v ) {
1626
+ if( v <= 0.0 )
1627
+ return vec2( 0., 0. );
1628
+ if( v >= 1.0 )
1629
+ return vec2( 1., 1. );
1630
+ float vuf;
1631
+ float gf = modf( v * 256., vuf );
1632
+ return vec2( vuf * Inv255, gf );
1633
+ }
1634
+ float unpackRGBAToDepth( const in vec4 v ) {
1635
+ return dot( v, UnpackFactors4 );
1636
+ }
1637
+ float unpackRGBToDepth( const in vec3 v ) {
1638
+ return dot( v, UnpackFactors3 );
1639
+ }
1640
+ float unpackRGToDepth( const in vec2 v ) {
1641
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1642
+ }
1643
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1644
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1645
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1646
+ }
1647
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1648
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1649
+ }
1650
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1651
+ return ( viewZ + near ) / ( near - far );
1652
+ }
1653
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1654
+ return depth * ( near - far ) - near;
1655
+ }
1656
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1657
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1658
+ }
1659
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1660
+ return ( near * far ) / ( ( far - near ) * depth - far );
1661
+ }`,Em=`#ifdef PREMULTIPLIED_ALPHA
1662
+ gl_FragColor.rgb *= gl_FragColor.a;
1663
+ #endif`,Tm=`vec4 mvPosition = vec4( transformed, 1.0 );
1664
+ #ifdef USE_BATCHING
1665
+ mvPosition = batchingMatrix * mvPosition;
1666
+ #endif
1667
+ #ifdef USE_INSTANCING
1668
+ mvPosition = instanceMatrix * mvPosition;
1669
+ #endif
1670
+ mvPosition = modelViewMatrix * mvPosition;
1671
+ gl_Position = projectionMatrix * mvPosition;`,Am=`#ifdef DITHERING
1672
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1673
+ #endif`,wm=`#ifdef DITHERING
1674
+ vec3 dithering( vec3 color ) {
1675
+ float grid_position = rand( gl_FragCoord.xy );
1676
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1677
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1678
+ return color + dither_shift_RGB;
1679
+ }
1680
+ #endif`,Cm=`float roughnessFactor = roughness;
1681
+ #ifdef USE_ROUGHNESSMAP
1682
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1683
+ roughnessFactor *= texelRoughness.g;
1684
+ #endif`,Rm=`#ifdef USE_ROUGHNESSMAP
1685
+ uniform sampler2D roughnessMap;
1686
+ #endif`,Im=`#if NUM_SPOT_LIGHT_COORDS > 0
1687
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1688
+ #endif
1689
+ #if NUM_SPOT_LIGHT_MAPS > 0
1690
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1691
+ #endif
1692
+ #ifdef USE_SHADOWMAP
1693
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1694
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1695
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1696
+ struct DirectionalLightShadow {
1697
+ float shadowIntensity;
1698
+ float shadowBias;
1699
+ float shadowNormalBias;
1700
+ float shadowRadius;
1701
+ vec2 shadowMapSize;
1702
+ };
1703
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1704
+ #endif
1705
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1706
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1707
+ struct SpotLightShadow {
1708
+ float shadowIntensity;
1709
+ float shadowBias;
1710
+ float shadowNormalBias;
1711
+ float shadowRadius;
1712
+ vec2 shadowMapSize;
1713
+ };
1714
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1715
+ #endif
1716
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1717
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1718
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1719
+ struct PointLightShadow {
1720
+ float shadowIntensity;
1721
+ float shadowBias;
1722
+ float shadowNormalBias;
1723
+ float shadowRadius;
1724
+ vec2 shadowMapSize;
1725
+ float shadowCameraNear;
1726
+ float shadowCameraFar;
1727
+ };
1728
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1729
+ #endif
1730
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1731
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1732
+ }
1733
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1734
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1735
+ }
1736
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1737
+ float occlusion = 1.0;
1738
+ vec2 distribution = texture2DDistribution( shadow, uv );
1739
+ float hard_shadow = step( compare , distribution.x );
1740
+ if (hard_shadow != 1.0 ) {
1741
+ float distance = compare - distribution.x ;
1742
+ float variance = max( 0.00000, distribution.y * distribution.y );
1743
+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1744
+ }
1745
+ return occlusion;
1746
+ }
1747
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1748
+ float shadow = 1.0;
1749
+ shadowCoord.xyz /= shadowCoord.w;
1750
+ shadowCoord.z += shadowBias;
1751
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1752
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1753
+ if ( frustumTest ) {
1754
+ #if defined( SHADOWMAP_TYPE_PCF )
1755
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1756
+ float dx0 = - texelSize.x * shadowRadius;
1757
+ float dy0 = - texelSize.y * shadowRadius;
1758
+ float dx1 = + texelSize.x * shadowRadius;
1759
+ float dy1 = + texelSize.y * shadowRadius;
1760
+ float dx2 = dx0 / 2.0;
1761
+ float dy2 = dy0 / 2.0;
1762
+ float dx3 = dx1 / 2.0;
1763
+ float dy3 = dy1 / 2.0;
1764
+ shadow = (
1765
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1766
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1767
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1768
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1769
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1770
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1771
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1772
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1773
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1774
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1775
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1776
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1782
+ ) * ( 1.0 / 17.0 );
1783
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1784
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1785
+ float dx = texelSize.x;
1786
+ float dy = texelSize.y;
1787
+ vec2 uv = shadowCoord.xy;
1788
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1789
+ uv -= f * texelSize;
1790
+ shadow = (
1791
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1794
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1795
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1796
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1797
+ f.x ) +
1798
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1799
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1800
+ f.x ) +
1801
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1802
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1803
+ f.y ) +
1804
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1805
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1806
+ f.y ) +
1807
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1808
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1809
+ f.x ),
1810
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1811
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1812
+ f.x ),
1813
+ f.y )
1814
+ ) * ( 1.0 / 9.0 );
1815
+ #elif defined( SHADOWMAP_TYPE_VSM )
1816
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1817
+ #else
1818
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1819
+ #endif
1820
+ }
1821
+ return mix( 1.0, shadow, shadowIntensity );
1822
+ }
1823
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1824
+ vec3 absV = abs( v );
1825
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1826
+ absV *= scaleToCube;
1827
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1828
+ vec2 planar = v.xy;
1829
+ float almostATexel = 1.5 * texelSizeY;
1830
+ float almostOne = 1.0 - almostATexel;
1831
+ if ( absV.z >= almostOne ) {
1832
+ if ( v.z > 0.0 )
1833
+ planar.x = 4.0 - v.x;
1834
+ } else if ( absV.x >= almostOne ) {
1835
+ float signX = sign( v.x );
1836
+ planar.x = v.z * signX + 2.0 * signX;
1837
+ } else if ( absV.y >= almostOne ) {
1838
+ float signY = sign( v.y );
1839
+ planar.x = v.x + 2.0 * signY + 2.0;
1840
+ planar.y = v.z * signY - 2.0;
1841
+ }
1842
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1843
+ }
1844
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1845
+ float shadow = 1.0;
1846
+ vec3 lightToPosition = shadowCoord.xyz;
1847
+
1848
+ float lightToPositionLength = length( lightToPosition );
1849
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1850
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1851
+ vec3 bd3D = normalize( lightToPosition );
1852
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1853
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1854
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1855
+ shadow = (
1856
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1857
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1858
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1859
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1860
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1861
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1862
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1863
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1864
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1865
+ ) * ( 1.0 / 9.0 );
1866
+ #else
1867
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1868
+ #endif
1869
+ }
1870
+ return mix( 1.0, shadow, shadowIntensity );
1871
+ }
1872
+ #endif`,Pm=`#if NUM_SPOT_LIGHT_COORDS > 0
1873
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1874
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1875
+ #endif
1876
+ #ifdef USE_SHADOWMAP
1877
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1878
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1879
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1880
+ struct DirectionalLightShadow {
1881
+ float shadowIntensity;
1882
+ float shadowBias;
1883
+ float shadowNormalBias;
1884
+ float shadowRadius;
1885
+ vec2 shadowMapSize;
1886
+ };
1887
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1888
+ #endif
1889
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1890
+ struct SpotLightShadow {
1891
+ float shadowIntensity;
1892
+ float shadowBias;
1893
+ float shadowNormalBias;
1894
+ float shadowRadius;
1895
+ vec2 shadowMapSize;
1896
+ };
1897
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1898
+ #endif
1899
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1900
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1901
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1902
+ struct PointLightShadow {
1903
+ float shadowIntensity;
1904
+ float shadowBias;
1905
+ float shadowNormalBias;
1906
+ float shadowRadius;
1907
+ vec2 shadowMapSize;
1908
+ float shadowCameraNear;
1909
+ float shadowCameraFar;
1910
+ };
1911
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1912
+ #endif
1913
+ #endif`,Lm=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1914
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1915
+ vec4 shadowWorldPosition;
1916
+ #endif
1917
+ #if defined( USE_SHADOWMAP )
1918
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1919
+ #pragma unroll_loop_start
1920
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1921
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1922
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1923
+ }
1924
+ #pragma unroll_loop_end
1925
+ #endif
1926
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1927
+ #pragma unroll_loop_start
1928
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1929
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1930
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1931
+ }
1932
+ #pragma unroll_loop_end
1933
+ #endif
1934
+ #endif
1935
+ #if NUM_SPOT_LIGHT_COORDS > 0
1936
+ #pragma unroll_loop_start
1937
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1938
+ shadowWorldPosition = worldPosition;
1939
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1940
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1941
+ #endif
1942
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1943
+ }
1944
+ #pragma unroll_loop_end
1945
+ #endif`,Dm=`float getShadowMask() {
1946
+ float shadow = 1.0;
1947
+ #ifdef USE_SHADOWMAP
1948
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1949
+ DirectionalLightShadow directionalLight;
1950
+ #pragma unroll_loop_start
1951
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1952
+ directionalLight = directionalLightShadows[ i ];
1953
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1954
+ }
1955
+ #pragma unroll_loop_end
1956
+ #endif
1957
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1958
+ SpotLightShadow spotLight;
1959
+ #pragma unroll_loop_start
1960
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1961
+ spotLight = spotLightShadows[ i ];
1962
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1963
+ }
1964
+ #pragma unroll_loop_end
1965
+ #endif
1966
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1967
+ PointLightShadow pointLight;
1968
+ #pragma unroll_loop_start
1969
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1970
+ pointLight = pointLightShadows[ i ];
1971
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1972
+ }
1973
+ #pragma unroll_loop_end
1974
+ #endif
1975
+ #endif
1976
+ return shadow;
1977
+ }`,Um=`#ifdef USE_SKINNING
1978
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1979
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1980
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1981
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1982
+ #endif`,Nm=`#ifdef USE_SKINNING
1983
+ uniform mat4 bindMatrix;
1984
+ uniform mat4 bindMatrixInverse;
1985
+ uniform highp sampler2D boneTexture;
1986
+ mat4 getBoneMatrix( const in float i ) {
1987
+ int size = textureSize( boneTexture, 0 ).x;
1988
+ int j = int( i ) * 4;
1989
+ int x = j % size;
1990
+ int y = j / size;
1991
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1992
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1993
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
1994
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
1995
+ return mat4( v1, v2, v3, v4 );
1996
+ }
1997
+ #endif`,Fm=`#ifdef USE_SKINNING
1998
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
1999
+ vec4 skinned = vec4( 0.0 );
2000
+ skinned += boneMatX * skinVertex * skinWeight.x;
2001
+ skinned += boneMatY * skinVertex * skinWeight.y;
2002
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2003
+ skinned += boneMatW * skinVertex * skinWeight.w;
2004
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2005
+ #endif`,Om=`#ifdef USE_SKINNING
2006
+ mat4 skinMatrix = mat4( 0.0 );
2007
+ skinMatrix += skinWeight.x * boneMatX;
2008
+ skinMatrix += skinWeight.y * boneMatY;
2009
+ skinMatrix += skinWeight.z * boneMatZ;
2010
+ skinMatrix += skinWeight.w * boneMatW;
2011
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2012
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2013
+ #ifdef USE_TANGENT
2014
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2015
+ #endif
2016
+ #endif`,Bm=`float specularStrength;
2017
+ #ifdef USE_SPECULARMAP
2018
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2019
+ specularStrength = texelSpecular.r;
2020
+ #else
2021
+ specularStrength = 1.0;
2022
+ #endif`,zm=`#ifdef USE_SPECULARMAP
2023
+ uniform sampler2D specularMap;
2024
+ #endif`,km=`#if defined( TONE_MAPPING )
2025
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2026
+ #endif`,Vm=`#ifndef saturate
2027
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2028
+ #endif
2029
+ uniform float toneMappingExposure;
2030
+ vec3 LinearToneMapping( vec3 color ) {
2031
+ return saturate( toneMappingExposure * color );
2032
+ }
2033
+ vec3 ReinhardToneMapping( vec3 color ) {
2034
+ color *= toneMappingExposure;
2035
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2036
+ }
2037
+ vec3 CineonToneMapping( vec3 color ) {
2038
+ color *= toneMappingExposure;
2039
+ color = max( vec3( 0.0 ), color - 0.004 );
2040
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2041
+ }
2042
+ vec3 RRTAndODTFit( vec3 v ) {
2043
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2044
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2045
+ return a / b;
2046
+ }
2047
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2048
+ const mat3 ACESInputMat = mat3(
2049
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2050
+ vec3( 0.04823, 0.01566, 0.83777 )
2051
+ );
2052
+ const mat3 ACESOutputMat = mat3(
2053
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2054
+ vec3( -0.07367, -0.00605, 1.07602 )
2055
+ );
2056
+ color *= toneMappingExposure / 0.6;
2057
+ color = ACESInputMat * color;
2058
+ color = RRTAndODTFit( color );
2059
+ color = ACESOutputMat * color;
2060
+ return saturate( color );
2061
+ }
2062
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2063
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2064
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2065
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2066
+ );
2067
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2068
+ vec3( 0.6274, 0.0691, 0.0164 ),
2069
+ vec3( 0.3293, 0.9195, 0.0880 ),
2070
+ vec3( 0.0433, 0.0113, 0.8956 )
2071
+ );
2072
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2073
+ vec3 x2 = x * x;
2074
+ vec3 x4 = x2 * x2;
2075
+ return + 15.5 * x4 * x2
2076
+ - 40.14 * x4 * x
2077
+ + 31.96 * x4
2078
+ - 6.868 * x2 * x
2079
+ + 0.4298 * x2
2080
+ + 0.1191 * x
2081
+ - 0.00232;
2082
+ }
2083
+ vec3 AgXToneMapping( vec3 color ) {
2084
+ const mat3 AgXInsetMatrix = mat3(
2085
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2086
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2087
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2088
+ );
2089
+ const mat3 AgXOutsetMatrix = mat3(
2090
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2091
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2092
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2093
+ );
2094
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2095
+ color *= toneMappingExposure;
2096
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2097
+ color = AgXInsetMatrix * color;
2098
+ color = max( color, 1e-10 ); color = log2( color );
2099
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2100
+ color = clamp( color, 0.0, 1.0 );
2101
+ color = agxDefaultContrastApprox( color );
2102
+ color = AgXOutsetMatrix * color;
2103
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2104
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2105
+ color = clamp( color, 0.0, 1.0 );
2106
+ return color;
2107
+ }
2108
+ vec3 NeutralToneMapping( vec3 color ) {
2109
+ const float StartCompression = 0.8 - 0.04;
2110
+ const float Desaturation = 0.15;
2111
+ color *= toneMappingExposure;
2112
+ float x = min( color.r, min( color.g, color.b ) );
2113
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2114
+ color -= offset;
2115
+ float peak = max( color.r, max( color.g, color.b ) );
2116
+ if ( peak < StartCompression ) return color;
2117
+ float d = 1. - StartCompression;
2118
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2119
+ color *= newPeak / peak;
2120
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2121
+ return mix( color, vec3( newPeak ), g );
2122
+ }
2123
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hm=`#ifdef USE_TRANSMISSION
2124
+ material.transmission = transmission;
2125
+ material.transmissionAlpha = 1.0;
2126
+ material.thickness = thickness;
2127
+ material.attenuationDistance = attenuationDistance;
2128
+ material.attenuationColor = attenuationColor;
2129
+ #ifdef USE_TRANSMISSIONMAP
2130
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2131
+ #endif
2132
+ #ifdef USE_THICKNESSMAP
2133
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2134
+ #endif
2135
+ vec3 pos = vWorldPosition;
2136
+ vec3 v = normalize( cameraPosition - pos );
2137
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2138
+ vec4 transmitted = getIBLVolumeRefraction(
2139
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2140
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2141
+ material.attenuationColor, material.attenuationDistance );
2142
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2143
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2144
+ #endif`,Gm=`#ifdef USE_TRANSMISSION
2145
+ uniform float transmission;
2146
+ uniform float thickness;
2147
+ uniform float attenuationDistance;
2148
+ uniform vec3 attenuationColor;
2149
+ #ifdef USE_TRANSMISSIONMAP
2150
+ uniform sampler2D transmissionMap;
2151
+ #endif
2152
+ #ifdef USE_THICKNESSMAP
2153
+ uniform sampler2D thicknessMap;
2154
+ #endif
2155
+ uniform vec2 transmissionSamplerSize;
2156
+ uniform sampler2D transmissionSamplerMap;
2157
+ uniform mat4 modelMatrix;
2158
+ uniform mat4 projectionMatrix;
2159
+ varying vec3 vWorldPosition;
2160
+ float w0( float a ) {
2161
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2162
+ }
2163
+ float w1( float a ) {
2164
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2165
+ }
2166
+ float w2( float a ){
2167
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2168
+ }
2169
+ float w3( float a ) {
2170
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2171
+ }
2172
+ float g0( float a ) {
2173
+ return w0( a ) + w1( a );
2174
+ }
2175
+ float g1( float a ) {
2176
+ return w2( a ) + w3( a );
2177
+ }
2178
+ float h0( float a ) {
2179
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2180
+ }
2181
+ float h1( float a ) {
2182
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2183
+ }
2184
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2185
+ uv = uv * texelSize.zw + 0.5;
2186
+ vec2 iuv = floor( uv );
2187
+ vec2 fuv = fract( uv );
2188
+ float g0x = g0( fuv.x );
2189
+ float g1x = g1( fuv.x );
2190
+ float h0x = h0( fuv.x );
2191
+ float h1x = h1( fuv.x );
2192
+ float h0y = h0( fuv.y );
2193
+ float h1y = h1( fuv.y );
2194
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2195
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2196
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2197
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2198
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2199
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2200
+ }
2201
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2202
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2203
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2204
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2205
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2206
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2207
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2208
+ return mix( fSample, cSample, fract( lod ) );
2209
+ }
2210
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2211
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2212
+ vec3 modelScale;
2213
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2214
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2215
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2216
+ return normalize( refractionVector ) * thickness * modelScale;
2217
+ }
2218
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2219
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2220
+ }
2221
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2222
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2223
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2224
+ }
2225
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2226
+ if ( isinf( attenuationDistance ) ) {
2227
+ return vec3( 1.0 );
2228
+ } else {
2229
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2230
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2231
+ }
2232
+ }
2233
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2234
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2235
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2236
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2237
+ vec4 transmittedLight;
2238
+ vec3 transmittance;
2239
+ #ifdef USE_DISPERSION
2240
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2241
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2242
+ for ( int i = 0; i < 3; i ++ ) {
2243
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2244
+ vec3 refractedRayExit = position + transmissionRay;
2245
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2246
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2247
+ refractionCoords += 1.0;
2248
+ refractionCoords /= 2.0;
2249
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2250
+ transmittedLight[ i ] = transmissionSample[ i ];
2251
+ transmittedLight.a += transmissionSample.a;
2252
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2253
+ }
2254
+ transmittedLight.a /= 3.0;
2255
+ #else
2256
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2257
+ vec3 refractedRayExit = position + transmissionRay;
2258
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2259
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2260
+ refractionCoords += 1.0;
2261
+ refractionCoords /= 2.0;
2262
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2263
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2264
+ #endif
2265
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2266
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2267
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2268
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2269
+ }
2270
+ #endif`,Wm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2271
+ varying vec2 vUv;
2272
+ #endif
2273
+ #ifdef USE_MAP
2274
+ varying vec2 vMapUv;
2275
+ #endif
2276
+ #ifdef USE_ALPHAMAP
2277
+ varying vec2 vAlphaMapUv;
2278
+ #endif
2279
+ #ifdef USE_LIGHTMAP
2280
+ varying vec2 vLightMapUv;
2281
+ #endif
2282
+ #ifdef USE_AOMAP
2283
+ varying vec2 vAoMapUv;
2284
+ #endif
2285
+ #ifdef USE_BUMPMAP
2286
+ varying vec2 vBumpMapUv;
2287
+ #endif
2288
+ #ifdef USE_NORMALMAP
2289
+ varying vec2 vNormalMapUv;
2290
+ #endif
2291
+ #ifdef USE_EMISSIVEMAP
2292
+ varying vec2 vEmissiveMapUv;
2293
+ #endif
2294
+ #ifdef USE_METALNESSMAP
2295
+ varying vec2 vMetalnessMapUv;
2296
+ #endif
2297
+ #ifdef USE_ROUGHNESSMAP
2298
+ varying vec2 vRoughnessMapUv;
2299
+ #endif
2300
+ #ifdef USE_ANISOTROPYMAP
2301
+ varying vec2 vAnisotropyMapUv;
2302
+ #endif
2303
+ #ifdef USE_CLEARCOATMAP
2304
+ varying vec2 vClearcoatMapUv;
2305
+ #endif
2306
+ #ifdef USE_CLEARCOAT_NORMALMAP
2307
+ varying vec2 vClearcoatNormalMapUv;
2308
+ #endif
2309
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2310
+ varying vec2 vClearcoatRoughnessMapUv;
2311
+ #endif
2312
+ #ifdef USE_IRIDESCENCEMAP
2313
+ varying vec2 vIridescenceMapUv;
2314
+ #endif
2315
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2316
+ varying vec2 vIridescenceThicknessMapUv;
2317
+ #endif
2318
+ #ifdef USE_SHEEN_COLORMAP
2319
+ varying vec2 vSheenColorMapUv;
2320
+ #endif
2321
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2322
+ varying vec2 vSheenRoughnessMapUv;
2323
+ #endif
2324
+ #ifdef USE_SPECULARMAP
2325
+ varying vec2 vSpecularMapUv;
2326
+ #endif
2327
+ #ifdef USE_SPECULAR_COLORMAP
2328
+ varying vec2 vSpecularColorMapUv;
2329
+ #endif
2330
+ #ifdef USE_SPECULAR_INTENSITYMAP
2331
+ varying vec2 vSpecularIntensityMapUv;
2332
+ #endif
2333
+ #ifdef USE_TRANSMISSIONMAP
2334
+ uniform mat3 transmissionMapTransform;
2335
+ varying vec2 vTransmissionMapUv;
2336
+ #endif
2337
+ #ifdef USE_THICKNESSMAP
2338
+ uniform mat3 thicknessMapTransform;
2339
+ varying vec2 vThicknessMapUv;
2340
+ #endif`,Xm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2341
+ varying vec2 vUv;
2342
+ #endif
2343
+ #ifdef USE_MAP
2344
+ uniform mat3 mapTransform;
2345
+ varying vec2 vMapUv;
2346
+ #endif
2347
+ #ifdef USE_ALPHAMAP
2348
+ uniform mat3 alphaMapTransform;
2349
+ varying vec2 vAlphaMapUv;
2350
+ #endif
2351
+ #ifdef USE_LIGHTMAP
2352
+ uniform mat3 lightMapTransform;
2353
+ varying vec2 vLightMapUv;
2354
+ #endif
2355
+ #ifdef USE_AOMAP
2356
+ uniform mat3 aoMapTransform;
2357
+ varying vec2 vAoMapUv;
2358
+ #endif
2359
+ #ifdef USE_BUMPMAP
2360
+ uniform mat3 bumpMapTransform;
2361
+ varying vec2 vBumpMapUv;
2362
+ #endif
2363
+ #ifdef USE_NORMALMAP
2364
+ uniform mat3 normalMapTransform;
2365
+ varying vec2 vNormalMapUv;
2366
+ #endif
2367
+ #ifdef USE_DISPLACEMENTMAP
2368
+ uniform mat3 displacementMapTransform;
2369
+ varying vec2 vDisplacementMapUv;
2370
+ #endif
2371
+ #ifdef USE_EMISSIVEMAP
2372
+ uniform mat3 emissiveMapTransform;
2373
+ varying vec2 vEmissiveMapUv;
2374
+ #endif
2375
+ #ifdef USE_METALNESSMAP
2376
+ uniform mat3 metalnessMapTransform;
2377
+ varying vec2 vMetalnessMapUv;
2378
+ #endif
2379
+ #ifdef USE_ROUGHNESSMAP
2380
+ uniform mat3 roughnessMapTransform;
2381
+ varying vec2 vRoughnessMapUv;
2382
+ #endif
2383
+ #ifdef USE_ANISOTROPYMAP
2384
+ uniform mat3 anisotropyMapTransform;
2385
+ varying vec2 vAnisotropyMapUv;
2386
+ #endif
2387
+ #ifdef USE_CLEARCOATMAP
2388
+ uniform mat3 clearcoatMapTransform;
2389
+ varying vec2 vClearcoatMapUv;
2390
+ #endif
2391
+ #ifdef USE_CLEARCOAT_NORMALMAP
2392
+ uniform mat3 clearcoatNormalMapTransform;
2393
+ varying vec2 vClearcoatNormalMapUv;
2394
+ #endif
2395
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2396
+ uniform mat3 clearcoatRoughnessMapTransform;
2397
+ varying vec2 vClearcoatRoughnessMapUv;
2398
+ #endif
2399
+ #ifdef USE_SHEEN_COLORMAP
2400
+ uniform mat3 sheenColorMapTransform;
2401
+ varying vec2 vSheenColorMapUv;
2402
+ #endif
2403
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2404
+ uniform mat3 sheenRoughnessMapTransform;
2405
+ varying vec2 vSheenRoughnessMapUv;
2406
+ #endif
2407
+ #ifdef USE_IRIDESCENCEMAP
2408
+ uniform mat3 iridescenceMapTransform;
2409
+ varying vec2 vIridescenceMapUv;
2410
+ #endif
2411
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2412
+ uniform mat3 iridescenceThicknessMapTransform;
2413
+ varying vec2 vIridescenceThicknessMapUv;
2414
+ #endif
2415
+ #ifdef USE_SPECULARMAP
2416
+ uniform mat3 specularMapTransform;
2417
+ varying vec2 vSpecularMapUv;
2418
+ #endif
2419
+ #ifdef USE_SPECULAR_COLORMAP
2420
+ uniform mat3 specularColorMapTransform;
2421
+ varying vec2 vSpecularColorMapUv;
2422
+ #endif
2423
+ #ifdef USE_SPECULAR_INTENSITYMAP
2424
+ uniform mat3 specularIntensityMapTransform;
2425
+ varying vec2 vSpecularIntensityMapUv;
2426
+ #endif
2427
+ #ifdef USE_TRANSMISSIONMAP
2428
+ uniform mat3 transmissionMapTransform;
2429
+ varying vec2 vTransmissionMapUv;
2430
+ #endif
2431
+ #ifdef USE_THICKNESSMAP
2432
+ uniform mat3 thicknessMapTransform;
2433
+ varying vec2 vThicknessMapUv;
2434
+ #endif`,qm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2435
+ vUv = vec3( uv, 1 ).xy;
2436
+ #endif
2437
+ #ifdef USE_MAP
2438
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2439
+ #endif
2440
+ #ifdef USE_ALPHAMAP
2441
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2442
+ #endif
2443
+ #ifdef USE_LIGHTMAP
2444
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2445
+ #endif
2446
+ #ifdef USE_AOMAP
2447
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2448
+ #endif
2449
+ #ifdef USE_BUMPMAP
2450
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2451
+ #endif
2452
+ #ifdef USE_NORMALMAP
2453
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2454
+ #endif
2455
+ #ifdef USE_DISPLACEMENTMAP
2456
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2457
+ #endif
2458
+ #ifdef USE_EMISSIVEMAP
2459
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2460
+ #endif
2461
+ #ifdef USE_METALNESSMAP
2462
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2463
+ #endif
2464
+ #ifdef USE_ROUGHNESSMAP
2465
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2466
+ #endif
2467
+ #ifdef USE_ANISOTROPYMAP
2468
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2469
+ #endif
2470
+ #ifdef USE_CLEARCOATMAP
2471
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2472
+ #endif
2473
+ #ifdef USE_CLEARCOAT_NORMALMAP
2474
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2475
+ #endif
2476
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2477
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2478
+ #endif
2479
+ #ifdef USE_IRIDESCENCEMAP
2480
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2481
+ #endif
2482
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2483
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2484
+ #endif
2485
+ #ifdef USE_SHEEN_COLORMAP
2486
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2487
+ #endif
2488
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2489
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2490
+ #endif
2491
+ #ifdef USE_SPECULARMAP
2492
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2493
+ #endif
2494
+ #ifdef USE_SPECULAR_COLORMAP
2495
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2496
+ #endif
2497
+ #ifdef USE_SPECULAR_INTENSITYMAP
2498
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2499
+ #endif
2500
+ #ifdef USE_TRANSMISSIONMAP
2501
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2502
+ #endif
2503
+ #ifdef USE_THICKNESSMAP
2504
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2505
+ #endif`,Ym=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2506
+ vec4 worldPosition = vec4( transformed, 1.0 );
2507
+ #ifdef USE_BATCHING
2508
+ worldPosition = batchingMatrix * worldPosition;
2509
+ #endif
2510
+ #ifdef USE_INSTANCING
2511
+ worldPosition = instanceMatrix * worldPosition;
2512
+ #endif
2513
+ worldPosition = modelMatrix * worldPosition;
2514
+ #endif`,Zm=`varying vec2 vUv;
2515
+ uniform mat3 uvTransform;
2516
+ void main() {
2517
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2518
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2519
+ }`,Jm=`uniform sampler2D t2D;
2520
+ uniform float backgroundIntensity;
2521
+ varying vec2 vUv;
2522
+ void main() {
2523
+ vec4 texColor = texture2D( t2D, vUv );
2524
+ #ifdef DECODE_VIDEO_TEXTURE
2525
+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
2526
+ #endif
2527
+ texColor.rgb *= backgroundIntensity;
2528
+ gl_FragColor = texColor;
2529
+ #include <tonemapping_fragment>
2530
+ #include <colorspace_fragment>
2531
+ }`,$m=`varying vec3 vWorldDirection;
2532
+ #include <common>
2533
+ void main() {
2534
+ vWorldDirection = transformDirection( position, modelMatrix );
2535
+ #include <begin_vertex>
2536
+ #include <project_vertex>
2537
+ gl_Position.z = gl_Position.w;
2538
+ }`,Km=`#ifdef ENVMAP_TYPE_CUBE
2539
+ uniform samplerCube envMap;
2540
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2541
+ uniform sampler2D envMap;
2542
+ #endif
2543
+ uniform float flipEnvMap;
2544
+ uniform float backgroundBlurriness;
2545
+ uniform float backgroundIntensity;
2546
+ uniform mat3 backgroundRotation;
2547
+ varying vec3 vWorldDirection;
2548
+ #include <cube_uv_reflection_fragment>
2549
+ void main() {
2550
+ #ifdef ENVMAP_TYPE_CUBE
2551
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2552
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2553
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2554
+ #else
2555
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2556
+ #endif
2557
+ texColor.rgb *= backgroundIntensity;
2558
+ gl_FragColor = texColor;
2559
+ #include <tonemapping_fragment>
2560
+ #include <colorspace_fragment>
2561
+ }`,Qm=`varying vec3 vWorldDirection;
2562
+ #include <common>
2563
+ void main() {
2564
+ vWorldDirection = transformDirection( position, modelMatrix );
2565
+ #include <begin_vertex>
2566
+ #include <project_vertex>
2567
+ gl_Position.z = gl_Position.w;
2568
+ }`,jm=`uniform samplerCube tCube;
2569
+ uniform float tFlip;
2570
+ uniform float opacity;
2571
+ varying vec3 vWorldDirection;
2572
+ void main() {
2573
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2574
+ gl_FragColor = texColor;
2575
+ gl_FragColor.a *= opacity;
2576
+ #include <tonemapping_fragment>
2577
+ #include <colorspace_fragment>
2578
+ }`,tg=`#include <common>
2579
+ #include <batching_pars_vertex>
2580
+ #include <uv_pars_vertex>
2581
+ #include <displacementmap_pars_vertex>
2582
+ #include <morphtarget_pars_vertex>
2583
+ #include <skinning_pars_vertex>
2584
+ #include <logdepthbuf_pars_vertex>
2585
+ #include <clipping_planes_pars_vertex>
2586
+ varying vec2 vHighPrecisionZW;
2587
+ void main() {
2588
+ #include <uv_vertex>
2589
+ #include <batching_vertex>
2590
+ #include <skinbase_vertex>
2591
+ #include <morphinstance_vertex>
2592
+ #ifdef USE_DISPLACEMENTMAP
2593
+ #include <beginnormal_vertex>
2594
+ #include <morphnormal_vertex>
2595
+ #include <skinnormal_vertex>
2596
+ #endif
2597
+ #include <begin_vertex>
2598
+ #include <morphtarget_vertex>
2599
+ #include <skinning_vertex>
2600
+ #include <displacementmap_vertex>
2601
+ #include <project_vertex>
2602
+ #include <logdepthbuf_vertex>
2603
+ #include <clipping_planes_vertex>
2604
+ vHighPrecisionZW = gl_Position.zw;
2605
+ }`,eg=`#if DEPTH_PACKING == 3200
2606
+ uniform float opacity;
2607
+ #endif
2608
+ #include <common>
2609
+ #include <packing>
2610
+ #include <uv_pars_fragment>
2611
+ #include <map_pars_fragment>
2612
+ #include <alphamap_pars_fragment>
2613
+ #include <alphatest_pars_fragment>
2614
+ #include <alphahash_pars_fragment>
2615
+ #include <logdepthbuf_pars_fragment>
2616
+ #include <clipping_planes_pars_fragment>
2617
+ varying vec2 vHighPrecisionZW;
2618
+ void main() {
2619
+ vec4 diffuseColor = vec4( 1.0 );
2620
+ #include <clipping_planes_fragment>
2621
+ #if DEPTH_PACKING == 3200
2622
+ diffuseColor.a = opacity;
2623
+ #endif
2624
+ #include <map_fragment>
2625
+ #include <alphamap_fragment>
2626
+ #include <alphatest_fragment>
2627
+ #include <alphahash_fragment>
2628
+ #include <logdepthbuf_fragment>
2629
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2630
+ #if DEPTH_PACKING == 3200
2631
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2632
+ #elif DEPTH_PACKING == 3201
2633
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2634
+ #elif DEPTH_PACKING == 3202
2635
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2636
+ #elif DEPTH_PACKING == 3203
2637
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2638
+ #endif
2639
+ }`,ng=`#define DISTANCE
2640
+ varying vec3 vWorldPosition;
2641
+ #include <common>
2642
+ #include <batching_pars_vertex>
2643
+ #include <uv_pars_vertex>
2644
+ #include <displacementmap_pars_vertex>
2645
+ #include <morphtarget_pars_vertex>
2646
+ #include <skinning_pars_vertex>
2647
+ #include <clipping_planes_pars_vertex>
2648
+ void main() {
2649
+ #include <uv_vertex>
2650
+ #include <batching_vertex>
2651
+ #include <skinbase_vertex>
2652
+ #include <morphinstance_vertex>
2653
+ #ifdef USE_DISPLACEMENTMAP
2654
+ #include <beginnormal_vertex>
2655
+ #include <morphnormal_vertex>
2656
+ #include <skinnormal_vertex>
2657
+ #endif
2658
+ #include <begin_vertex>
2659
+ #include <morphtarget_vertex>
2660
+ #include <skinning_vertex>
2661
+ #include <displacementmap_vertex>
2662
+ #include <project_vertex>
2663
+ #include <worldpos_vertex>
2664
+ #include <clipping_planes_vertex>
2665
+ vWorldPosition = worldPosition.xyz;
2666
+ }`,ig=`#define DISTANCE
2667
+ uniform vec3 referencePosition;
2668
+ uniform float nearDistance;
2669
+ uniform float farDistance;
2670
+ varying vec3 vWorldPosition;
2671
+ #include <common>
2672
+ #include <packing>
2673
+ #include <uv_pars_fragment>
2674
+ #include <map_pars_fragment>
2675
+ #include <alphamap_pars_fragment>
2676
+ #include <alphatest_pars_fragment>
2677
+ #include <alphahash_pars_fragment>
2678
+ #include <clipping_planes_pars_fragment>
2679
+ void main () {
2680
+ vec4 diffuseColor = vec4( 1.0 );
2681
+ #include <clipping_planes_fragment>
2682
+ #include <map_fragment>
2683
+ #include <alphamap_fragment>
2684
+ #include <alphatest_fragment>
2685
+ #include <alphahash_fragment>
2686
+ float dist = length( vWorldPosition - referencePosition );
2687
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2688
+ dist = saturate( dist );
2689
+ gl_FragColor = packDepthToRGBA( dist );
2690
+ }`,sg=`varying vec3 vWorldDirection;
2691
+ #include <common>
2692
+ void main() {
2693
+ vWorldDirection = transformDirection( position, modelMatrix );
2694
+ #include <begin_vertex>
2695
+ #include <project_vertex>
2696
+ }`,rg=`uniform sampler2D tEquirect;
2697
+ varying vec3 vWorldDirection;
2698
+ #include <common>
2699
+ void main() {
2700
+ vec3 direction = normalize( vWorldDirection );
2701
+ vec2 sampleUV = equirectUv( direction );
2702
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2703
+ #include <tonemapping_fragment>
2704
+ #include <colorspace_fragment>
2705
+ }`,ag=`uniform float scale;
2706
+ attribute float lineDistance;
2707
+ varying float vLineDistance;
2708
+ #include <common>
2709
+ #include <uv_pars_vertex>
2710
+ #include <color_pars_vertex>
2711
+ #include <fog_pars_vertex>
2712
+ #include <morphtarget_pars_vertex>
2713
+ #include <logdepthbuf_pars_vertex>
2714
+ #include <clipping_planes_pars_vertex>
2715
+ void main() {
2716
+ vLineDistance = scale * lineDistance;
2717
+ #include <uv_vertex>
2718
+ #include <color_vertex>
2719
+ #include <morphinstance_vertex>
2720
+ #include <morphcolor_vertex>
2721
+ #include <begin_vertex>
2722
+ #include <morphtarget_vertex>
2723
+ #include <project_vertex>
2724
+ #include <logdepthbuf_vertex>
2725
+ #include <clipping_planes_vertex>
2726
+ #include <fog_vertex>
2727
+ }`,og=`uniform vec3 diffuse;
2728
+ uniform float opacity;
2729
+ uniform float dashSize;
2730
+ uniform float totalSize;
2731
+ varying float vLineDistance;
2732
+ #include <common>
2733
+ #include <color_pars_fragment>
2734
+ #include <uv_pars_fragment>
2735
+ #include <map_pars_fragment>
2736
+ #include <fog_pars_fragment>
2737
+ #include <logdepthbuf_pars_fragment>
2738
+ #include <clipping_planes_pars_fragment>
2739
+ void main() {
2740
+ vec4 diffuseColor = vec4( diffuse, opacity );
2741
+ #include <clipping_planes_fragment>
2742
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2743
+ discard;
2744
+ }
2745
+ vec3 outgoingLight = vec3( 0.0 );
2746
+ #include <logdepthbuf_fragment>
2747
+ #include <map_fragment>
2748
+ #include <color_fragment>
2749
+ outgoingLight = diffuseColor.rgb;
2750
+ #include <opaque_fragment>
2751
+ #include <tonemapping_fragment>
2752
+ #include <colorspace_fragment>
2753
+ #include <fog_fragment>
2754
+ #include <premultiplied_alpha_fragment>
2755
+ }`,lg=`#include <common>
2756
+ #include <batching_pars_vertex>
2757
+ #include <uv_pars_vertex>
2758
+ #include <envmap_pars_vertex>
2759
+ #include <color_pars_vertex>
2760
+ #include <fog_pars_vertex>
2761
+ #include <morphtarget_pars_vertex>
2762
+ #include <skinning_pars_vertex>
2763
+ #include <logdepthbuf_pars_vertex>
2764
+ #include <clipping_planes_pars_vertex>
2765
+ void main() {
2766
+ #include <uv_vertex>
2767
+ #include <color_vertex>
2768
+ #include <morphinstance_vertex>
2769
+ #include <morphcolor_vertex>
2770
+ #include <batching_vertex>
2771
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2772
+ #include <beginnormal_vertex>
2773
+ #include <morphnormal_vertex>
2774
+ #include <skinbase_vertex>
2775
+ #include <skinnormal_vertex>
2776
+ #include <defaultnormal_vertex>
2777
+ #endif
2778
+ #include <begin_vertex>
2779
+ #include <morphtarget_vertex>
2780
+ #include <skinning_vertex>
2781
+ #include <project_vertex>
2782
+ #include <logdepthbuf_vertex>
2783
+ #include <clipping_planes_vertex>
2784
+ #include <worldpos_vertex>
2785
+ #include <envmap_vertex>
2786
+ #include <fog_vertex>
2787
+ }`,cg=`uniform vec3 diffuse;
2788
+ uniform float opacity;
2789
+ #ifndef FLAT_SHADED
2790
+ varying vec3 vNormal;
2791
+ #endif
2792
+ #include <common>
2793
+ #include <dithering_pars_fragment>
2794
+ #include <color_pars_fragment>
2795
+ #include <uv_pars_fragment>
2796
+ #include <map_pars_fragment>
2797
+ #include <alphamap_pars_fragment>
2798
+ #include <alphatest_pars_fragment>
2799
+ #include <alphahash_pars_fragment>
2800
+ #include <aomap_pars_fragment>
2801
+ #include <lightmap_pars_fragment>
2802
+ #include <envmap_common_pars_fragment>
2803
+ #include <envmap_pars_fragment>
2804
+ #include <fog_pars_fragment>
2805
+ #include <specularmap_pars_fragment>
2806
+ #include <logdepthbuf_pars_fragment>
2807
+ #include <clipping_planes_pars_fragment>
2808
+ void main() {
2809
+ vec4 diffuseColor = vec4( diffuse, opacity );
2810
+ #include <clipping_planes_fragment>
2811
+ #include <logdepthbuf_fragment>
2812
+ #include <map_fragment>
2813
+ #include <color_fragment>
2814
+ #include <alphamap_fragment>
2815
+ #include <alphatest_fragment>
2816
+ #include <alphahash_fragment>
2817
+ #include <specularmap_fragment>
2818
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2819
+ #ifdef USE_LIGHTMAP
2820
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2821
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2822
+ #else
2823
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2824
+ #endif
2825
+ #include <aomap_fragment>
2826
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2827
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2828
+ #include <envmap_fragment>
2829
+ #include <opaque_fragment>
2830
+ #include <tonemapping_fragment>
2831
+ #include <colorspace_fragment>
2832
+ #include <fog_fragment>
2833
+ #include <premultiplied_alpha_fragment>
2834
+ #include <dithering_fragment>
2835
+ }`,hg=`#define LAMBERT
2836
+ varying vec3 vViewPosition;
2837
+ #include <common>
2838
+ #include <batching_pars_vertex>
2839
+ #include <uv_pars_vertex>
2840
+ #include <displacementmap_pars_vertex>
2841
+ #include <envmap_pars_vertex>
2842
+ #include <color_pars_vertex>
2843
+ #include <fog_pars_vertex>
2844
+ #include <normal_pars_vertex>
2845
+ #include <morphtarget_pars_vertex>
2846
+ #include <skinning_pars_vertex>
2847
+ #include <shadowmap_pars_vertex>
2848
+ #include <logdepthbuf_pars_vertex>
2849
+ #include <clipping_planes_pars_vertex>
2850
+ void main() {
2851
+ #include <uv_vertex>
2852
+ #include <color_vertex>
2853
+ #include <morphinstance_vertex>
2854
+ #include <morphcolor_vertex>
2855
+ #include <batching_vertex>
2856
+ #include <beginnormal_vertex>
2857
+ #include <morphnormal_vertex>
2858
+ #include <skinbase_vertex>
2859
+ #include <skinnormal_vertex>
2860
+ #include <defaultnormal_vertex>
2861
+ #include <normal_vertex>
2862
+ #include <begin_vertex>
2863
+ #include <morphtarget_vertex>
2864
+ #include <skinning_vertex>
2865
+ #include <displacementmap_vertex>
2866
+ #include <project_vertex>
2867
+ #include <logdepthbuf_vertex>
2868
+ #include <clipping_planes_vertex>
2869
+ vViewPosition = - mvPosition.xyz;
2870
+ #include <worldpos_vertex>
2871
+ #include <envmap_vertex>
2872
+ #include <shadowmap_vertex>
2873
+ #include <fog_vertex>
2874
+ }`,ug=`#define LAMBERT
2875
+ uniform vec3 diffuse;
2876
+ uniform vec3 emissive;
2877
+ uniform float opacity;
2878
+ #include <common>
2879
+ #include <packing>
2880
+ #include <dithering_pars_fragment>
2881
+ #include <color_pars_fragment>
2882
+ #include <uv_pars_fragment>
2883
+ #include <map_pars_fragment>
2884
+ #include <alphamap_pars_fragment>
2885
+ #include <alphatest_pars_fragment>
2886
+ #include <alphahash_pars_fragment>
2887
+ #include <aomap_pars_fragment>
2888
+ #include <lightmap_pars_fragment>
2889
+ #include <emissivemap_pars_fragment>
2890
+ #include <envmap_common_pars_fragment>
2891
+ #include <envmap_pars_fragment>
2892
+ #include <fog_pars_fragment>
2893
+ #include <bsdfs>
2894
+ #include <lights_pars_begin>
2895
+ #include <normal_pars_fragment>
2896
+ #include <lights_lambert_pars_fragment>
2897
+ #include <shadowmap_pars_fragment>
2898
+ #include <bumpmap_pars_fragment>
2899
+ #include <normalmap_pars_fragment>
2900
+ #include <specularmap_pars_fragment>
2901
+ #include <logdepthbuf_pars_fragment>
2902
+ #include <clipping_planes_pars_fragment>
2903
+ void main() {
2904
+ vec4 diffuseColor = vec4( diffuse, opacity );
2905
+ #include <clipping_planes_fragment>
2906
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2907
+ vec3 totalEmissiveRadiance = emissive;
2908
+ #include <logdepthbuf_fragment>
2909
+ #include <map_fragment>
2910
+ #include <color_fragment>
2911
+ #include <alphamap_fragment>
2912
+ #include <alphatest_fragment>
2913
+ #include <alphahash_fragment>
2914
+ #include <specularmap_fragment>
2915
+ #include <normal_fragment_begin>
2916
+ #include <normal_fragment_maps>
2917
+ #include <emissivemap_fragment>
2918
+ #include <lights_lambert_fragment>
2919
+ #include <lights_fragment_begin>
2920
+ #include <lights_fragment_maps>
2921
+ #include <lights_fragment_end>
2922
+ #include <aomap_fragment>
2923
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2924
+ #include <envmap_fragment>
2925
+ #include <opaque_fragment>
2926
+ #include <tonemapping_fragment>
2927
+ #include <colorspace_fragment>
2928
+ #include <fog_fragment>
2929
+ #include <premultiplied_alpha_fragment>
2930
+ #include <dithering_fragment>
2931
+ }`,dg=`#define MATCAP
2932
+ varying vec3 vViewPosition;
2933
+ #include <common>
2934
+ #include <batching_pars_vertex>
2935
+ #include <uv_pars_vertex>
2936
+ #include <color_pars_vertex>
2937
+ #include <displacementmap_pars_vertex>
2938
+ #include <fog_pars_vertex>
2939
+ #include <normal_pars_vertex>
2940
+ #include <morphtarget_pars_vertex>
2941
+ #include <skinning_pars_vertex>
2942
+ #include <logdepthbuf_pars_vertex>
2943
+ #include <clipping_planes_pars_vertex>
2944
+ void main() {
2945
+ #include <uv_vertex>
2946
+ #include <color_vertex>
2947
+ #include <morphinstance_vertex>
2948
+ #include <morphcolor_vertex>
2949
+ #include <batching_vertex>
2950
+ #include <beginnormal_vertex>
2951
+ #include <morphnormal_vertex>
2952
+ #include <skinbase_vertex>
2953
+ #include <skinnormal_vertex>
2954
+ #include <defaultnormal_vertex>
2955
+ #include <normal_vertex>
2956
+ #include <begin_vertex>
2957
+ #include <morphtarget_vertex>
2958
+ #include <skinning_vertex>
2959
+ #include <displacementmap_vertex>
2960
+ #include <project_vertex>
2961
+ #include <logdepthbuf_vertex>
2962
+ #include <clipping_planes_vertex>
2963
+ #include <fog_vertex>
2964
+ vViewPosition = - mvPosition.xyz;
2965
+ }`,fg=`#define MATCAP
2966
+ uniform vec3 diffuse;
2967
+ uniform float opacity;
2968
+ uniform sampler2D matcap;
2969
+ varying vec3 vViewPosition;
2970
+ #include <common>
2971
+ #include <dithering_pars_fragment>
2972
+ #include <color_pars_fragment>
2973
+ #include <uv_pars_fragment>
2974
+ #include <map_pars_fragment>
2975
+ #include <alphamap_pars_fragment>
2976
+ #include <alphatest_pars_fragment>
2977
+ #include <alphahash_pars_fragment>
2978
+ #include <fog_pars_fragment>
2979
+ #include <normal_pars_fragment>
2980
+ #include <bumpmap_pars_fragment>
2981
+ #include <normalmap_pars_fragment>
2982
+ #include <logdepthbuf_pars_fragment>
2983
+ #include <clipping_planes_pars_fragment>
2984
+ void main() {
2985
+ vec4 diffuseColor = vec4( diffuse, opacity );
2986
+ #include <clipping_planes_fragment>
2987
+ #include <logdepthbuf_fragment>
2988
+ #include <map_fragment>
2989
+ #include <color_fragment>
2990
+ #include <alphamap_fragment>
2991
+ #include <alphatest_fragment>
2992
+ #include <alphahash_fragment>
2993
+ #include <normal_fragment_begin>
2994
+ #include <normal_fragment_maps>
2995
+ vec3 viewDir = normalize( vViewPosition );
2996
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
2997
+ vec3 y = cross( viewDir, x );
2998
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
2999
+ #ifdef USE_MATCAP
3000
+ vec4 matcapColor = texture2D( matcap, uv );
3001
+ #else
3002
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3003
+ #endif
3004
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3005
+ #include <opaque_fragment>
3006
+ #include <tonemapping_fragment>
3007
+ #include <colorspace_fragment>
3008
+ #include <fog_fragment>
3009
+ #include <premultiplied_alpha_fragment>
3010
+ #include <dithering_fragment>
3011
+ }`,pg=`#define NORMAL
3012
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3013
+ varying vec3 vViewPosition;
3014
+ #endif
3015
+ #include <common>
3016
+ #include <batching_pars_vertex>
3017
+ #include <uv_pars_vertex>
3018
+ #include <displacementmap_pars_vertex>
3019
+ #include <normal_pars_vertex>
3020
+ #include <morphtarget_pars_vertex>
3021
+ #include <skinning_pars_vertex>
3022
+ #include <logdepthbuf_pars_vertex>
3023
+ #include <clipping_planes_pars_vertex>
3024
+ void main() {
3025
+ #include <uv_vertex>
3026
+ #include <batching_vertex>
3027
+ #include <beginnormal_vertex>
3028
+ #include <morphinstance_vertex>
3029
+ #include <morphnormal_vertex>
3030
+ #include <skinbase_vertex>
3031
+ #include <skinnormal_vertex>
3032
+ #include <defaultnormal_vertex>
3033
+ #include <normal_vertex>
3034
+ #include <begin_vertex>
3035
+ #include <morphtarget_vertex>
3036
+ #include <skinning_vertex>
3037
+ #include <displacementmap_vertex>
3038
+ #include <project_vertex>
3039
+ #include <logdepthbuf_vertex>
3040
+ #include <clipping_planes_vertex>
3041
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3042
+ vViewPosition = - mvPosition.xyz;
3043
+ #endif
3044
+ }`,mg=`#define NORMAL
3045
+ uniform float opacity;
3046
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
+ varying vec3 vViewPosition;
3048
+ #endif
3049
+ #include <packing>
3050
+ #include <uv_pars_fragment>
3051
+ #include <normal_pars_fragment>
3052
+ #include <bumpmap_pars_fragment>
3053
+ #include <normalmap_pars_fragment>
3054
+ #include <logdepthbuf_pars_fragment>
3055
+ #include <clipping_planes_pars_fragment>
3056
+ void main() {
3057
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3058
+ #include <clipping_planes_fragment>
3059
+ #include <logdepthbuf_fragment>
3060
+ #include <normal_fragment_begin>
3061
+ #include <normal_fragment_maps>
3062
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3063
+ #ifdef OPAQUE
3064
+ gl_FragColor.a = 1.0;
3065
+ #endif
3066
+ }`,gg=`#define PHONG
3067
+ varying vec3 vViewPosition;
3068
+ #include <common>
3069
+ #include <batching_pars_vertex>
3070
+ #include <uv_pars_vertex>
3071
+ #include <displacementmap_pars_vertex>
3072
+ #include <envmap_pars_vertex>
3073
+ #include <color_pars_vertex>
3074
+ #include <fog_pars_vertex>
3075
+ #include <normal_pars_vertex>
3076
+ #include <morphtarget_pars_vertex>
3077
+ #include <skinning_pars_vertex>
3078
+ #include <shadowmap_pars_vertex>
3079
+ #include <logdepthbuf_pars_vertex>
3080
+ #include <clipping_planes_pars_vertex>
3081
+ void main() {
3082
+ #include <uv_vertex>
3083
+ #include <color_vertex>
3084
+ #include <morphcolor_vertex>
3085
+ #include <batching_vertex>
3086
+ #include <beginnormal_vertex>
3087
+ #include <morphinstance_vertex>
3088
+ #include <morphnormal_vertex>
3089
+ #include <skinbase_vertex>
3090
+ #include <skinnormal_vertex>
3091
+ #include <defaultnormal_vertex>
3092
+ #include <normal_vertex>
3093
+ #include <begin_vertex>
3094
+ #include <morphtarget_vertex>
3095
+ #include <skinning_vertex>
3096
+ #include <displacementmap_vertex>
3097
+ #include <project_vertex>
3098
+ #include <logdepthbuf_vertex>
3099
+ #include <clipping_planes_vertex>
3100
+ vViewPosition = - mvPosition.xyz;
3101
+ #include <worldpos_vertex>
3102
+ #include <envmap_vertex>
3103
+ #include <shadowmap_vertex>
3104
+ #include <fog_vertex>
3105
+ }`,_g=`#define PHONG
3106
+ uniform vec3 diffuse;
3107
+ uniform vec3 emissive;
3108
+ uniform vec3 specular;
3109
+ uniform float shininess;
3110
+ uniform float opacity;
3111
+ #include <common>
3112
+ #include <packing>
3113
+ #include <dithering_pars_fragment>
3114
+ #include <color_pars_fragment>
3115
+ #include <uv_pars_fragment>
3116
+ #include <map_pars_fragment>
3117
+ #include <alphamap_pars_fragment>
3118
+ #include <alphatest_pars_fragment>
3119
+ #include <alphahash_pars_fragment>
3120
+ #include <aomap_pars_fragment>
3121
+ #include <lightmap_pars_fragment>
3122
+ #include <emissivemap_pars_fragment>
3123
+ #include <envmap_common_pars_fragment>
3124
+ #include <envmap_pars_fragment>
3125
+ #include <fog_pars_fragment>
3126
+ #include <bsdfs>
3127
+ #include <lights_pars_begin>
3128
+ #include <normal_pars_fragment>
3129
+ #include <lights_phong_pars_fragment>
3130
+ #include <shadowmap_pars_fragment>
3131
+ #include <bumpmap_pars_fragment>
3132
+ #include <normalmap_pars_fragment>
3133
+ #include <specularmap_pars_fragment>
3134
+ #include <logdepthbuf_pars_fragment>
3135
+ #include <clipping_planes_pars_fragment>
3136
+ void main() {
3137
+ vec4 diffuseColor = vec4( diffuse, opacity );
3138
+ #include <clipping_planes_fragment>
3139
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3140
+ vec3 totalEmissiveRadiance = emissive;
3141
+ #include <logdepthbuf_fragment>
3142
+ #include <map_fragment>
3143
+ #include <color_fragment>
3144
+ #include <alphamap_fragment>
3145
+ #include <alphatest_fragment>
3146
+ #include <alphahash_fragment>
3147
+ #include <specularmap_fragment>
3148
+ #include <normal_fragment_begin>
3149
+ #include <normal_fragment_maps>
3150
+ #include <emissivemap_fragment>
3151
+ #include <lights_phong_fragment>
3152
+ #include <lights_fragment_begin>
3153
+ #include <lights_fragment_maps>
3154
+ #include <lights_fragment_end>
3155
+ #include <aomap_fragment>
3156
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3157
+ #include <envmap_fragment>
3158
+ #include <opaque_fragment>
3159
+ #include <tonemapping_fragment>
3160
+ #include <colorspace_fragment>
3161
+ #include <fog_fragment>
3162
+ #include <premultiplied_alpha_fragment>
3163
+ #include <dithering_fragment>
3164
+ }`,xg=`#define STANDARD
3165
+ varying vec3 vViewPosition;
3166
+ #ifdef USE_TRANSMISSION
3167
+ varying vec3 vWorldPosition;
3168
+ #endif
3169
+ #include <common>
3170
+ #include <batching_pars_vertex>
3171
+ #include <uv_pars_vertex>
3172
+ #include <displacementmap_pars_vertex>
3173
+ #include <color_pars_vertex>
3174
+ #include <fog_pars_vertex>
3175
+ #include <normal_pars_vertex>
3176
+ #include <morphtarget_pars_vertex>
3177
+ #include <skinning_pars_vertex>
3178
+ #include <shadowmap_pars_vertex>
3179
+ #include <logdepthbuf_pars_vertex>
3180
+ #include <clipping_planes_pars_vertex>
3181
+ void main() {
3182
+ #include <uv_vertex>
3183
+ #include <color_vertex>
3184
+ #include <morphinstance_vertex>
3185
+ #include <morphcolor_vertex>
3186
+ #include <batching_vertex>
3187
+ #include <beginnormal_vertex>
3188
+ #include <morphnormal_vertex>
3189
+ #include <skinbase_vertex>
3190
+ #include <skinnormal_vertex>
3191
+ #include <defaultnormal_vertex>
3192
+ #include <normal_vertex>
3193
+ #include <begin_vertex>
3194
+ #include <morphtarget_vertex>
3195
+ #include <skinning_vertex>
3196
+ #include <displacementmap_vertex>
3197
+ #include <project_vertex>
3198
+ #include <logdepthbuf_vertex>
3199
+ #include <clipping_planes_vertex>
3200
+ vViewPosition = - mvPosition.xyz;
3201
+ #include <worldpos_vertex>
3202
+ #include <shadowmap_vertex>
3203
+ #include <fog_vertex>
3204
+ #ifdef USE_TRANSMISSION
3205
+ vWorldPosition = worldPosition.xyz;
3206
+ #endif
3207
+ }`,vg=`#define STANDARD
3208
+ #ifdef PHYSICAL
3209
+ #define IOR
3210
+ #define USE_SPECULAR
3211
+ #endif
3212
+ uniform vec3 diffuse;
3213
+ uniform vec3 emissive;
3214
+ uniform float roughness;
3215
+ uniform float metalness;
3216
+ uniform float opacity;
3217
+ #ifdef IOR
3218
+ uniform float ior;
3219
+ #endif
3220
+ #ifdef USE_SPECULAR
3221
+ uniform float specularIntensity;
3222
+ uniform vec3 specularColor;
3223
+ #ifdef USE_SPECULAR_COLORMAP
3224
+ uniform sampler2D specularColorMap;
3225
+ #endif
3226
+ #ifdef USE_SPECULAR_INTENSITYMAP
3227
+ uniform sampler2D specularIntensityMap;
3228
+ #endif
3229
+ #endif
3230
+ #ifdef USE_CLEARCOAT
3231
+ uniform float clearcoat;
3232
+ uniform float clearcoatRoughness;
3233
+ #endif
3234
+ #ifdef USE_DISPERSION
3235
+ uniform float dispersion;
3236
+ #endif
3237
+ #ifdef USE_IRIDESCENCE
3238
+ uniform float iridescence;
3239
+ uniform float iridescenceIOR;
3240
+ uniform float iridescenceThicknessMinimum;
3241
+ uniform float iridescenceThicknessMaximum;
3242
+ #endif
3243
+ #ifdef USE_SHEEN
3244
+ uniform vec3 sheenColor;
3245
+ uniform float sheenRoughness;
3246
+ #ifdef USE_SHEEN_COLORMAP
3247
+ uniform sampler2D sheenColorMap;
3248
+ #endif
3249
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3250
+ uniform sampler2D sheenRoughnessMap;
3251
+ #endif
3252
+ #endif
3253
+ #ifdef USE_ANISOTROPY
3254
+ uniform vec2 anisotropyVector;
3255
+ #ifdef USE_ANISOTROPYMAP
3256
+ uniform sampler2D anisotropyMap;
3257
+ #endif
3258
+ #endif
3259
+ varying vec3 vViewPosition;
3260
+ #include <common>
3261
+ #include <packing>
3262
+ #include <dithering_pars_fragment>
3263
+ #include <color_pars_fragment>
3264
+ #include <uv_pars_fragment>
3265
+ #include <map_pars_fragment>
3266
+ #include <alphamap_pars_fragment>
3267
+ #include <alphatest_pars_fragment>
3268
+ #include <alphahash_pars_fragment>
3269
+ #include <aomap_pars_fragment>
3270
+ #include <lightmap_pars_fragment>
3271
+ #include <emissivemap_pars_fragment>
3272
+ #include <iridescence_fragment>
3273
+ #include <cube_uv_reflection_fragment>
3274
+ #include <envmap_common_pars_fragment>
3275
+ #include <envmap_physical_pars_fragment>
3276
+ #include <fog_pars_fragment>
3277
+ #include <lights_pars_begin>
3278
+ #include <normal_pars_fragment>
3279
+ #include <lights_physical_pars_fragment>
3280
+ #include <transmission_pars_fragment>
3281
+ #include <shadowmap_pars_fragment>
3282
+ #include <bumpmap_pars_fragment>
3283
+ #include <normalmap_pars_fragment>
3284
+ #include <clearcoat_pars_fragment>
3285
+ #include <iridescence_pars_fragment>
3286
+ #include <roughnessmap_pars_fragment>
3287
+ #include <metalnessmap_pars_fragment>
3288
+ #include <logdepthbuf_pars_fragment>
3289
+ #include <clipping_planes_pars_fragment>
3290
+ void main() {
3291
+ vec4 diffuseColor = vec4( diffuse, opacity );
3292
+ #include <clipping_planes_fragment>
3293
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3294
+ vec3 totalEmissiveRadiance = emissive;
3295
+ #include <logdepthbuf_fragment>
3296
+ #include <map_fragment>
3297
+ #include <color_fragment>
3298
+ #include <alphamap_fragment>
3299
+ #include <alphatest_fragment>
3300
+ #include <alphahash_fragment>
3301
+ #include <roughnessmap_fragment>
3302
+ #include <metalnessmap_fragment>
3303
+ #include <normal_fragment_begin>
3304
+ #include <normal_fragment_maps>
3305
+ #include <clearcoat_normal_fragment_begin>
3306
+ #include <clearcoat_normal_fragment_maps>
3307
+ #include <emissivemap_fragment>
3308
+ #include <lights_physical_fragment>
3309
+ #include <lights_fragment_begin>
3310
+ #include <lights_fragment_maps>
3311
+ #include <lights_fragment_end>
3312
+ #include <aomap_fragment>
3313
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3314
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3315
+ #include <transmission_fragment>
3316
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3317
+ #ifdef USE_SHEEN
3318
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3319
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3320
+ #endif
3321
+ #ifdef USE_CLEARCOAT
3322
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3323
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3324
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3325
+ #endif
3326
+ #include <opaque_fragment>
3327
+ #include <tonemapping_fragment>
3328
+ #include <colorspace_fragment>
3329
+ #include <fog_fragment>
3330
+ #include <premultiplied_alpha_fragment>
3331
+ #include <dithering_fragment>
3332
+ }`,yg=`#define TOON
3333
+ varying vec3 vViewPosition;
3334
+ #include <common>
3335
+ #include <batching_pars_vertex>
3336
+ #include <uv_pars_vertex>
3337
+ #include <displacementmap_pars_vertex>
3338
+ #include <color_pars_vertex>
3339
+ #include <fog_pars_vertex>
3340
+ #include <normal_pars_vertex>
3341
+ #include <morphtarget_pars_vertex>
3342
+ #include <skinning_pars_vertex>
3343
+ #include <shadowmap_pars_vertex>
3344
+ #include <logdepthbuf_pars_vertex>
3345
+ #include <clipping_planes_pars_vertex>
3346
+ void main() {
3347
+ #include <uv_vertex>
3348
+ #include <color_vertex>
3349
+ #include <morphinstance_vertex>
3350
+ #include <morphcolor_vertex>
3351
+ #include <batching_vertex>
3352
+ #include <beginnormal_vertex>
3353
+ #include <morphnormal_vertex>
3354
+ #include <skinbase_vertex>
3355
+ #include <skinnormal_vertex>
3356
+ #include <defaultnormal_vertex>
3357
+ #include <normal_vertex>
3358
+ #include <begin_vertex>
3359
+ #include <morphtarget_vertex>
3360
+ #include <skinning_vertex>
3361
+ #include <displacementmap_vertex>
3362
+ #include <project_vertex>
3363
+ #include <logdepthbuf_vertex>
3364
+ #include <clipping_planes_vertex>
3365
+ vViewPosition = - mvPosition.xyz;
3366
+ #include <worldpos_vertex>
3367
+ #include <shadowmap_vertex>
3368
+ #include <fog_vertex>
3369
+ }`,Mg=`#define TOON
3370
+ uniform vec3 diffuse;
3371
+ uniform vec3 emissive;
3372
+ uniform float opacity;
3373
+ #include <common>
3374
+ #include <packing>
3375
+ #include <dithering_pars_fragment>
3376
+ #include <color_pars_fragment>
3377
+ #include <uv_pars_fragment>
3378
+ #include <map_pars_fragment>
3379
+ #include <alphamap_pars_fragment>
3380
+ #include <alphatest_pars_fragment>
3381
+ #include <alphahash_pars_fragment>
3382
+ #include <aomap_pars_fragment>
3383
+ #include <lightmap_pars_fragment>
3384
+ #include <emissivemap_pars_fragment>
3385
+ #include <gradientmap_pars_fragment>
3386
+ #include <fog_pars_fragment>
3387
+ #include <bsdfs>
3388
+ #include <lights_pars_begin>
3389
+ #include <normal_pars_fragment>
3390
+ #include <lights_toon_pars_fragment>
3391
+ #include <shadowmap_pars_fragment>
3392
+ #include <bumpmap_pars_fragment>
3393
+ #include <normalmap_pars_fragment>
3394
+ #include <logdepthbuf_pars_fragment>
3395
+ #include <clipping_planes_pars_fragment>
3396
+ void main() {
3397
+ vec4 diffuseColor = vec4( diffuse, opacity );
3398
+ #include <clipping_planes_fragment>
3399
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3400
+ vec3 totalEmissiveRadiance = emissive;
3401
+ #include <logdepthbuf_fragment>
3402
+ #include <map_fragment>
3403
+ #include <color_fragment>
3404
+ #include <alphamap_fragment>
3405
+ #include <alphatest_fragment>
3406
+ #include <alphahash_fragment>
3407
+ #include <normal_fragment_begin>
3408
+ #include <normal_fragment_maps>
3409
+ #include <emissivemap_fragment>
3410
+ #include <lights_toon_fragment>
3411
+ #include <lights_fragment_begin>
3412
+ #include <lights_fragment_maps>
3413
+ #include <lights_fragment_end>
3414
+ #include <aomap_fragment>
3415
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3416
+ #include <opaque_fragment>
3417
+ #include <tonemapping_fragment>
3418
+ #include <colorspace_fragment>
3419
+ #include <fog_fragment>
3420
+ #include <premultiplied_alpha_fragment>
3421
+ #include <dithering_fragment>
3422
+ }`,Sg=`uniform float size;
3423
+ uniform float scale;
3424
+ #include <common>
3425
+ #include <color_pars_vertex>
3426
+ #include <fog_pars_vertex>
3427
+ #include <morphtarget_pars_vertex>
3428
+ #include <logdepthbuf_pars_vertex>
3429
+ #include <clipping_planes_pars_vertex>
3430
+ #ifdef USE_POINTS_UV
3431
+ varying vec2 vUv;
3432
+ uniform mat3 uvTransform;
3433
+ #endif
3434
+ void main() {
3435
+ #ifdef USE_POINTS_UV
3436
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3437
+ #endif
3438
+ #include <color_vertex>
3439
+ #include <morphinstance_vertex>
3440
+ #include <morphcolor_vertex>
3441
+ #include <begin_vertex>
3442
+ #include <morphtarget_vertex>
3443
+ #include <project_vertex>
3444
+ gl_PointSize = size;
3445
+ #ifdef USE_SIZEATTENUATION
3446
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3447
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3448
+ #endif
3449
+ #include <logdepthbuf_vertex>
3450
+ #include <clipping_planes_vertex>
3451
+ #include <worldpos_vertex>
3452
+ #include <fog_vertex>
3453
+ }`,bg=`uniform vec3 diffuse;
3454
+ uniform float opacity;
3455
+ #include <common>
3456
+ #include <color_pars_fragment>
3457
+ #include <map_particle_pars_fragment>
3458
+ #include <alphatest_pars_fragment>
3459
+ #include <alphahash_pars_fragment>
3460
+ #include <fog_pars_fragment>
3461
+ #include <logdepthbuf_pars_fragment>
3462
+ #include <clipping_planes_pars_fragment>
3463
+ void main() {
3464
+ vec4 diffuseColor = vec4( diffuse, opacity );
3465
+ #include <clipping_planes_fragment>
3466
+ vec3 outgoingLight = vec3( 0.0 );
3467
+ #include <logdepthbuf_fragment>
3468
+ #include <map_particle_fragment>
3469
+ #include <color_fragment>
3470
+ #include <alphatest_fragment>
3471
+ #include <alphahash_fragment>
3472
+ outgoingLight = diffuseColor.rgb;
3473
+ #include <opaque_fragment>
3474
+ #include <tonemapping_fragment>
3475
+ #include <colorspace_fragment>
3476
+ #include <fog_fragment>
3477
+ #include <premultiplied_alpha_fragment>
3478
+ }`,Eg=`#include <common>
3479
+ #include <batching_pars_vertex>
3480
+ #include <fog_pars_vertex>
3481
+ #include <morphtarget_pars_vertex>
3482
+ #include <skinning_pars_vertex>
3483
+ #include <logdepthbuf_pars_vertex>
3484
+ #include <shadowmap_pars_vertex>
3485
+ void main() {
3486
+ #include <batching_vertex>
3487
+ #include <beginnormal_vertex>
3488
+ #include <morphinstance_vertex>
3489
+ #include <morphnormal_vertex>
3490
+ #include <skinbase_vertex>
3491
+ #include <skinnormal_vertex>
3492
+ #include <defaultnormal_vertex>
3493
+ #include <begin_vertex>
3494
+ #include <morphtarget_vertex>
3495
+ #include <skinning_vertex>
3496
+ #include <project_vertex>
3497
+ #include <logdepthbuf_vertex>
3498
+ #include <worldpos_vertex>
3499
+ #include <shadowmap_vertex>
3500
+ #include <fog_vertex>
3501
+ }`,Tg=`uniform vec3 color;
3502
+ uniform float opacity;
3503
+ #include <common>
3504
+ #include <packing>
3505
+ #include <fog_pars_fragment>
3506
+ #include <bsdfs>
3507
+ #include <lights_pars_begin>
3508
+ #include <logdepthbuf_pars_fragment>
3509
+ #include <shadowmap_pars_fragment>
3510
+ #include <shadowmask_pars_fragment>
3511
+ void main() {
3512
+ #include <logdepthbuf_fragment>
3513
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3514
+ #include <tonemapping_fragment>
3515
+ #include <colorspace_fragment>
3516
+ #include <fog_fragment>
3517
+ }`,Ag=`uniform float rotation;
3518
+ uniform vec2 center;
3519
+ #include <common>
3520
+ #include <uv_pars_vertex>
3521
+ #include <fog_pars_vertex>
3522
+ #include <logdepthbuf_pars_vertex>
3523
+ #include <clipping_planes_pars_vertex>
3524
+ void main() {
3525
+ #include <uv_vertex>
3526
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3527
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3528
+ #ifndef USE_SIZEATTENUATION
3529
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3530
+ if ( isPerspective ) scale *= - mvPosition.z;
3531
+ #endif
3532
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3533
+ vec2 rotatedPosition;
3534
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3535
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3536
+ mvPosition.xy += rotatedPosition;
3537
+ gl_Position = projectionMatrix * mvPosition;
3538
+ #include <logdepthbuf_vertex>
3539
+ #include <clipping_planes_vertex>
3540
+ #include <fog_vertex>
3541
+ }`,wg=`uniform vec3 diffuse;
3542
+ uniform float opacity;
3543
+ #include <common>
3544
+ #include <uv_pars_fragment>
3545
+ #include <map_pars_fragment>
3546
+ #include <alphamap_pars_fragment>
3547
+ #include <alphatest_pars_fragment>
3548
+ #include <alphahash_pars_fragment>
3549
+ #include <fog_pars_fragment>
3550
+ #include <logdepthbuf_pars_fragment>
3551
+ #include <clipping_planes_pars_fragment>
3552
+ void main() {
3553
+ vec4 diffuseColor = vec4( diffuse, opacity );
3554
+ #include <clipping_planes_fragment>
3555
+ vec3 outgoingLight = vec3( 0.0 );
3556
+ #include <logdepthbuf_fragment>
3557
+ #include <map_fragment>
3558
+ #include <alphamap_fragment>
3559
+ #include <alphatest_fragment>
3560
+ #include <alphahash_fragment>
3561
+ outgoingLight = diffuseColor.rgb;
3562
+ #include <opaque_fragment>
3563
+ #include <tonemapping_fragment>
3564
+ #include <colorspace_fragment>
3565
+ #include <fog_fragment>
3566
+ }`,Xt={alphahash_fragment:Jf,alphahash_pars_fragment:$f,alphamap_fragment:Kf,alphamap_pars_fragment:Qf,alphatest_fragment:jf,alphatest_pars_fragment:tp,aomap_fragment:ep,aomap_pars_fragment:np,batching_pars_vertex:ip,batching_vertex:sp,begin_vertex:rp,beginnormal_vertex:ap,bsdfs:op,iridescence_fragment:lp,bumpmap_pars_fragment:cp,clipping_planes_fragment:hp,clipping_planes_pars_fragment:up,clipping_planes_pars_vertex:dp,clipping_planes_vertex:fp,color_fragment:pp,color_pars_fragment:mp,color_pars_vertex:gp,color_vertex:_p,common:xp,cube_uv_reflection_fragment:vp,defaultnormal_vertex:yp,displacementmap_pars_vertex:Mp,displacementmap_vertex:Sp,emissivemap_fragment:bp,emissivemap_pars_fragment:Ep,colorspace_fragment:Tp,colorspace_pars_fragment:Ap,envmap_fragment:wp,envmap_common_pars_fragment:Cp,envmap_pars_fragment:Rp,envmap_pars_vertex:Ip,envmap_physical_pars_fragment:Vp,envmap_vertex:Pp,fog_vertex:Lp,fog_pars_vertex:Dp,fog_fragment:Up,fog_pars_fragment:Np,gradientmap_pars_fragment:Fp,lightmap_pars_fragment:Op,lights_lambert_fragment:Bp,lights_lambert_pars_fragment:zp,lights_pars_begin:kp,lights_toon_fragment:Hp,lights_toon_pars_fragment:Gp,lights_phong_fragment:Wp,lights_phong_pars_fragment:Xp,lights_physical_fragment:qp,lights_physical_pars_fragment:Yp,lights_fragment_begin:Zp,lights_fragment_maps:Jp,lights_fragment_end:$p,logdepthbuf_fragment:Kp,logdepthbuf_pars_fragment:Qp,logdepthbuf_pars_vertex:jp,logdepthbuf_vertex:tm,map_fragment:em,map_pars_fragment:nm,map_particle_fragment:im,map_particle_pars_fragment:sm,metalnessmap_fragment:rm,metalnessmap_pars_fragment:am,morphinstance_vertex:om,morphcolor_vertex:lm,morphnormal_vertex:cm,morphtarget_pars_vertex:hm,morphtarget_vertex:um,normal_fragment_begin:dm,normal_fragment_maps:fm,normal_pars_fragment:pm,normal_pars_vertex:mm,normal_vertex:gm,normalmap_pars_fragment:_m,clearcoat_normal_fragment_begin:xm,clearcoat_normal_fragment_maps:vm,clearcoat_pars_fragment:ym,iridescence_pars_fragment:Mm,opaque_fragment:Sm,packing:bm,premultiplied_alpha_fragment:Em,project_vertex:Tm,dithering_fragment:Am,dithering_pars_fragment:wm,roughnessmap_fragment:Cm,roughnessmap_pars_fragment:Rm,shadowmap_pars_fragment:Im,shadowmap_pars_vertex:Pm,shadowmap_vertex:Lm,shadowmask_pars_fragment:Dm,skinbase_vertex:Um,skinning_pars_vertex:Nm,skinning_vertex:Fm,skinnormal_vertex:Om,specularmap_fragment:Bm,specularmap_pars_fragment:zm,tonemapping_fragment:km,tonemapping_pars_fragment:Vm,transmission_fragment:Hm,transmission_pars_fragment:Gm,uv_pars_fragment:Wm,uv_pars_vertex:Xm,uv_vertex:qm,worldpos_vertex:Ym,background_vert:Zm,background_frag:Jm,backgroundCube_vert:$m,backgroundCube_frag:Km,cube_vert:Qm,cube_frag:jm,depth_vert:tg,depth_frag:eg,distanceRGBA_vert:ng,distanceRGBA_frag:ig,equirect_vert:sg,equirect_frag:rg,linedashed_vert:ag,linedashed_frag:og,meshbasic_vert:lg,meshbasic_frag:cg,meshlambert_vert:hg,meshlambert_frag:ug,meshmatcap_vert:dg,meshmatcap_frag:fg,meshnormal_vert:pg,meshnormal_frag:mg,meshphong_vert:gg,meshphong_frag:_g,meshphysical_vert:xg,meshphysical_frag:vg,meshtoon_vert:yg,meshtoon_frag:Mg,points_vert:Sg,points_frag:bg,shadow_vert:Eg,shadow_frag:Tg,sprite_vert:Ag,sprite_frag:wg},ut={common:{diffuse:{value:new Ut(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Vt},alphaMap:{value:null},alphaMapTransform:{value:new Vt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Vt}},envmap:{envMap:{value:null},envMapRotation:{value:new Vt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Vt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Vt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Vt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Vt},normalScale:{value:new ot(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Vt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Vt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Vt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Vt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ut(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ut(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Vt},alphaTest:{value:0},uvTransform:{value:new Vt}},sprite:{diffuse:{value:new Ut(16777215)},opacity:{value:1},center:{value:new ot(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Vt},alphaMap:{value:null},alphaMapTransform:{value:new Vt},alphaTest:{value:0}}},mn={basic:{uniforms:Re([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:Re([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Ut(0)}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:Re([ut.common,ut.specularmap,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,ut.lights,{emissive:{value:new Ut(0)},specular:{value:new Ut(1118481)},shininess:{value:30}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:Re([ut.common,ut.envmap,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.roughnessmap,ut.metalnessmap,ut.fog,ut.lights,{emissive:{value:new Ut(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:Re([ut.common,ut.aomap,ut.lightmap,ut.emissivemap,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.gradientmap,ut.fog,ut.lights,{emissive:{value:new Ut(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:Re([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,ut.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:Re([ut.points,ut.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:Re([ut.common,ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:Re([ut.common,ut.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:Re([ut.common,ut.bumpmap,ut.normalmap,ut.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:Re([ut.sprite,ut.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new Vt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Vt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distanceRGBA:{uniforms:Re([ut.common,ut.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distanceRGBA_vert,fragmentShader:Xt.distanceRGBA_frag},shadow:{uniforms:Re([ut.lights,ut.fog,{color:{value:new Ut(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};mn.physical={uniforms:Re([mn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Vt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Vt},clearcoatNormalScale:{value:new ot(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Vt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Vt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Vt},sheen:{value:0},sheenColor:{value:new Ut(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Vt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Vt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Vt},transmissionSamplerSize:{value:new ot},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Vt},attenuationDistance:{value:0},attenuationColor:{value:new Ut(0)},specularColor:{value:new Ut(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Vt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Vt},anisotropyVector:{value:new ot},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Vt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};var io={r:0,b:0,g:0},xi=new Ke,Cg=new Wt;function Rg(s,t,e,n,i,r,a){let o=new Ut(0),l=r===!0?0:1,c,h,u=null,d=0,p=null;function g(M){let v=M.isScene===!0?M.background:null;return v&&v.isTexture&&(v=(M.backgroundBlurriness>0?e:t).get(v)),v}function x(M){let v=!1,I=g(M);I===null?f(o,l):I&&I.isColor&&(f(I,1),v=!0);let w=s.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(M,v){let I=g(v);I&&(I.isCubeTexture||I.mapping===Gs)?(h===void 0&&(h=new be(new Gi(1,1,1),new an({name:"BackgroundCubeMaterial",uniforms:_i(mn.backgroundCube.uniforms),vertexShader:mn.backgroundCube.vertexShader,fragmentShader:mn.backgroundCube.fragmentShader,side:Ue,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,R,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),xi.copy(v.backgroundRotation),xi.x*=-1,xi.y*=-1,xi.z*=-1,I.isCubeTexture&&I.isRenderTargetTexture===!1&&(xi.y*=-1,xi.z*=-1),h.material.uniforms.envMap.value=I,h.material.uniforms.flipEnvMap.value=I.isCubeTexture&&I.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Cg.makeRotationFromEuler(xi)),h.material.toneMapped=Jt.getTransfer(I.colorSpace)!==ee,(u!==I||d!==I.version||p!==s.toneMapping)&&(h.material.needsUpdate=!0,u=I,d=I.version,p=s.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):I&&I.isTexture&&(c===void 0&&(c=new be(new zs(2,2),new an({name:"BackgroundMaterial",uniforms:_i(mn.background.uniforms),vertexShader:mn.background.vertexShader,fragmentShader:mn.background.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=I,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=Jt.getTransfer(I.colorSpace)!==ee,I.matrixAutoUpdate===!0&&I.updateMatrix(),c.material.uniforms.uvTransform.value.copy(I.matrix),(u!==I||d!==I.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,u=I,d=I.version,p=s.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function f(M,v){M.getRGB(io,ec(s)),n.buffers.color.setClear(io.r,io.g,io.b,v,a)}function A(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(M,v=1){o.set(M),l=v,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(M){l=M,f(o,l)},render:x,addToRenderList:m,dispose:A}}function Ig(s,t){let e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null),r=i,a=!1;function o(S,P,Y,z,X){let J=!1,G=u(z,Y,P);r!==G&&(r=G,c(r.object)),J=p(S,z,Y,X),J&&g(S,z,Y,X),X!==null&&t.update(X,s.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,v(S,P,Y,z),X!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(X).buffer))}function l(){return s.createVertexArray()}function c(S){return s.bindVertexArray(S)}function h(S){return s.deleteVertexArray(S)}function u(S,P,Y){let z=Y.wireframe===!0,X=n[S.id];X===void 0&&(X={},n[S.id]=X);let J=X[P.id];J===void 0&&(J={},X[P.id]=J);let G=J[z];return G===void 0&&(G=d(l()),J[z]=G),G}function d(S){let P=[],Y=[],z=[];for(let X=0;X<e;X++)P[X]=0,Y[X]=0,z[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:Y,attributeDivisors:z,object:S,attributes:{},index:null}}function p(S,P,Y,z){let X=r.attributes,J=P.attributes,G=0,tt=Y.getAttributes();for(let k in tt)if(tt[k].location>=0){let mt=X[k],Mt=J[k];if(Mt===void 0&&(k==="instanceMatrix"&&S.instanceMatrix&&(Mt=S.instanceMatrix),k==="instanceColor"&&S.instanceColor&&(Mt=S.instanceColor)),mt===void 0||mt.attribute!==Mt||Mt&&mt.data!==Mt.data)return!0;G++}return r.attributesNum!==G||r.index!==z}function g(S,P,Y,z){let X={},J=P.attributes,G=0,tt=Y.getAttributes();for(let k in tt)if(tt[k].location>=0){let mt=J[k];mt===void 0&&(k==="instanceMatrix"&&S.instanceMatrix&&(mt=S.instanceMatrix),k==="instanceColor"&&S.instanceColor&&(mt=S.instanceColor));let Mt={};Mt.attribute=mt,mt&&mt.data&&(Mt.data=mt.data),X[k]=Mt,G++}r.attributes=X,r.attributesNum=G,r.index=z}function x(){let S=r.newAttributes;for(let P=0,Y=S.length;P<Y;P++)S[P]=0}function m(S){f(S,0)}function f(S,P){let Y=r.newAttributes,z=r.enabledAttributes,X=r.attributeDivisors;Y[S]=1,z[S]===0&&(s.enableVertexAttribArray(S),z[S]=1),X[S]!==P&&(s.vertexAttribDivisor(S,P),X[S]=P)}function A(){let S=r.newAttributes,P=r.enabledAttributes;for(let Y=0,z=P.length;Y<z;Y++)P[Y]!==S[Y]&&(s.disableVertexAttribArray(Y),P[Y]=0)}function M(S,P,Y,z,X,J,G){G===!0?s.vertexAttribIPointer(S,P,Y,X,J):s.vertexAttribPointer(S,P,Y,z,X,J)}function v(S,P,Y,z){x();let X=z.attributes,J=Y.getAttributes(),G=P.defaultAttributeValues;for(let tt in J){let k=J[tt];if(k.location>=0){let lt=X[tt];if(lt===void 0&&(tt==="instanceMatrix"&&S.instanceMatrix&&(lt=S.instanceMatrix),tt==="instanceColor"&&S.instanceColor&&(lt=S.instanceColor)),lt!==void 0){let mt=lt.normalized,Mt=lt.itemSize,kt=t.get(lt);if(kt===void 0)continue;let Zt=kt.buffer,W=kt.type,st=kt.bytesPerElement,wt=W===s.INT||W===s.UNSIGNED_INT||lt.gpuType===Ea;if(lt.isInterleavedBufferAttribute){let pt=lt.data,Ct=pt.stride,Ht=lt.offset;if(pt.isInstancedInterleavedBuffer){for(let It=0;It<k.locationSize;It++)f(k.location+It,pt.meshPerAttribute);S.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=pt.meshPerAttribute*pt.count)}else for(let It=0;It<k.locationSize;It++)m(k.location+It);s.bindBuffer(s.ARRAY_BUFFER,Zt);for(let It=0;It<k.locationSize;It++)M(k.location+It,Mt/k.locationSize,W,mt,Ct*st,(Ht+Mt/k.locationSize*It)*st,wt)}else{if(lt.isInstancedBufferAttribute){for(let pt=0;pt<k.locationSize;pt++)f(k.location+pt,lt.meshPerAttribute);S.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=lt.meshPerAttribute*lt.count)}else for(let pt=0;pt<k.locationSize;pt++)m(k.location+pt);s.bindBuffer(s.ARRAY_BUFFER,Zt);for(let pt=0;pt<k.locationSize;pt++)M(k.location+pt,Mt/k.locationSize,W,mt,Mt*st,Mt/k.locationSize*pt*st,wt)}}else if(G!==void 0){let mt=G[tt];if(mt!==void 0)switch(mt.length){case 2:s.vertexAttrib2fv(k.location,mt);break;case 3:s.vertexAttrib3fv(k.location,mt);break;case 4:s.vertexAttrib4fv(k.location,mt);break;default:s.vertexAttrib1fv(k.location,mt)}}}}A()}function I(){D();for(let S in n){let P=n[S];for(let Y in P){let z=P[Y];for(let X in z)h(z[X].object),delete z[X];delete P[Y]}delete n[S]}}function w(S){if(n[S.id]===void 0)return;let P=n[S.id];for(let Y in P){let z=P[Y];for(let X in z)h(z[X].object),delete z[X];delete P[Y]}delete n[S.id]}function R(S){for(let P in n){let Y=n[P];if(Y[S.id]===void 0)continue;let z=Y[S.id];for(let X in z)h(z[X].object),delete z[X];delete Y[S.id]}}function D(){E(),a=!0,r!==i&&(r=i,c(r.object))}function E(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:D,resetDefaultState:E,dispose:I,releaseStatesOfGeometry:w,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:A}}function Pg(s,t,e){let n;function i(c){n=c}function r(c,h){s.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(s.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let p=0;for(let g=0;g<u;g++)p+=h[g];e.update(p,n,1)}function l(c,h,u,d){if(u===0)return;let p=t.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let x=0;x<u;x++)g+=h[x]*d[x];e.update(g,n,1)}}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Lg(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==De&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){let D=R===$i&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==on&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Be&&!D)}function l(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),A=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),M=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),I=g>0,w=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:M,maxFragmentUniforms:v,vertexTextures:I,maxSamples:w}}function Dg(s){let t=this,e=null,n=0,i=!1,r=!1,a=new hn,o=new Vt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let p=u.length!==0||d||n!==0||i;return i=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,p){let g=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,f=s.get(u);if(!i||g===null||g.length===0||r&&!m)r?h(null):c();else{let A=r?0:n,M=A*4,v=f.clippingState||null;l.value=v,v=h(g,d,M,p);for(let I=0;I!==M;++I)v[I]=e[I];f.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,p,g){let x=u!==null?u.length:0,m=null;if(x!==0){if(m=l.value,g!==!0||m===null){let f=p+x*4,A=d.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let M=0,v=p;M!==x;++M,v+=4)a.copy(u[M]).applyMatrix4(A,o),a.normal.toArray(m,v),m[v+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,m}}function Ug(s){let t=new WeakMap;function e(a,o){return o===Ma?a.mapping=mi:o===Sa&&(a.mapping=gi),a}function n(a){if(a&&a.isTexture){let o=a.mapping;if(o===Ma||o===Sa)if(t.has(a)){let l=t.get(a).texture;return e(l,a.mapping)}else{let l=a.image;if(l&&l.height>0){let c=new Wr(l.height);return c.fromEquirectangularTexture(s,a),t.set(a,c),a.addEventListener("dispose",i),e(c.texture,a.mapping)}else return null}}return a}function i(a){let o=a.target;o.removeEventListener("dispose",i);let l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var ts=4,Mu=[.125,.215,.35,.446,.526,.582],Mi=20,ac=new Hs,Su=new Ut,oc=null,lc=0,cc=0,hc=!1,yi=(1+Math.sqrt(5))/2,ji=1/yi,bu=[new C(-yi,ji,0),new C(yi,ji,0),new C(-ji,0,yi),new C(ji,0,yi),new C(0,yi,-ji),new C(0,yi,ji),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)],Ng=new C,ao=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100,r={}){let{size:a=256,position:o=Ng}=r;oc=this._renderer.getRenderTarget(),lc=this._renderer.getActiveCubeFace(),cc=this._renderer.getActiveMipmapLevel(),hc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,i,l,o),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Au(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Tu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(oc,lc,cc),this._renderer.xr.enabled=hc,t.scissorTest=!1,so(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===mi||t.mapping===gi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),oc=this._renderer.getRenderTarget(),lc=this._renderer.getActiveCubeFace(),cc=this._renderer.getActiveMipmapLevel(),hc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:sn,minFilter:sn,generateMipmaps:!1,type:$i,format:De,colorSpace:ai,depthBuffer:!1},i=Eu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Eu(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Fg(r)),this._blurMaterial=Og(r,t,e)}return i}_compileMaterial(t){let e=new be(this._lodPlanes[0],t);this._renderer.compile(e,ac)}_sceneToCubeUV(t,e,n,i,r){let l=new we(90,1,e,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(Su),u.toneMapping=Pn,u.autoClear=!1;let g=new Ss({name:"PMREM.Background",side:Ue,depthWrite:!1,depthTest:!1}),x=new be(new Gi,g),m=!1,f=t.background;f?f.isColor&&(g.color.copy(f),t.background=null,m=!0):(g.color.copy(Su),m=!0);for(let A=0;A<6;A++){let M=A%3;M===0?(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[A],r.y,r.z)):M===1?(l.up.set(0,0,c[A]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[A],r.z)):(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[A]));let v=this._cubeSize;so(i,M*v,A>2?v:0,v,v),u.setRenderTarget(i),m&&u.render(x,l),u.render(t,l)}x.geometry.dispose(),x.material.dispose(),u.toneMapping=p,u.autoClear=d,t.background=f}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===mi||t.mapping===gi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Au()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Tu());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new be(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let l=this._cubeSize;so(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,ac)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodPlanes.length;for(let r=1;r<i;r++){let a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=bu[(i-r-1)%bu.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,i,r){let a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new be(this._lodPlanes[i],c),d=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Mi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Mi;m>Mi&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Mi}`);let f=[],A=0;for(let R=0;R<Mi;++R){let D=R/x,E=Math.exp(-D*D/2);f.push(E),R===0?A+=E:R<m&&(A+=2*E)}for(let R=0;R<f.length;R++)f[R]=f[R]/A;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);let{_lodMax:M}=this;d.dTheta.value=g,d.mipInt.value=M-n;let v=this._sizeLods[i],I=3*v*(i>M-ts?i-M+ts:0),w=4*(this._cubeSize-v);so(e,I,w,3*v,2*v),l.setRenderTarget(e),l.render(u,ac)}};function Fg(s){let t=[],e=[],n=[],i=s,r=s-ts+1+Mu.length;for(let a=0;a<r;a++){let o=Math.pow(2,i);e.push(o);let l=1/o;a>s-ts?l=Mu[a-s+ts-1]:a===0&&(l=0),n.push(l);let c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,x=3,m=2,f=1,A=new Float32Array(x*g*p),M=new Float32Array(m*g*p),v=new Float32Array(f*g*p);for(let w=0;w<p;w++){let R=w%3*2/3-1,D=w>2?0:-1,E=[R,D,0,R+2/3,D,0,R+2/3,D+1,0,R,D,0,R+2/3,D+1,0,R,D+1,0];A.set(E,x*g*w),M.set(d,m*g*w);let S=[w,w,w,w,w,w];v.set(S,f*g*w)}let I=new _e;I.setAttribute("position",new Me(A,x)),I.setAttribute("uv",new Me(M,m)),I.setAttribute("faceIndex",new Me(v,f)),t.push(I),i>ts&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Eu(s,t,e){let n=new dn(s,t,e);return n.texture.mapping=Gs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function so(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function Og(s,t,e){let n=new Float32Array(Mi),i=new C(0,1,0);return new an({name:"SphericalGaussianBlur",defines:{n:Mi,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:yc(),fragmentShader:`
3567
+
3568
+ precision mediump float;
3569
+ precision mediump int;
3570
+
3571
+ varying vec3 vOutputDirection;
3572
+
3573
+ uniform sampler2D envMap;
3574
+ uniform int samples;
3575
+ uniform float weights[ n ];
3576
+ uniform bool latitudinal;
3577
+ uniform float dTheta;
3578
+ uniform float mipInt;
3579
+ uniform vec3 poleAxis;
3580
+
3581
+ #define ENVMAP_TYPE_CUBE_UV
3582
+ #include <cube_uv_reflection_fragment>
3583
+
3584
+ vec3 getSample( float theta, vec3 axis ) {
3585
+
3586
+ float cosTheta = cos( theta );
3587
+ // Rodrigues' axis-angle rotation
3588
+ vec3 sampleDirection = vOutputDirection * cosTheta
3589
+ + cross( axis, vOutputDirection ) * sin( theta )
3590
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3591
+
3592
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3593
+
3594
+ }
3595
+
3596
+ void main() {
3597
+
3598
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3599
+
3600
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3601
+
3602
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3603
+
3604
+ }
3605
+
3606
+ axis = normalize( axis );
3607
+
3608
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3609
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3610
+
3611
+ for ( int i = 1; i < n; i++ ) {
3612
+
3613
+ if ( i >= samples ) {
3614
+
3615
+ break;
3616
+
3617
+ }
3618
+
3619
+ float theta = dTheta * float( i );
3620
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3621
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3622
+
3623
+ }
3624
+
3625
+ }
3626
+ `,blending:In,depthTest:!1,depthWrite:!1})}function Tu(){return new an({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yc(),fragmentShader:`
3627
+
3628
+ precision mediump float;
3629
+ precision mediump int;
3630
+
3631
+ varying vec3 vOutputDirection;
3632
+
3633
+ uniform sampler2D envMap;
3634
+
3635
+ #include <common>
3636
+
3637
+ void main() {
3638
+
3639
+ vec3 outputDirection = normalize( vOutputDirection );
3640
+ vec2 uv = equirectUv( outputDirection );
3641
+
3642
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3643
+
3644
+ }
3645
+ `,blending:In,depthTest:!1,depthWrite:!1})}function Au(){return new an({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yc(),fragmentShader:`
3646
+
3647
+ precision mediump float;
3648
+ precision mediump int;
3649
+
3650
+ uniform float flipEnvMap;
3651
+
3652
+ varying vec3 vOutputDirection;
3653
+
3654
+ uniform samplerCube envMap;
3655
+
3656
+ void main() {
3657
+
3658
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3659
+
3660
+ }
3661
+ `,blending:In,depthTest:!1,depthWrite:!1})}function yc(){return`
3662
+
3663
+ precision mediump float;
3664
+ precision mediump int;
3665
+
3666
+ attribute float faceIndex;
3667
+
3668
+ varying vec3 vOutputDirection;
3669
+
3670
+ // RH coordinate system; PMREM face-indexing convention
3671
+ vec3 getDirection( vec2 uv, float face ) {
3672
+
3673
+ uv = 2.0 * uv - 1.0;
3674
+
3675
+ vec3 direction = vec3( uv, 1.0 );
3676
+
3677
+ if ( face == 0.0 ) {
3678
+
3679
+ direction = direction.zyx; // ( 1, v, u ) pos x
3680
+
3681
+ } else if ( face == 1.0 ) {
3682
+
3683
+ direction = direction.xzy;
3684
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3685
+
3686
+ } else if ( face == 2.0 ) {
3687
+
3688
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3689
+
3690
+ } else if ( face == 3.0 ) {
3691
+
3692
+ direction = direction.zyx;
3693
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3694
+
3695
+ } else if ( face == 4.0 ) {
3696
+
3697
+ direction = direction.xzy;
3698
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3699
+
3700
+ } else if ( face == 5.0 ) {
3701
+
3702
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3703
+
3704
+ }
3705
+
3706
+ return direction;
3707
+
3708
+ }
3709
+
3710
+ void main() {
3711
+
3712
+ vOutputDirection = getDirection( uv, faceIndex );
3713
+ gl_Position = vec4( position, 1.0 );
3714
+
3715
+ }
3716
+ `}function Bg(s){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let l=o.mapping,c=l===Ma||l===Sa,h=l===mi||l===gi;if(c||h){let u=t.get(o),d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new ao(s)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{let p=o.image;return c&&p&&p.height>0||h&&p&&i(p)?(e===null&&(e=new ao(s)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function i(o){let l=0,c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function r(o){let l=o.target;l.removeEventListener("dispose",r);let c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function zg(s){let t={};function e(n){if(t[n]!==void 0)return t[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let i=e(n);return i===null&&li("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function kg(s,t,e,n){let i={},r=new WeakMap;function a(u){let d=u.target;d.index!==null&&t.remove(d.index);for(let g in d.attributes)t.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete i[d.id];let p=r.get(d);p&&(t.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,e.memory.geometries++),d}function l(u){let d=u.attributes;for(let p in d)t.update(d[p],s.ARRAY_BUFFER)}function c(u){let d=[],p=u.index,g=u.attributes.position,x=0;if(p!==null){let A=p.array;x=p.version;for(let M=0,v=A.length;M<v;M+=3){let I=A[M+0],w=A[M+1],R=A[M+2];d.push(I,w,w,R,R,I)}}else if(g!==void 0){let A=g.array;x=g.version;for(let M=0,v=A.length/3-1;M<v;M+=3){let I=M+0,w=M+1,R=M+2;d.push(I,w,w,R,R,I)}}else return;let m=new(tc(d)?Es:bs)(d,1);m.version=x;let f=r.get(u);f&&t.remove(f),r.set(u,m)}function h(u){let d=r.get(u);if(d){let p=u.index;p!==null&&d.version<p.version&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function Vg(s,t,e){let n;function i(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,p){s.drawElements(n,p,r,d*a),e.update(p,n,1)}function c(d,p,g){g!==0&&(s.drawElementsInstanced(n,p,r,d*a,g),e.update(p,n,g))}function h(d,p,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,d,0,g);let m=0;for(let f=0;f<g;f++)m+=p[f];e.update(m,n,1)}function u(d,p,g,x){if(g===0)return;let m=t.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/a,p[f],x[f]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,d,0,x,0,g);let f=0;for(let A=0;A<g;A++)f+=p[A]*x[A];e.update(f,n,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function Hg(s){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case s.TRIANGLES:e.triangles+=o*(r/3);break;case s.LINES:e.lines+=o*(r/2);break;case s.LINE_STRIP:e.lines+=o*(r-1);break;case s.LINE_LOOP:e.lines+=o*r;break;case s.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function Gg(s,t,e){let n=new WeakMap,i=new Qt;function r(a,o,l){let c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0,d=n.get(o);if(d===void 0||d.count!==u){let E=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();let p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],A=o.morphAttributes.color||[],M=0;p===!0&&(M=1),g===!0&&(M=2),x===!0&&(M=3);let v=o.attributes.position.count*M,I=1;v>t.maxTextureSize&&(I=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let w=new Float32Array(v*I*4*u),R=new Ms(w,v,I,u);R.type=Be,R.needsUpdate=!0;let D=M*4;for(let S=0;S<u;S++){let P=m[S],Y=f[S],z=A[S],X=v*I*4*S;for(let J=0;J<P.count;J++){let G=J*D;p===!0&&(i.fromBufferAttribute(P,J),w[X+G+0]=i.x,w[X+G+1]=i.y,w[X+G+2]=i.z,w[X+G+3]=0),g===!0&&(i.fromBufferAttribute(Y,J),w[X+G+4]=i.x,w[X+G+5]=i.y,w[X+G+6]=i.z,w[X+G+7]=0),x===!0&&(i.fromBufferAttribute(z,J),w[X+G+8]=i.x,w[X+G+9]=i.y,w[X+G+10]=i.z,w[X+G+11]=z.itemSize===4?i.w:1)}}d={count:u,texture:R,size:new ot(v,I)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,e);else{let p=0;for(let x=0;x<c.length;x++)p+=c[x];let g=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function Wg(s,t,e,n){let i=new WeakMap;function r(l){let c=n.render.frame,h=l.geometry,u=t.get(l,h);if(i.get(u)!==c&&(t.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(e.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,s.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){let d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return u}function a(){i=new WeakMap}function o(l){let c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:r,dispose:a}}var qu=new Se,wu=new Rs(1,1),Yu=new Ms,Zu=new Hr,Ju=new Ts,Cu=[],Ru=[],Iu=new Float32Array(16),Pu=new Float32Array(9),Lu=new Float32Array(4);function ns(s,t,e){let n=s[0];if(n<=0||n>0)return s;let i=t*e,r=Cu[i];if(r===void 0&&(r=new Float32Array(i),Cu[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function xe(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function ve(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function oo(s,t){let e=Ru[t];e===void 0&&(e=new Int32Array(t),Ru[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function Xg(s,t){let e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function qg(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(xe(e,t))return;s.uniform2fv(this.addr,t),ve(e,t)}}function Yg(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(xe(e,t))return;s.uniform3fv(this.addr,t),ve(e,t)}}function Zg(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(xe(e,t))return;s.uniform4fv(this.addr,t),ve(e,t)}}function Jg(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(xe(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),ve(e,t)}else{if(xe(e,n))return;Lu.set(n),s.uniformMatrix2fv(this.addr,!1,Lu),ve(e,n)}}function $g(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(xe(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),ve(e,t)}else{if(xe(e,n))return;Pu.set(n),s.uniformMatrix3fv(this.addr,!1,Pu),ve(e,n)}}function Kg(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(xe(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),ve(e,t)}else{if(xe(e,n))return;Iu.set(n),s.uniformMatrix4fv(this.addr,!1,Iu),ve(e,n)}}function Qg(s,t){let e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function jg(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(xe(e,t))return;s.uniform2iv(this.addr,t),ve(e,t)}}function t_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(xe(e,t))return;s.uniform3iv(this.addr,t),ve(e,t)}}function e_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(xe(e,t))return;s.uniform4iv(this.addr,t),ve(e,t)}}function n_(s,t){let e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function i_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(xe(e,t))return;s.uniform2uiv(this.addr,t),ve(e,t)}}function s_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(xe(e,t))return;s.uniform3uiv(this.addr,t),ve(e,t)}}function r_(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(xe(e,t))return;s.uniform4uiv(this.addr,t),ve(e,t)}}function a_(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(wu.compareFunction=Kl,r=wu):r=qu,e.setTexture2D(t||r,i)}function o_(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||Zu,i)}function l_(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||Ju,i)}function c_(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||Yu,i)}function h_(s){switch(s){case 5126:return Xg;case 35664:return qg;case 35665:return Yg;case 35666:return Zg;case 35674:return Jg;case 35675:return $g;case 35676:return Kg;case 5124:case 35670:return Qg;case 35667:case 35671:return jg;case 35668:case 35672:return t_;case 35669:case 35673:return e_;case 5125:return n_;case 36294:return i_;case 36295:return s_;case 36296:return r_;case 35678:case 36198:case 36298:case 36306:case 35682:return a_;case 35679:case 36299:case 36307:return o_;case 35680:case 36300:case 36308:case 36293:return l_;case 36289:case 36303:case 36311:case 36292:return c_}}function u_(s,t){s.uniform1fv(this.addr,t)}function d_(s,t){let e=ns(t,this.size,2);s.uniform2fv(this.addr,e)}function f_(s,t){let e=ns(t,this.size,3);s.uniform3fv(this.addr,e)}function p_(s,t){let e=ns(t,this.size,4);s.uniform4fv(this.addr,e)}function m_(s,t){let e=ns(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function g_(s,t){let e=ns(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function __(s,t){let e=ns(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function x_(s,t){s.uniform1iv(this.addr,t)}function v_(s,t){s.uniform2iv(this.addr,t)}function y_(s,t){s.uniform3iv(this.addr,t)}function M_(s,t){s.uniform4iv(this.addr,t)}function S_(s,t){s.uniform1uiv(this.addr,t)}function b_(s,t){s.uniform2uiv(this.addr,t)}function E_(s,t){s.uniform3uiv(this.addr,t)}function T_(s,t){s.uniform4uiv(this.addr,t)}function A_(s,t,e){let n=this.cache,i=t.length,r=oo(e,i);xe(n,r)||(s.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==i;++a)e.setTexture2D(t[a]||qu,r[a])}function w_(s,t,e){let n=this.cache,i=t.length,r=oo(e,i);xe(n,r)||(s.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==i;++a)e.setTexture3D(t[a]||Zu,r[a])}function C_(s,t,e){let n=this.cache,i=t.length,r=oo(e,i);xe(n,r)||(s.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==i;++a)e.setTextureCube(t[a]||Ju,r[a])}function R_(s,t,e){let n=this.cache,i=t.length,r=oo(e,i);xe(n,r)||(s.uniform1iv(this.addr,r),ve(n,r));for(let a=0;a!==i;++a)e.setTexture2DArray(t[a]||Yu,r[a])}function I_(s){switch(s){case 5126:return u_;case 35664:return d_;case 35665:return f_;case 35666:return p_;case 35674:return m_;case 35675:return g_;case 35676:return __;case 5124:case 35670:return x_;case 35667:case 35671:return v_;case 35668:case 35672:return y_;case 35669:case 35673:return M_;case 5125:return S_;case 36294:return b_;case 36295:return E_;case 36296:return T_;case 35678:case 36198:case 36298:case 36306:case 35682:return A_;case 35679:case 36299:case 36307:return w_;case 35680:case 36300:case 36308:case 36293:return C_;case 36289:case 36303:case 36311:case 36292:return R_}}var dc=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=h_(e.type)}},fc=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=I_(e.type)}},pc=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let r=0,a=i.length;r!==a;++r){let o=i[r];o.setValue(t,e[o.id],n)}}},uc=/(\w+)(\])?(\[|\.)?/g;function Du(s,t){s.seq.push(t),s.map[t.id]=t}function P_(s,t,e){let n=s.name,i=n.length;for(uc.lastIndex=0;;){let r=uc.exec(n),a=uc.lastIndex,o=r[1],l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){Du(e,c===void 0?new dc(o,s,t):new fc(o,s,t));break}else{let u=e.map[o];u===void 0&&(u=new pc(o),Du(e,u)),e=u}}}var es=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let r=t.getActiveUniform(e,i),a=t.getUniformLocation(e,r.name);P_(r,a,this)}}setValue(t,e,n,i){let r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){let o=e[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,r=t.length;i!==r;++i){let a=t[i];a.id in e&&n.push(a)}return n}};function Uu(s,t,e){let n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}var L_=37297,D_=0;function U_(s,t){let e=s.split(`
3717
+ `),n=[],i=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=i;a<r;a++){let o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3718
+ `)}var Nu=new Vt;function N_(s){Jt._getMatrix(Nu,Jt.workingColorSpace,s);let t=`mat3( ${Nu.elements.map(e=>e.toFixed(4))} )`;switch(Jt.getTransfer(s)){case vs:return[t,"LinearTransferOETF"];case ee:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[t,"LinearTransferOETF"]}}function Fu(s,t,e){let n=s.getShaderParameter(t,s.COMPILE_STATUS),i=s.getShaderInfoLog(t).trim();if(n&&i==="")return"";let r=/ERROR: 0:(\d+)/.exec(i);if(r){let a=parseInt(r[1]);return e.toUpperCase()+`
3719
+
3720
+ `+i+`
3721
+
3722
+ `+U_(s.getShaderSource(t),a)}else return i}function F_(s,t){let e=N_(t);return[`vec4 ${s}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3723
+ `)}function O_(s,t){let e;switch(t){case Gh:e="Linear";break;case Wh:e="Reinhard";break;case Xh:e="Cineon";break;case qh:e="ACESFilmic";break;case Zh:e="AgX";break;case Jh:e="Neutral";break;case Yh:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var ro=new C;function B_(){Jt.getLuminanceCoefficients(ro);let s=ro.x.toFixed(4),t=ro.y.toFixed(4),e=ro.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3724
+ `)}function z_(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ks).join(`
3725
+ `)}function k_(s){let t=[];for(let e in s){let n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3726
+ `)}function V_(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let r=s.getActiveAttrib(t,i),a=r.name,o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:s.getAttribLocation(t,a),locationSize:o}}return e}function Ks(s){return s!==""}function Ou(s,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Bu(s,t){return s.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var H_=/^[ \t]*#include +<([\w\d./]+)>/gm;function mc(s){return s.replace(H_,W_)}var G_=new Map;function W_(s,t){let e=Xt[t];if(e===void 0){let n=G_.get(t);if(n!==void 0)e=Xt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return mc(e)}var X_=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function zu(s){return s.replace(X_,q_)}function q_(s,t,e,n){let i="";for(let r=parseInt(t);r<parseInt(e);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function ku(s){let t=`precision ${s.precision} float;
3727
+ precision ${s.precision} int;
3728
+ precision ${s.precision} sampler2D;
3729
+ precision ${s.precision} samplerCube;
3730
+ precision ${s.precision} sampler3D;
3731
+ precision ${s.precision} sampler2DArray;
3732
+ precision ${s.precision} sampler2DShadow;
3733
+ precision ${s.precision} samplerCubeShadow;
3734
+ precision ${s.precision} sampler2DArrayShadow;
3735
+ precision ${s.precision} isampler2D;
3736
+ precision ${s.precision} isampler3D;
3737
+ precision ${s.precision} isamplerCube;
3738
+ precision ${s.precision} isampler2DArray;
3739
+ precision ${s.precision} usampler2D;
3740
+ precision ${s.precision} usampler3D;
3741
+ precision ${s.precision} usamplerCube;
3742
+ precision ${s.precision} usampler2DArray;
3743
+ `;return s.precision==="highp"?t+=`
3744
+ #define HIGH_PRECISION`:s.precision==="mediump"?t+=`
3745
+ #define MEDIUM_PRECISION`:s.precision==="lowp"&&(t+=`
3746
+ #define LOW_PRECISION`),t}function Y_(s){let t="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===zl?t="SHADOWMAP_TYPE_PCF":s.shadowMapType===Sh?t="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===fn&&(t="SHADOWMAP_TYPE_VSM"),t}function Z_(s){let t="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case mi:case gi:t="ENVMAP_TYPE_CUBE";break;case Gs:t="ENVMAP_TYPE_CUBE_UV";break}return t}function J_(s){let t="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case gi:t="ENVMAP_MODE_REFRACTION";break}return t}function $_(s){let t="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case ya:t="ENVMAP_BLENDING_MULTIPLY";break;case Vh:t="ENVMAP_BLENDING_MIX";break;case Hh:t="ENVMAP_BLENDING_ADD";break}return t}function K_(s){let t=s.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Q_(s,t,e,n){let i=s.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,l=Y_(e),c=Z_(e),h=J_(e),u=$_(e),d=K_(e),p=z_(e),g=k_(r),x=i.createProgram(),m,f,A=e.glslVersion?"#version "+e.glslVersion+`
3747
+ `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Ks).join(`
3748
+ `),m.length>0&&(m+=`
3749
+ `),f=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Ks).join(`
3750
+ `),f.length>0&&(f+=`
3751
+ `)):(m=[ku(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3752
+ `].filter(Ks).join(`
3753
+ `),f=[ku(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Pn?"#define TONE_MAPPING":"",e.toneMapping!==Pn?Xt.tonemapping_pars_fragment:"",e.toneMapping!==Pn?O_("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Xt.colorspace_pars_fragment,F_("linearToOutputTexel",e.outputColorSpace),B_(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3754
+ `].filter(Ks).join(`
3755
+ `)),a=mc(a),a=Ou(a,e),a=Bu(a,e),o=mc(o),o=Ou(o,e),o=Bu(o,e),a=zu(a),o=zu(o),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
3756
+ `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3757
+ `)+`
3758
+ `+m,f=["#define varying in",e.glslVersion===Ql?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ql?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3759
+ `)+`
3760
+ `+f);let M=A+m+a,v=A+f+o,I=Uu(i,i.VERTEX_SHADER,M),w=Uu(i,i.FRAGMENT_SHADER,v);i.attachShader(x,I),i.attachShader(x,w),e.index0AttributeName!==void 0?i.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x);function R(P){if(s.debug.checkShaderErrors){let Y=i.getProgramInfoLog(x).trim(),z=i.getShaderInfoLog(I).trim(),X=i.getShaderInfoLog(w).trim(),J=!0,G=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if(J=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,x,I,w);else{let tt=Fu(i,I,"vertex"),k=Fu(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+`
3761
+
3762
+ Material Name: `+P.name+`
3763
+ Material Type: `+P.type+`
3764
+
3765
+ Program Info Log: `+Y+`
3766
+ `+tt+`
3767
+ `+k)}else Y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Y):(z===""||X==="")&&(G=!1);G&&(P.diagnostics={runnable:J,programLog:Y,vertexShader:{log:z,prefix:m},fragmentShader:{log:X,prefix:f}})}i.deleteShader(I),i.deleteShader(w),D=new es(i,x),E=V_(i,x)}let D;this.getUniforms=function(){return D===void 0&&R(this),D};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let S=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=i.getProgramParameter(x,L_)),S},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=D_++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=I,this.fragmentShader=w,this}var j_=0,gc=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new _c(t),e.set(t,n)),n}},_c=class{constructor(t){this.id=j_++,this.code=t,this.usedTimes=0}};function tx(s,t,e,n,i,r,a){let o=new Hi,l=new gc,c=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures,p=i.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(E){return c.add(E),E===0?"uv":`uv${E}`}function m(E,S,P,Y,z){let X=Y.fog,J=z.geometry,G=E.isMeshStandardMaterial?Y.environment:null,tt=(E.isMeshStandardMaterial?e:t).get(E.envMap||G),k=tt&&tt.mapping===Gs?tt.image.height:null,lt=g[E.type];E.precision!==null&&(p=i.getMaxPrecision(E.precision),p!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",p,"instead."));let mt=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Mt=mt!==void 0?mt.length:0,kt=0;J.morphAttributes.position!==void 0&&(kt=1),J.morphAttributes.normal!==void 0&&(kt=2),J.morphAttributes.color!==void 0&&(kt=3);let Zt,W,st,wt;if(lt){let jt=mn[lt];Zt=jt.vertexShader,W=jt.fragmentShader}else Zt=E.vertexShader,W=E.fragmentShader,l.update(E),st=l.getVertexShaderID(E),wt=l.getFragmentShaderID(E);let pt=s.getRenderTarget(),Ct=s.state.buffers.depth.getReversed(),Ht=z.isInstancedMesh===!0,It=z.isBatchedMesh===!0,se=!!E.map,$t=!!E.matcap,Gt=!!tt,b=!!E.aoMap,rt=!!E.lightMap,Q=!!E.bumpMap,at=!!E.normalMap,q=!!E.displacementMap,gt=!!E.emissiveMap,et=!!E.metalnessMap,_t=!!E.roughnessMap,Bt=E.anisotropy>0,T=E.clearcoat>0,_=E.dispersion>0,F=E.iridescence>0,V=E.sheen>0,$=E.transmission>0,H=Bt&&!!E.anisotropyMap,Tt=T&&!!E.clearcoatMap,ct=T&&!!E.clearcoatNormalMap,St=T&&!!E.clearcoatRoughnessMap,At=F&&!!E.iridescenceMap,K=F&&!!E.iridescenceThicknessMap,xt=V&&!!E.sheenColorMap,Dt=V&&!!E.sheenRoughnessMap,Lt=!!E.specularMap,ht=!!E.specularColorMap,Ot=!!E.specularIntensityMap,L=$&&!!E.transmissionMap,dt=$&&!!E.thicknessMap,j=!!E.gradientMap,yt=!!E.alphaMap,nt=E.alphaTest>0,Z=!!E.alphaHash,bt=!!E.extensions,zt=Pn;E.toneMapped&&(pt===null||pt.isXRRenderTarget===!0)&&(zt=s.toneMapping);let re={shaderID:lt,shaderType:E.type,shaderName:E.name,vertexShader:Zt,fragmentShader:W,defines:E.defines,customVertexShaderID:st,customFragmentShaderID:wt,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:p,batching:It,batchingColor:It&&z._colorsTexture!==null,instancing:Ht,instancingColor:Ht&&z.instanceColor!==null,instancingMorph:Ht&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:pt===null?s.outputColorSpace:pt.isXRRenderTarget===!0?pt.texture.colorSpace:ai,alphaToCoverage:!!E.alphaToCoverage,map:se,matcap:$t,envMap:Gt,envMapMode:Gt&&tt.mapping,envMapCubeUVHeight:k,aoMap:b,lightMap:rt,bumpMap:Q,normalMap:at,displacementMap:d&&q,emissiveMap:gt,normalMapObjectSpace:at&&E.normalMapType===eu,normalMapTangentSpace:at&&E.normalMapType===no,metalnessMap:et,roughnessMap:_t,anisotropy:Bt,anisotropyMap:H,clearcoat:T,clearcoatMap:Tt,clearcoatNormalMap:ct,clearcoatRoughnessMap:St,dispersion:_,iridescence:F,iridescenceMap:At,iridescenceThicknessMap:K,sheen:V,sheenColorMap:xt,sheenRoughnessMap:Dt,specularMap:Lt,specularColorMap:ht,specularIntensityMap:Ot,transmission:$,transmissionMap:L,thicknessMap:dt,gradientMap:j,opaque:E.transparent===!1&&E.blending===si&&E.alphaToCoverage===!1,alphaMap:yt,alphaTest:nt,alphaHash:Z,combine:E.combine,mapUv:se&&x(E.map.channel),aoMapUv:b&&x(E.aoMap.channel),lightMapUv:rt&&x(E.lightMap.channel),bumpMapUv:Q&&x(E.bumpMap.channel),normalMapUv:at&&x(E.normalMap.channel),displacementMapUv:q&&x(E.displacementMap.channel),emissiveMapUv:gt&&x(E.emissiveMap.channel),metalnessMapUv:et&&x(E.metalnessMap.channel),roughnessMapUv:_t&&x(E.roughnessMap.channel),anisotropyMapUv:H&&x(E.anisotropyMap.channel),clearcoatMapUv:Tt&&x(E.clearcoatMap.channel),clearcoatNormalMapUv:ct&&x(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:St&&x(E.clearcoatRoughnessMap.channel),iridescenceMapUv:At&&x(E.iridescenceMap.channel),iridescenceThicknessMapUv:K&&x(E.iridescenceThicknessMap.channel),sheenColorMapUv:xt&&x(E.sheenColorMap.channel),sheenRoughnessMapUv:Dt&&x(E.sheenRoughnessMap.channel),specularMapUv:Lt&&x(E.specularMap.channel),specularColorMapUv:ht&&x(E.specularColorMap.channel),specularIntensityMapUv:Ot&&x(E.specularIntensityMap.channel),transmissionMapUv:L&&x(E.transmissionMap.channel),thicknessMapUv:dt&&x(E.thicknessMap.channel),alphaMapUv:yt&&x(E.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(at||Bt),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!J.attributes.uv&&(se||yt),fog:!!X,useFog:E.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:E.flatShading===!0&&E.wireframe===!1,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Ct,skinning:z.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Mt,morphTextureStride:kt,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:zt,decodeVideoTexture:se&&E.map.isVideoTexture===!0&&Jt.getTransfer(E.map.colorSpace)===ee,decodeVideoTextureEmissive:gt&&E.emissiveMap.isVideoTexture===!0&&Jt.getTransfer(E.emissiveMap.colorSpace)===ee,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===pn,flipSided:E.side===Ue,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:bt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(bt&&E.extensions.multiDraw===!0||It)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return re.vertexUv1s=c.has(1),re.vertexUv2s=c.has(2),re.vertexUv3s=c.has(3),c.clear(),re}function f(E){let S=[];if(E.shaderID?S.push(E.shaderID):(S.push(E.customVertexShaderID),S.push(E.customFragmentShaderID)),E.defines!==void 0)for(let P in E.defines)S.push(P),S.push(E.defines[P]);return E.isRawShaderMaterial===!1&&(A(S,E),M(S,E),S.push(s.outputColorSpace)),S.push(E.customProgramCacheKey),S.join()}function A(E,S){E.push(S.precision),E.push(S.outputColorSpace),E.push(S.envMapMode),E.push(S.envMapCubeUVHeight),E.push(S.mapUv),E.push(S.alphaMapUv),E.push(S.lightMapUv),E.push(S.aoMapUv),E.push(S.bumpMapUv),E.push(S.normalMapUv),E.push(S.displacementMapUv),E.push(S.emissiveMapUv),E.push(S.metalnessMapUv),E.push(S.roughnessMapUv),E.push(S.anisotropyMapUv),E.push(S.clearcoatMapUv),E.push(S.clearcoatNormalMapUv),E.push(S.clearcoatRoughnessMapUv),E.push(S.iridescenceMapUv),E.push(S.iridescenceThicknessMapUv),E.push(S.sheenColorMapUv),E.push(S.sheenRoughnessMapUv),E.push(S.specularMapUv),E.push(S.specularColorMapUv),E.push(S.specularIntensityMapUv),E.push(S.transmissionMapUv),E.push(S.thicknessMapUv),E.push(S.combine),E.push(S.fogExp2),E.push(S.sizeAttenuation),E.push(S.morphTargetsCount),E.push(S.morphAttributeCount),E.push(S.numDirLights),E.push(S.numPointLights),E.push(S.numSpotLights),E.push(S.numSpotLightMaps),E.push(S.numHemiLights),E.push(S.numRectAreaLights),E.push(S.numDirLightShadows),E.push(S.numPointLightShadows),E.push(S.numSpotLightShadows),E.push(S.numSpotLightShadowsWithMaps),E.push(S.numLightProbes),E.push(S.shadowMapType),E.push(S.toneMapping),E.push(S.numClippingPlanes),E.push(S.numClipIntersection),E.push(S.depthPacking)}function M(E,S){o.disableAll(),S.supportsVertexTextures&&o.enable(0),S.instancing&&o.enable(1),S.instancingColor&&o.enable(2),S.instancingMorph&&o.enable(3),S.matcap&&o.enable(4),S.envMap&&o.enable(5),S.normalMapObjectSpace&&o.enable(6),S.normalMapTangentSpace&&o.enable(7),S.clearcoat&&o.enable(8),S.iridescence&&o.enable(9),S.alphaTest&&o.enable(10),S.vertexColors&&o.enable(11),S.vertexAlphas&&o.enable(12),S.vertexUv1s&&o.enable(13),S.vertexUv2s&&o.enable(14),S.vertexUv3s&&o.enable(15),S.vertexTangents&&o.enable(16),S.anisotropy&&o.enable(17),S.alphaHash&&o.enable(18),S.batching&&o.enable(19),S.dispersion&&o.enable(20),S.batchingColor&&o.enable(21),S.gradientMap&&o.enable(22),E.push(o.mask),o.disableAll(),S.fog&&o.enable(0),S.useFog&&o.enable(1),S.flatShading&&o.enable(2),S.logarithmicDepthBuffer&&o.enable(3),S.reverseDepthBuffer&&o.enable(4),S.skinning&&o.enable(5),S.morphTargets&&o.enable(6),S.morphNormals&&o.enable(7),S.morphColors&&o.enable(8),S.premultipliedAlpha&&o.enable(9),S.shadowMapEnabled&&o.enable(10),S.doubleSided&&o.enable(11),S.flipSided&&o.enable(12),S.useDepthPacking&&o.enable(13),S.dithering&&o.enable(14),S.transmission&&o.enable(15),S.sheen&&o.enable(16),S.opaque&&o.enable(17),S.pointsUvs&&o.enable(18),S.decodeVideoTexture&&o.enable(19),S.decodeVideoTextureEmissive&&o.enable(20),S.alphaToCoverage&&o.enable(21),E.push(o.mask)}function v(E){let S=g[E.type],P;if(S){let Y=mn[S];P=pu.clone(Y.uniforms)}else P=E.uniforms;return P}function I(E,S){let P;for(let Y=0,z=h.length;Y<z;Y++){let X=h[Y];if(X.cacheKey===S){P=X,++P.usedTimes;break}}return P===void 0&&(P=new Q_(s,S,E,r),h.push(P)),P}function w(E){if(--E.usedTimes===0){let S=h.indexOf(E);h[S]=h[h.length-1],h.pop(),E.destroy()}}function R(E){l.remove(E)}function D(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:v,acquireProgram:I,releaseProgram:w,releaseShaderCache:R,programs:h,dispose:D}}function ex(){let s=new WeakMap;function t(a){return s.has(a)}function e(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function nx(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.z!==t.z?s.z-t.z:s.id-t.id}function Vu(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function Hu(){let s=[],t=0,e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function a(u,d,p,g,x,m){let f=s[t];return f===void 0?(f={id:u.id,object:u,geometry:d,material:p,groupOrder:g,renderOrder:u.renderOrder,z:x,group:m},s[t]=f):(f.id=u.id,f.object=u,f.geometry=d,f.material=p,f.groupOrder=g,f.renderOrder=u.renderOrder,f.z=x,f.group=m),t++,f}function o(u,d,p,g,x,m){let f=a(u,d,p,g,x,m);p.transmission>0?n.push(f):p.transparent===!0?i.push(f):e.push(f)}function l(u,d,p,g,x,m){let f=a(u,d,p,g,x,m);p.transmission>0?n.unshift(f):p.transparent===!0?i.unshift(f):e.unshift(f)}function c(u,d){e.length>1&&e.sort(u||nx),n.length>1&&n.sort(d||Vu),i.length>1&&i.sort(d||Vu)}function h(){for(let u=t,d=s.length;u<d;u++){let p=s[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:i,init:r,push:o,unshift:l,finish:h,sort:c}}function ix(){let s=new WeakMap;function t(n,i){let r=s.get(n),a;return r===void 0?(a=new Hu,s.set(n,[a])):i>=r.length?(a=new Hu,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function sx(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new C,color:new Ut};break;case"SpotLight":e={position:new C,direction:new C,color:new Ut,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new Ut,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new Ut,groundColor:new Ut};break;case"RectAreaLight":e={color:new Ut,position:new C,halfWidth:new C,halfHeight:new C};break}return s[t.id]=e,e}}}function rx(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ot,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var ax=0;function ox(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function lx(s){let t=new sx,e=rx(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);let i=new C,r=new Wt,a=new Wt;function o(c){let h=0,u=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let p=0,g=0,x=0,m=0,f=0,A=0,M=0,v=0,I=0,w=0,R=0;c.sort(ox);for(let E=0,S=c.length;E<S;E++){let P=c[E],Y=P.color,z=P.intensity,X=P.distance,J=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=Y.r*z,u+=Y.g*z,d+=Y.b*z;else if(P.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(P.sh.coefficients[G],z);R++}else if(P.isDirectionalLight){let G=t.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let tt=P.shadow,k=e.get(P);k.shadowIntensity=tt.intensity,k.shadowBias=tt.bias,k.shadowNormalBias=tt.normalBias,k.shadowRadius=tt.radius,k.shadowMapSize=tt.mapSize,n.directionalShadow[p]=k,n.directionalShadowMap[p]=J,n.directionalShadowMatrix[p]=P.shadow.matrix,A++}n.directional[p]=G,p++}else if(P.isSpotLight){let G=t.get(P);G.position.setFromMatrixPosition(P.matrixWorld),G.color.copy(Y).multiplyScalar(z),G.distance=X,G.coneCos=Math.cos(P.angle),G.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),G.decay=P.decay,n.spot[x]=G;let tt=P.shadow;if(P.map&&(n.spotLightMap[I]=P.map,I++,tt.updateMatrices(P),P.castShadow&&w++),n.spotLightMatrix[x]=tt.matrix,P.castShadow){let k=e.get(P);k.shadowIntensity=tt.intensity,k.shadowBias=tt.bias,k.shadowNormalBias=tt.normalBias,k.shadowRadius=tt.radius,k.shadowMapSize=tt.mapSize,n.spotShadow[x]=k,n.spotShadowMap[x]=J,v++}x++}else if(P.isRectAreaLight){let G=t.get(P);G.color.copy(Y).multiplyScalar(z),G.halfWidth.set(P.width*.5,0,0),G.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=G,m++}else if(P.isPointLight){let G=t.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),G.distance=P.distance,G.decay=P.decay,P.castShadow){let tt=P.shadow,k=e.get(P);k.shadowIntensity=tt.intensity,k.shadowBias=tt.bias,k.shadowNormalBias=tt.normalBias,k.shadowRadius=tt.radius,k.shadowMapSize=tt.mapSize,k.shadowCameraNear=tt.camera.near,k.shadowCameraFar=tt.camera.far,n.pointShadow[g]=k,n.pointShadowMap[g]=J,n.pointShadowMatrix[g]=P.shadow.matrix,M++}n.point[g]=G,g++}else if(P.isHemisphereLight){let G=t.get(P);G.skyColor.copy(P.color).multiplyScalar(z),G.groundColor.copy(P.groundColor).multiplyScalar(z),n.hemi[f]=G,f++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ut.LTC_FLOAT_1,n.rectAreaLTC2=ut.LTC_FLOAT_2):(n.rectAreaLTC1=ut.LTC_HALF_1,n.rectAreaLTC2=ut.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;let D=n.hash;(D.directionalLength!==p||D.pointLength!==g||D.spotLength!==x||D.rectAreaLength!==m||D.hemiLength!==f||D.numDirectionalShadows!==A||D.numPointShadows!==M||D.numSpotShadows!==v||D.numSpotMaps!==I||D.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=x,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=M,n.pointShadowMap.length=M,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=M,n.spotLightMatrix.length=v+I-w,n.spotLightMap.length=I,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,D.directionalLength=p,D.pointLength=g,D.spotLength=x,D.rectAreaLength=m,D.hemiLength=f,D.numDirectionalShadows=A,D.numPointShadows=M,D.numSpotShadows=v,D.numSpotMaps=I,D.numLightProbes=R,n.version=ax++)}function l(c,h){let u=0,d=0,p=0,g=0,x=0,m=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;f++){let M=c[f];if(M.isDirectionalLight){let v=n.directional[u];v.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(i),v.direction.transformDirection(m),u++}else if(M.isSpotLight){let v=n.spot[p];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),v.direction.setFromMatrixPosition(M.matrixWorld),i.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(i),v.direction.transformDirection(m),p++}else if(M.isRectAreaLight){let v=n.rectArea[g];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),a.identity(),r.copy(M.matrixWorld),r.premultiply(m),a.extractRotation(r),v.halfWidth.set(M.width*.5,0,0),v.halfHeight.set(0,M.height*.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),g++}else if(M.isPointLight){let v=n.point[d];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),d++}else if(M.isHemisphereLight){let v=n.hemi[x];v.direction.setFromMatrixPosition(M.matrixWorld),v.direction.transformDirection(m),x++}}}return{setup:o,setupView:l,state:n}}function Gu(s){let t=new lx(s),e=[],n=[];function i(h){c.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}let c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:r,pushShadow:a}}function cx(s){let t=new WeakMap;function e(i,r=0){let a=t.get(i),o;return a===void 0?(o=new Gu(s),t.set(i,[o])):r>=a.length?(o=new Gu(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var hx=`void main() {
3768
+ gl_Position = vec4( position, 1.0 );
3769
+ }`,ux=`uniform sampler2D shadow_pass;
3770
+ uniform vec2 resolution;
3771
+ uniform float radius;
3772
+ #include <packing>
3773
+ void main() {
3774
+ const float samples = float( VSM_SAMPLES );
3775
+ float mean = 0.0;
3776
+ float squared_mean = 0.0;
3777
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3778
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3779
+ for ( float i = 0.0; i < samples; i ++ ) {
3780
+ float uvOffset = uvStart + i * uvStride;
3781
+ #ifdef HORIZONTAL_PASS
3782
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3783
+ mean += distribution.x;
3784
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3785
+ #else
3786
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3787
+ mean += depth;
3788
+ squared_mean += depth * depth;
3789
+ #endif
3790
+ }
3791
+ mean = mean / samples;
3792
+ squared_mean = squared_mean / samples;
3793
+ float std_dev = sqrt( squared_mean - mean * mean );
3794
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3795
+ }`;function dx(s,t,e){let n=new Wn,i=new ot,r=new ot,a=new Qt,o=new sa({depthPacking:tu}),l=new ra,c={},h=e.maxTextureSize,u={[Tn]:Ue,[Ue]:Tn,[pn]:pn},d=new an({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ot},radius:{value:4}},vertexShader:hx,fragmentShader:ux}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let g=new _e;g.setAttribute("position",new Me(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new be(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zl;let f=this.type;this.render=function(w,R,D){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let E=s.getRenderTarget(),S=s.getActiveCubeFace(),P=s.getActiveMipmapLevel(),Y=s.state;Y.setBlending(In),Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);let z=f!==fn&&this.type===fn,X=f===fn&&this.type!==fn;for(let J=0,G=w.length;J<G;J++){let tt=w[J],k=tt.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",tt,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;i.copy(k.mapSize);let lt=k.getFrameExtents();if(i.multiply(lt),r.copy(k.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/lt.x),i.x=r.x*lt.x,k.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/lt.y),i.y=r.y*lt.y,k.mapSize.y=r.y)),k.map===null||z===!0||X===!0){let Mt=this.type!==fn?{minFilter:Oe,magFilter:Oe}:{};k.map!==null&&k.map.dispose(),k.map=new dn(i.x,i.y,Mt),k.map.texture.name=tt.name+".shadowMap",k.camera.updateProjectionMatrix()}s.setRenderTarget(k.map),s.clear();let mt=k.getViewportCount();for(let Mt=0;Mt<mt;Mt++){let kt=k.getViewport(Mt);a.set(r.x*kt.x,r.y*kt.y,r.x*kt.z,r.y*kt.w),Y.viewport(a),k.updateMatrices(tt,Mt),n=k.getFrustum(),v(R,D,k.camera,tt,this.type)}k.isPointLightShadow!==!0&&this.type===fn&&A(k,D),k.needsUpdate=!1}f=this.type,m.needsUpdate=!1,s.setRenderTarget(E,S,P)};function A(w,R){let D=t.update(x);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new dn(i.x,i.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,D,d,x,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,D,p,x,null)}function M(w,R,D,E){let S=null,P=D.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)S=P;else if(S=D.isPointLight===!0?l:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let Y=S.uuid,z=R.uuid,X=c[Y];X===void 0&&(X={},c[Y]=X);let J=X[z];J===void 0&&(J=S.clone(),X[z]=J,R.addEventListener("dispose",I)),S=J}if(S.visible=R.visible,S.wireframe=R.wireframe,E===fn?S.side=R.shadowSide!==null?R.shadowSide:R.side:S.side=R.shadowSide!==null?R.shadowSide:u[R.side],S.alphaMap=R.alphaMap,S.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,S.map=R.map,S.clipShadows=R.clipShadows,S.clippingPlanes=R.clippingPlanes,S.clipIntersection=R.clipIntersection,S.displacementMap=R.displacementMap,S.displacementScale=R.displacementScale,S.displacementBias=R.displacementBias,S.wireframeLinewidth=R.wireframeLinewidth,S.linewidth=R.linewidth,D.isPointLight===!0&&S.isMeshDistanceMaterial===!0){let Y=s.properties.get(S);Y.light=D}return S}function v(w,R,D,E,S){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&S===fn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,w.matrixWorld);let z=t.update(w),X=w.material;if(Array.isArray(X)){let J=z.groups;for(let G=0,tt=J.length;G<tt;G++){let k=J[G],lt=X[k.materialIndex];if(lt&&lt.visible){let mt=M(w,lt,E,S);w.onBeforeShadow(s,w,R,D,z,mt,k),s.renderBufferDirect(D,null,z,mt,w,k),w.onAfterShadow(s,w,R,D,z,mt,k)}}}else if(X.visible){let J=M(w,X,E,S);w.onBeforeShadow(s,w,R,D,z,J,null),s.renderBufferDirect(D,null,z,J,w,null),w.onAfterShadow(s,w,R,D,z,J,null)}}let Y=w.children;for(let z=0,X=Y.length;z<X;z++)v(Y[z],R,D,E,S)}function I(w){w.target.removeEventListener("dispose",I);for(let D in c){let E=c[D],S=w.target.uuid;S in E&&(E[S].dispose(),delete E[S])}}}var fx={[fa]:pa,[ma]:xa,[ga]:va,[ri]:_a,[pa]:fa,[xa]:ma,[va]:ga,[_a]:ri};function px(s,t){function e(){let L=!1,dt=new Qt,j=null,yt=new Qt(0,0,0,0);return{setMask:function(nt){j!==nt&&!L&&(s.colorMask(nt,nt,nt,nt),j=nt)},setLocked:function(nt){L=nt},setClear:function(nt,Z,bt,zt,re){re===!0&&(nt*=zt,Z*=zt,bt*=zt),dt.set(nt,Z,bt,zt),yt.equals(dt)===!1&&(s.clearColor(nt,Z,bt,zt),yt.copy(dt))},reset:function(){L=!1,j=null,yt.set(-1,0,0,0)}}}function n(){let L=!1,dt=!1,j=null,yt=null,nt=null;return{setReversed:function(Z){if(dt!==Z){let bt=t.get("EXT_clip_control");Z?bt.clipControlEXT(bt.LOWER_LEFT_EXT,bt.ZERO_TO_ONE_EXT):bt.clipControlEXT(bt.LOWER_LEFT_EXT,bt.NEGATIVE_ONE_TO_ONE_EXT),dt=Z;let zt=nt;nt=null,this.setClear(zt)}},getReversed:function(){return dt},setTest:function(Z){Z?pt(s.DEPTH_TEST):Ct(s.DEPTH_TEST)},setMask:function(Z){j!==Z&&!L&&(s.depthMask(Z),j=Z)},setFunc:function(Z){if(dt&&(Z=fx[Z]),yt!==Z){switch(Z){case fa:s.depthFunc(s.NEVER);break;case pa:s.depthFunc(s.ALWAYS);break;case ma:s.depthFunc(s.LESS);break;case ri:s.depthFunc(s.LEQUAL);break;case ga:s.depthFunc(s.EQUAL);break;case _a:s.depthFunc(s.GEQUAL);break;case xa:s.depthFunc(s.GREATER);break;case va:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}yt=Z}},setLocked:function(Z){L=Z},setClear:function(Z){nt!==Z&&(dt&&(Z=1-Z),s.clearDepth(Z),nt=Z)},reset:function(){L=!1,j=null,yt=null,nt=null,dt=!1}}}function i(){let L=!1,dt=null,j=null,yt=null,nt=null,Z=null,bt=null,zt=null,re=null;return{setTest:function(jt){L||(jt?pt(s.STENCIL_TEST):Ct(s.STENCIL_TEST))},setMask:function(jt){dt!==jt&&!L&&(s.stencilMask(jt),dt=jt)},setFunc:function(jt,Qe,gn){(j!==jt||yt!==Qe||nt!==gn)&&(s.stencilFunc(jt,Qe,gn),j=jt,yt=Qe,nt=gn)},setOp:function(jt,Qe,gn){(Z!==jt||bt!==Qe||zt!==gn)&&(s.stencilOp(jt,Qe,gn),Z=jt,bt=Qe,zt=gn)},setLocked:function(jt){L=jt},setClear:function(jt){re!==jt&&(s.clearStencil(jt),re=jt)},reset:function(){L=!1,dt=null,j=null,yt=null,nt=null,Z=null,bt=null,zt=null,re=null}}}let r=new e,a=new n,o=new i,l=new WeakMap,c=new WeakMap,h={},u={},d=new WeakMap,p=[],g=null,x=!1,m=null,f=null,A=null,M=null,v=null,I=null,w=null,R=new Ut(0,0,0),D=0,E=!1,S=null,P=null,Y=null,z=null,X=null,J=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),G=!1,tt=0,k=s.getParameter(s.VERSION);k.indexOf("WebGL")!==-1?(tt=parseFloat(/^WebGL (\d)/.exec(k)[1]),G=tt>=1):k.indexOf("OpenGL ES")!==-1&&(tt=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),G=tt>=2);let lt=null,mt={},Mt=s.getParameter(s.SCISSOR_BOX),kt=s.getParameter(s.VIEWPORT),Zt=new Qt().fromArray(Mt),W=new Qt().fromArray(kt);function st(L,dt,j,yt){let nt=new Uint8Array(4),Z=s.createTexture();s.bindTexture(L,Z),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let bt=0;bt<j;bt++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(dt,0,s.RGBA,1,1,yt,0,s.RGBA,s.UNSIGNED_BYTE,nt):s.texImage2D(dt+bt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,nt);return Z}let wt={};wt[s.TEXTURE_2D]=st(s.TEXTURE_2D,s.TEXTURE_2D,1),wt[s.TEXTURE_CUBE_MAP]=st(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),wt[s.TEXTURE_2D_ARRAY]=st(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),wt[s.TEXTURE_3D]=st(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),pt(s.DEPTH_TEST),a.setFunc(ri),Q(!1),at(Bl),pt(s.CULL_FACE),b(In);function pt(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function Ct(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Ht(L,dt){return u[L]!==dt?(s.bindFramebuffer(L,dt),u[L]=dt,L===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=dt),L===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=dt),!0):!1}function It(L,dt){let j=p,yt=!1;if(L){j=d.get(dt),j===void 0&&(j=[],d.set(dt,j));let nt=L.textures;if(j.length!==nt.length||j[0]!==s.COLOR_ATTACHMENT0){for(let Z=0,bt=nt.length;Z<bt;Z++)j[Z]=s.COLOR_ATTACHMENT0+Z;j.length=nt.length,yt=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,yt=!0);yt&&s.drawBuffers(j)}function se(L){return g!==L?(s.useProgram(L),g=L,!0):!1}let $t={[Hn]:s.FUNC_ADD,[Eh]:s.FUNC_SUBTRACT,[Th]:s.FUNC_REVERSE_SUBTRACT};$t[Ah]=s.MIN,$t[wh]=s.MAX;let Gt={[Ch]:s.ZERO,[Rh]:s.ONE,[Ih]:s.SRC_COLOR,[Ur]:s.SRC_ALPHA,[Fh]:s.SRC_ALPHA_SATURATE,[Uh]:s.DST_COLOR,[Lh]:s.DST_ALPHA,[Ph]:s.ONE_MINUS_SRC_COLOR,[Nr]:s.ONE_MINUS_SRC_ALPHA,[Nh]:s.ONE_MINUS_DST_COLOR,[Dh]:s.ONE_MINUS_DST_ALPHA,[Oh]:s.CONSTANT_COLOR,[Bh]:s.ONE_MINUS_CONSTANT_COLOR,[zh]:s.CONSTANT_ALPHA,[kh]:s.ONE_MINUS_CONSTANT_ALPHA};function b(L,dt,j,yt,nt,Z,bt,zt,re,jt){if(L===In){x===!0&&(Ct(s.BLEND),x=!1);return}if(x===!1&&(pt(s.BLEND),x=!0),L!==bh){if(L!==m||jt!==E){if((f!==Hn||v!==Hn)&&(s.blendEquation(s.FUNC_ADD),f=Hn,v=Hn),jt)switch(L){case si:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case kl:s.blendFunc(s.ONE,s.ONE);break;case Vl:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Hl:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}else switch(L){case si:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case kl:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Vl:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Hl:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}A=null,M=null,I=null,w=null,R.set(0,0,0),D=0,m=L,E=jt}return}nt=nt||dt,Z=Z||j,bt=bt||yt,(dt!==f||nt!==v)&&(s.blendEquationSeparate($t[dt],$t[nt]),f=dt,v=nt),(j!==A||yt!==M||Z!==I||bt!==w)&&(s.blendFuncSeparate(Gt[j],Gt[yt],Gt[Z],Gt[bt]),A=j,M=yt,I=Z,w=bt),(zt.equals(R)===!1||re!==D)&&(s.blendColor(zt.r,zt.g,zt.b,re),R.copy(zt),D=re),m=L,E=!1}function rt(L,dt){L.side===pn?Ct(s.CULL_FACE):pt(s.CULL_FACE);let j=L.side===Ue;dt&&(j=!j),Q(j),L.blending===si&&L.transparent===!1?b(In):b(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);let yt=L.stencilWrite;o.setTest(yt),yt&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),gt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?pt(s.SAMPLE_ALPHA_TO_COVERAGE):Ct(s.SAMPLE_ALPHA_TO_COVERAGE)}function Q(L){S!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),S=L)}function at(L){L!==yh?(pt(s.CULL_FACE),L!==P&&(L===Bl?s.cullFace(s.BACK):L===Mh?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Ct(s.CULL_FACE),P=L}function q(L){L!==Y&&(G&&s.lineWidth(L),Y=L)}function gt(L,dt,j){L?(pt(s.POLYGON_OFFSET_FILL),(z!==dt||X!==j)&&(s.polygonOffset(dt,j),z=dt,X=j)):Ct(s.POLYGON_OFFSET_FILL)}function et(L){L?pt(s.SCISSOR_TEST):Ct(s.SCISSOR_TEST)}function _t(L){L===void 0&&(L=s.TEXTURE0+J-1),lt!==L&&(s.activeTexture(L),lt=L)}function Bt(L,dt,j){j===void 0&&(lt===null?j=s.TEXTURE0+J-1:j=lt);let yt=mt[j];yt===void 0&&(yt={type:void 0,texture:void 0},mt[j]=yt),(yt.type!==L||yt.texture!==dt)&&(lt!==j&&(s.activeTexture(j),lt=j),s.bindTexture(L,dt||wt[L]),yt.type=L,yt.texture=dt)}function T(){let L=mt[lt];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function _(){try{s.compressedTexImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function F(){try{s.compressedTexImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function V(){try{s.texSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function $(){try{s.texSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function H(){try{s.compressedTexSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function Tt(){try{s.compressedTexSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ct(){try{s.texStorage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function St(){try{s.texStorage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function At(){try{s.texImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function K(){try{s.texImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function xt(L){Zt.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),Zt.copy(L))}function Dt(L){W.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),W.copy(L))}function Lt(L,dt){let j=c.get(dt);j===void 0&&(j=new WeakMap,c.set(dt,j));let yt=j.get(L);yt===void 0&&(yt=s.getUniformBlockIndex(dt,L.name),j.set(L,yt))}function ht(L,dt){let yt=c.get(dt).get(L);l.get(dt)!==yt&&(s.uniformBlockBinding(dt,yt,L.__bindingPointIndex),l.set(dt,yt))}function Ot(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),h={},lt=null,mt={},u={},d=new WeakMap,p=[],g=null,x=!1,m=null,f=null,A=null,M=null,v=null,I=null,w=null,R=new Ut(0,0,0),D=0,E=!1,S=null,P=null,Y=null,z=null,X=null,Zt.set(0,0,s.canvas.width,s.canvas.height),W.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:pt,disable:Ct,bindFramebuffer:Ht,drawBuffers:It,useProgram:se,setBlending:b,setMaterial:rt,setFlipSided:Q,setCullFace:at,setLineWidth:q,setPolygonOffset:gt,setScissorTest:et,activeTexture:_t,bindTexture:Bt,unbindTexture:T,compressedTexImage2D:_,compressedTexImage3D:F,texImage2D:At,texImage3D:K,updateUBOMapping:Lt,uniformBlockBinding:ht,texStorage2D:ct,texStorage3D:St,texSubImage2D:V,texSubImage3D:$,compressedTexSubImage2D:H,compressedTexSubImage3D:Tt,scissor:xt,viewport:Dt,reset:Ot}}function mx(s,t,e,n,i,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ot,h=new WeakMap,u,d=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(T,_){return p?new OffscreenCanvas(T,_):ki("canvas")}function x(T,_,F){let V=1,$=Bt(T);if(($.width>F||$.height>F)&&(V=F/Math.max($.width,$.height)),V<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){let H=Math.floor(V*$.width),Tt=Math.floor(V*$.height);u===void 0&&(u=g(H,Tt));let ct=_?g(H,Tt):u;return ct.width=H,ct.height=Tt,ct.getContext("2d").drawImage(T,0,0,H,Tt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+H+"x"+Tt+")."),ct}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function m(T){return T.generateMipmaps}function f(T){s.generateMipmap(T)}function A(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function M(T,_,F,V,$=!1){if(T!==null){if(s[T]!==void 0)return s[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let H=_;if(_===s.RED&&(F===s.FLOAT&&(H=s.R32F),F===s.HALF_FLOAT&&(H=s.R16F),F===s.UNSIGNED_BYTE&&(H=s.R8)),_===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(H=s.R8UI),F===s.UNSIGNED_SHORT&&(H=s.R16UI),F===s.UNSIGNED_INT&&(H=s.R32UI),F===s.BYTE&&(H=s.R8I),F===s.SHORT&&(H=s.R16I),F===s.INT&&(H=s.R32I)),_===s.RG&&(F===s.FLOAT&&(H=s.RG32F),F===s.HALF_FLOAT&&(H=s.RG16F),F===s.UNSIGNED_BYTE&&(H=s.RG8)),_===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(H=s.RG8UI),F===s.UNSIGNED_SHORT&&(H=s.RG16UI),F===s.UNSIGNED_INT&&(H=s.RG32UI),F===s.BYTE&&(H=s.RG8I),F===s.SHORT&&(H=s.RG16I),F===s.INT&&(H=s.RG32I)),_===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(H=s.RGB8UI),F===s.UNSIGNED_SHORT&&(H=s.RGB16UI),F===s.UNSIGNED_INT&&(H=s.RGB32UI),F===s.BYTE&&(H=s.RGB8I),F===s.SHORT&&(H=s.RGB16I),F===s.INT&&(H=s.RGB32I)),_===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(H=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(H=s.RGBA16UI),F===s.UNSIGNED_INT&&(H=s.RGBA32UI),F===s.BYTE&&(H=s.RGBA8I),F===s.SHORT&&(H=s.RGBA16I),F===s.INT&&(H=s.RGBA32I)),_===s.RGB&&F===s.UNSIGNED_INT_5_9_9_9_REV&&(H=s.RGB9_E5),_===s.RGBA){let Tt=$?vs:Jt.getTransfer(V);F===s.FLOAT&&(H=s.RGBA32F),F===s.HALF_FLOAT&&(H=s.RGBA16F),F===s.UNSIGNED_BYTE&&(H=Tt===ee?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT_4_4_4_4&&(H=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(H=s.RGB5_A1)}return(H===s.R16F||H===s.R32F||H===s.RG16F||H===s.RG32F||H===s.RGBA16F||H===s.RGBA32F)&&t.get("EXT_color_buffer_float"),H}function v(T,_){let F;return T?_===null||_===Ln||_===Ki?F=s.DEPTH24_STENCIL8:_===Be?F=s.DEPTH32F_STENCIL8:_===Ji&&(F=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Ln||_===Ki?F=s.DEPTH_COMPONENT24:_===Be?F=s.DEPTH_COMPONENT32F:_===Ji&&(F=s.DEPTH_COMPONENT16),F}function I(T,_){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==Oe&&T.minFilter!==sn?Math.log2(Math.max(_.width,_.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?_.mipmaps.length:1}function w(T){let _=T.target;_.removeEventListener("dispose",w),D(_),_.isVideoTexture&&h.delete(_)}function R(T){let _=T.target;_.removeEventListener("dispose",R),S(_)}function D(T){let _=n.get(T);if(_.__webglInit===void 0)return;let F=T.source,V=d.get(F);if(V){let $=V[_.__cacheKey];$.usedTimes--,$.usedTimes===0&&E(T),Object.keys(V).length===0&&d.delete(F)}n.remove(T)}function E(T){let _=n.get(T);s.deleteTexture(_.__webglTexture);let F=T.source,V=d.get(F);delete V[_.__cacheKey],a.memory.textures--}function S(T){let _=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(_.__webglFramebuffer[V]))for(let $=0;$<_.__webglFramebuffer[V].length;$++)s.deleteFramebuffer(_.__webglFramebuffer[V][$]);else s.deleteFramebuffer(_.__webglFramebuffer[V]);_.__webglDepthbuffer&&s.deleteRenderbuffer(_.__webglDepthbuffer[V])}else{if(Array.isArray(_.__webglFramebuffer))for(let V=0;V<_.__webglFramebuffer.length;V++)s.deleteFramebuffer(_.__webglFramebuffer[V]);else s.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&s.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&s.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let V=0;V<_.__webglColorRenderbuffer.length;V++)_.__webglColorRenderbuffer[V]&&s.deleteRenderbuffer(_.__webglColorRenderbuffer[V]);_.__webglDepthRenderbuffer&&s.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let F=T.textures;for(let V=0,$=F.length;V<$;V++){let H=n.get(F[V]);H.__webglTexture&&(s.deleteTexture(H.__webglTexture),a.memory.textures--),n.remove(F[V])}n.remove(T)}let P=0;function Y(){P=0}function z(){let T=P;return T>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),P+=1,T}function X(T){let _=[];return _.push(T.wrapS),_.push(T.wrapT),_.push(T.wrapR||0),_.push(T.magFilter),_.push(T.minFilter),_.push(T.anisotropy),_.push(T.internalFormat),_.push(T.format),_.push(T.type),_.push(T.generateMipmaps),_.push(T.premultiplyAlpha),_.push(T.flipY),_.push(T.unpackAlignment),_.push(T.colorSpace),_.join()}function J(T,_){let F=n.get(T);if(T.isVideoTexture&&et(T),T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){let V=T.image;if(V===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{wt(F,T,_);return}}e.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+_)}function G(T,_){let F=n.get(T);if(T.version>0&&F.__version!==T.version){wt(F,T,_);return}e.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+_)}function tt(T,_){let F=n.get(T);if(T.version>0&&F.__version!==T.version){wt(F,T,_);return}e.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+_)}function k(T,_){let F=n.get(T);if(T.version>0&&F.__version!==T.version){pt(F,T,_);return}e.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+_)}let lt={[Fr]:s.REPEAT,[kn]:s.CLAMP_TO_EDGE,[Or]:s.MIRRORED_REPEAT},mt={[Oe]:s.NEAREST,[Kh]:s.NEAREST_MIPMAP_NEAREST,[Ws]:s.NEAREST_MIPMAP_LINEAR,[sn]:s.LINEAR,[ba]:s.LINEAR_MIPMAP_NEAREST,[qn]:s.LINEAR_MIPMAP_LINEAR},Mt={[nu]:s.NEVER,[lu]:s.ALWAYS,[iu]:s.LESS,[Kl]:s.LEQUAL,[su]:s.EQUAL,[ou]:s.GEQUAL,[ru]:s.GREATER,[au]:s.NOTEQUAL};function kt(T,_){if(_.type===Be&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===sn||_.magFilter===ba||_.magFilter===Ws||_.magFilter===qn||_.minFilter===sn||_.minFilter===ba||_.minFilter===Ws||_.minFilter===qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,lt[_.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,lt[_.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,lt[_.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,mt[_.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,mt[_.minFilter]),_.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,Mt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Oe||_.minFilter!==Ws&&_.minFilter!==qn||_.type===Be&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");s.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,i.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Zt(T,_){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",w));let V=_.source,$=d.get(V);$===void 0&&($={},d.set(V,$));let H=X(_);if(H!==T.__cacheKey){$[H]===void 0&&($[H]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),$[H].usedTimes++;let Tt=$[T.__cacheKey];Tt!==void 0&&($[T.__cacheKey].usedTimes--,Tt.usedTimes===0&&E(_)),T.__cacheKey=H,T.__webglTexture=$[H].texture}return F}function W(T,_,F){return Math.floor(Math.floor(T/F)/_)}function st(T,_,F,V){let H=T.updateRanges;if(H.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,_.width,_.height,F,V,_.data);else{H.sort((K,xt)=>K.start-xt.start);let Tt=0;for(let K=1;K<H.length;K++){let xt=H[Tt],Dt=H[K],Lt=xt.start+xt.count,ht=W(Dt.start,_.width,4),Ot=W(xt.start,_.width,4);Dt.start<=Lt+1&&ht===Ot&&W(Dt.start+Dt.count-1,_.width,4)===ht?xt.count=Math.max(xt.count,Dt.start+Dt.count-xt.start):(++Tt,H[Tt]=Dt)}H.length=Tt+1;let ct=s.getParameter(s.UNPACK_ROW_LENGTH),St=s.getParameter(s.UNPACK_SKIP_PIXELS),At=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,_.width);for(let K=0,xt=H.length;K<xt;K++){let Dt=H[K],Lt=Math.floor(Dt.start/4),ht=Math.ceil(Dt.count/4),Ot=Lt%_.width,L=Math.floor(Lt/_.width),dt=ht,j=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ot),s.pixelStorei(s.UNPACK_SKIP_ROWS,L),e.texSubImage2D(s.TEXTURE_2D,0,Ot,L,dt,j,F,V,_.data)}T.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,ct),s.pixelStorei(s.UNPACK_SKIP_PIXELS,St),s.pixelStorei(s.UNPACK_SKIP_ROWS,At)}}function wt(T,_,F){let V=s.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(V=s.TEXTURE_2D_ARRAY),_.isData3DTexture&&(V=s.TEXTURE_3D);let $=Zt(T,_),H=_.source;e.bindTexture(V,T.__webglTexture,s.TEXTURE0+F);let Tt=n.get(H);if(H.version!==Tt.__version||$===!0){e.activeTexture(s.TEXTURE0+F);let ct=Jt.getPrimaries(Jt.workingColorSpace),St=_.colorSpace===Dn?null:Jt.getPrimaries(_.colorSpace),At=_.colorSpace===Dn||ct===St?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,_.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,_.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,At);let K=x(_.image,!1,i.maxTextureSize);K=_t(_,K);let xt=r.convert(_.format,_.colorSpace),Dt=r.convert(_.type),Lt=M(_.internalFormat,xt,Dt,_.colorSpace,_.isVideoTexture);kt(V,_);let ht,Ot=_.mipmaps,L=_.isVideoTexture!==!0,dt=Tt.__version===void 0||$===!0,j=H.dataReady,yt=I(_,K);if(_.isDepthTexture)Lt=v(_.format===Qi,_.type),dt&&(L?e.texStorage2D(s.TEXTURE_2D,1,Lt,K.width,K.height):e.texImage2D(s.TEXTURE_2D,0,Lt,K.width,K.height,0,xt,Dt,null));else if(_.isDataTexture)if(Ot.length>0){L&&dt&&e.texStorage2D(s.TEXTURE_2D,yt,Lt,Ot[0].width,Ot[0].height);for(let nt=0,Z=Ot.length;nt<Z;nt++)ht=Ot[nt],L?j&&e.texSubImage2D(s.TEXTURE_2D,nt,0,0,ht.width,ht.height,xt,Dt,ht.data):e.texImage2D(s.TEXTURE_2D,nt,Lt,ht.width,ht.height,0,xt,Dt,ht.data);_.generateMipmaps=!1}else L?(dt&&e.texStorage2D(s.TEXTURE_2D,yt,Lt,K.width,K.height),j&&st(_,K,xt,Dt)):e.texImage2D(s.TEXTURE_2D,0,Lt,K.width,K.height,0,xt,Dt,K.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){L&&dt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,yt,Lt,Ot[0].width,Ot[0].height,K.depth);for(let nt=0,Z=Ot.length;nt<Z;nt++)if(ht=Ot[nt],_.format!==De)if(xt!==null)if(L){if(j)if(_.layerUpdates.size>0){let bt=rc(ht.width,ht.height,_.format,_.type);for(let zt of _.layerUpdates){let re=ht.data.subarray(zt*bt/ht.data.BYTES_PER_ELEMENT,(zt+1)*bt/ht.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,nt,0,0,zt,ht.width,ht.height,1,xt,re)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,nt,0,0,0,ht.width,ht.height,K.depth,xt,ht.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,nt,Lt,ht.width,ht.height,K.depth,0,ht.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else L?j&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,nt,0,0,0,ht.width,ht.height,K.depth,xt,Dt,ht.data):e.texImage3D(s.TEXTURE_2D_ARRAY,nt,Lt,ht.width,ht.height,K.depth,0,xt,Dt,ht.data)}else{L&&dt&&e.texStorage2D(s.TEXTURE_2D,yt,Lt,Ot[0].width,Ot[0].height);for(let nt=0,Z=Ot.length;nt<Z;nt++)ht=Ot[nt],_.format!==De?xt!==null?L?j&&e.compressedTexSubImage2D(s.TEXTURE_2D,nt,0,0,ht.width,ht.height,xt,ht.data):e.compressedTexImage2D(s.TEXTURE_2D,nt,Lt,ht.width,ht.height,0,ht.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?j&&e.texSubImage2D(s.TEXTURE_2D,nt,0,0,ht.width,ht.height,xt,Dt,ht.data):e.texImage2D(s.TEXTURE_2D,nt,Lt,ht.width,ht.height,0,xt,Dt,ht.data)}else if(_.isDataArrayTexture)if(L){if(dt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,yt,Lt,K.width,K.height,K.depth),j)if(_.layerUpdates.size>0){let nt=rc(K.width,K.height,_.format,_.type);for(let Z of _.layerUpdates){let bt=K.data.subarray(Z*nt/K.data.BYTES_PER_ELEMENT,(Z+1)*nt/K.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Z,K.width,K.height,1,xt,Dt,bt)}_.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,K.width,K.height,K.depth,xt,Dt,K.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,Lt,K.width,K.height,K.depth,0,xt,Dt,K.data);else if(_.isData3DTexture)L?(dt&&e.texStorage3D(s.TEXTURE_3D,yt,Lt,K.width,K.height,K.depth),j&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,K.width,K.height,K.depth,xt,Dt,K.data)):e.texImage3D(s.TEXTURE_3D,0,Lt,K.width,K.height,K.depth,0,xt,Dt,K.data);else if(_.isFramebufferTexture){if(dt)if(L)e.texStorage2D(s.TEXTURE_2D,yt,Lt,K.width,K.height);else{let nt=K.width,Z=K.height;for(let bt=0;bt<yt;bt++)e.texImage2D(s.TEXTURE_2D,bt,Lt,nt,Z,0,xt,Dt,null),nt>>=1,Z>>=1}}else if(Ot.length>0){if(L&&dt){let nt=Bt(Ot[0]);e.texStorage2D(s.TEXTURE_2D,yt,Lt,nt.width,nt.height)}for(let nt=0,Z=Ot.length;nt<Z;nt++)ht=Ot[nt],L?j&&e.texSubImage2D(s.TEXTURE_2D,nt,0,0,xt,Dt,ht):e.texImage2D(s.TEXTURE_2D,nt,Lt,xt,Dt,ht);_.generateMipmaps=!1}else if(L){if(dt){let nt=Bt(K);e.texStorage2D(s.TEXTURE_2D,yt,Lt,nt.width,nt.height)}j&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,xt,Dt,K)}else e.texImage2D(s.TEXTURE_2D,0,Lt,xt,Dt,K);m(_)&&f(V),Tt.__version=H.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function pt(T,_,F){if(_.image.length!==6)return;let V=Zt(T,_),$=_.source;e.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+F);let H=n.get($);if($.version!==H.__version||V===!0){e.activeTexture(s.TEXTURE0+F);let Tt=Jt.getPrimaries(Jt.workingColorSpace),ct=_.colorSpace===Dn?null:Jt.getPrimaries(_.colorSpace),St=_.colorSpace===Dn||Tt===ct?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,_.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,_.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,St);let At=_.isCompressedTexture||_.image[0].isCompressedTexture,K=_.image[0]&&_.image[0].isDataTexture,xt=[];for(let Z=0;Z<6;Z++)!At&&!K?xt[Z]=x(_.image[Z],!0,i.maxCubemapSize):xt[Z]=K?_.image[Z].image:_.image[Z],xt[Z]=_t(_,xt[Z]);let Dt=xt[0],Lt=r.convert(_.format,_.colorSpace),ht=r.convert(_.type),Ot=M(_.internalFormat,Lt,ht,_.colorSpace),L=_.isVideoTexture!==!0,dt=H.__version===void 0||V===!0,j=$.dataReady,yt=I(_,Dt);kt(s.TEXTURE_CUBE_MAP,_);let nt;if(At){L&&dt&&e.texStorage2D(s.TEXTURE_CUBE_MAP,yt,Ot,Dt.width,Dt.height);for(let Z=0;Z<6;Z++){nt=xt[Z].mipmaps;for(let bt=0;bt<nt.length;bt++){let zt=nt[bt];_.format!==De?Lt!==null?L?j&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt,0,0,zt.width,zt.height,Lt,zt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt,Ot,zt.width,zt.height,0,zt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt,0,0,zt.width,zt.height,Lt,ht,zt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt,Ot,zt.width,zt.height,0,Lt,ht,zt.data)}}}else{if(nt=_.mipmaps,L&&dt){nt.length>0&&yt++;let Z=Bt(xt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,yt,Ot,Z.width,Z.height)}for(let Z=0;Z<6;Z++)if(K){L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,xt[Z].width,xt[Z].height,Lt,ht,xt[Z].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ot,xt[Z].width,xt[Z].height,0,Lt,ht,xt[Z].data);for(let bt=0;bt<nt.length;bt++){let re=nt[bt].image[Z].image;L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt+1,0,0,re.width,re.height,Lt,ht,re.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt+1,Ot,re.width,re.height,0,Lt,ht,re.data)}}else{L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,Lt,ht,xt[Z]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ot,Lt,ht,xt[Z]);for(let bt=0;bt<nt.length;bt++){let zt=nt[bt];L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt+1,0,0,Lt,ht,zt.image[Z]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,bt+1,Ot,Lt,ht,zt.image[Z])}}}m(_)&&f(s.TEXTURE_CUBE_MAP),H.__version=$.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function Ct(T,_,F,V,$,H){let Tt=r.convert(F.format,F.colorSpace),ct=r.convert(F.type),St=M(F.internalFormat,Tt,ct,F.colorSpace),At=n.get(_),K=n.get(F);if(K.__renderTarget=_,!At.__hasExternalTextures){let xt=Math.max(1,_.width>>H),Dt=Math.max(1,_.height>>H);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?e.texImage3D($,H,St,xt,Dt,_.depth,0,Tt,ct,null):e.texImage2D($,H,St,xt,Dt,0,Tt,ct,null)}e.bindFramebuffer(s.FRAMEBUFFER,T),gt(_)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,V,$,K.__webglTexture,0,q(_)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,V,$,K.__webglTexture,H),e.bindFramebuffer(s.FRAMEBUFFER,null)}function Ht(T,_,F){if(s.bindRenderbuffer(s.RENDERBUFFER,T),_.depthBuffer){let V=_.depthTexture,$=V&&V.isDepthTexture?V.type:null,H=v(_.stencilBuffer,$),Tt=_.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ct=q(_);gt(_)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ct,H,_.width,_.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,ct,H,_.width,_.height):s.renderbufferStorage(s.RENDERBUFFER,H,_.width,_.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Tt,s.RENDERBUFFER,T)}else{let V=_.textures;for(let $=0;$<V.length;$++){let H=V[$],Tt=r.convert(H.format,H.colorSpace),ct=r.convert(H.type),St=M(H.internalFormat,Tt,ct,H.colorSpace),At=q(_);F&&gt(_)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,At,St,_.width,_.height):gt(_)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,At,St,_.width,_.height):s.renderbufferStorage(s.RENDERBUFFER,St,_.width,_.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function It(T,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(s.FRAMEBUFFER,T),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let V=n.get(_.depthTexture);V.__renderTarget=_,(!V.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),J(_.depthTexture,0);let $=V.__webglTexture,H=q(_);if(_.depthTexture.format===zi)gt(_)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,$,0,H):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,$,0);else if(_.depthTexture.format===Qi)gt(_)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,$,0,H):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,$,0);else throw new Error("Unknown depthTexture format")}function se(T){let _=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==T.depthTexture){let V=T.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),V){let $=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,V.removeEventListener("dispose",$)};V.addEventListener("dispose",$),_.__depthDisposeCallback=$}_.__boundDepthTexture=V}if(T.depthTexture&&!_.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");let V=T.texture.mipmaps;V&&V.length>0?It(_.__webglFramebuffer[0],T):It(_.__webglFramebuffer,T)}else if(F){_.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(e.bindFramebuffer(s.FRAMEBUFFER,_.__webglFramebuffer[V]),_.__webglDepthbuffer[V]===void 0)_.__webglDepthbuffer[V]=s.createRenderbuffer(),Ht(_.__webglDepthbuffer[V],T,!1);else{let $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,H=_.__webglDepthbuffer[V];s.bindRenderbuffer(s.RENDERBUFFER,H),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,H)}}else{let V=T.texture.mipmaps;if(V&&V.length>0?e.bindFramebuffer(s.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=s.createRenderbuffer(),Ht(_.__webglDepthbuffer,T,!1);else{let $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,H=_.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,H),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,H)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function $t(T,_,F){let V=n.get(T);_!==void 0&&Ct(V.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&se(T)}function Gt(T){let _=T.texture,F=n.get(T),V=n.get(_);T.addEventListener("dispose",R);let $=T.textures,H=T.isWebGLCubeRenderTarget===!0,Tt=$.length>1;if(Tt||(V.__webglTexture===void 0&&(V.__webglTexture=s.createTexture()),V.__version=_.version,a.memory.textures++),H){F.__webglFramebuffer=[];for(let ct=0;ct<6;ct++)if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer[ct]=[];for(let St=0;St<_.mipmaps.length;St++)F.__webglFramebuffer[ct][St]=s.createFramebuffer()}else F.__webglFramebuffer[ct]=s.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer=[];for(let ct=0;ct<_.mipmaps.length;ct++)F.__webglFramebuffer[ct]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(Tt)for(let ct=0,St=$.length;ct<St;ct++){let At=n.get($[ct]);At.__webglTexture===void 0&&(At.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&gt(T)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ct=0;ct<$.length;ct++){let St=$[ct];F.__webglColorRenderbuffer[ct]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[ct]);let At=r.convert(St.format,St.colorSpace),K=r.convert(St.type),xt=M(St.internalFormat,At,K,St.colorSpace,T.isXRRenderTarget===!0),Dt=q(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,Dt,xt,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.RENDERBUFFER,F.__webglColorRenderbuffer[ct])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Ht(F.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(H){e.bindTexture(s.TEXTURE_CUBE_MAP,V.__webglTexture),kt(s.TEXTURE_CUBE_MAP,_);for(let ct=0;ct<6;ct++)if(_.mipmaps&&_.mipmaps.length>0)for(let St=0;St<_.mipmaps.length;St++)Ct(F.__webglFramebuffer[ct][St],T,_,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ct,St);else Ct(F.__webglFramebuffer[ct],T,_,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0);m(_)&&f(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Tt){for(let ct=0,St=$.length;ct<St;ct++){let At=$[ct],K=n.get(At);e.bindTexture(s.TEXTURE_2D,K.__webglTexture),kt(s.TEXTURE_2D,At),Ct(F.__webglFramebuffer,T,At,s.COLOR_ATTACHMENT0+ct,s.TEXTURE_2D,0),m(At)&&f(s.TEXTURE_2D)}e.unbindTexture()}else{let ct=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ct=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(ct,V.__webglTexture),kt(ct,_),_.mipmaps&&_.mipmaps.length>0)for(let St=0;St<_.mipmaps.length;St++)Ct(F.__webglFramebuffer[St],T,_,s.COLOR_ATTACHMENT0,ct,St);else Ct(F.__webglFramebuffer,T,_,s.COLOR_ATTACHMENT0,ct,0);m(_)&&f(ct),e.unbindTexture()}T.depthBuffer&&se(T)}function b(T){let _=T.textures;for(let F=0,V=_.length;F<V;F++){let $=_[F];if(m($)){let H=A(T),Tt=n.get($).__webglTexture;e.bindTexture(H,Tt),f(H),e.unbindTexture()}}}let rt=[],Q=[];function at(T){if(T.samples>0){if(gt(T)===!1){let _=T.textures,F=T.width,V=T.height,$=s.COLOR_BUFFER_BIT,H=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Tt=n.get(T),ct=_.length>1;if(ct)for(let At=0;At<_.length;At++)e.bindFramebuffer(s.FRAMEBUFFER,Tt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+At,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,Tt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+At,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,Tt.__webglMultisampledFramebuffer);let St=T.texture.mipmaps;St&&St.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,Tt.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,Tt.__webglFramebuffer);for(let At=0;At<_.length;At++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),ct){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Tt.__webglColorRenderbuffer[At]);let K=n.get(_[At]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,K,0)}s.blitFramebuffer(0,0,F,V,0,0,F,V,$,s.NEAREST),l===!0&&(rt.length=0,Q.length=0,rt.push(s.COLOR_ATTACHMENT0+At),T.depthBuffer&&T.resolveDepthBuffer===!1&&(rt.push(H),Q.push(H),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Q)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,rt))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),ct)for(let At=0;At<_.length;At++){e.bindFramebuffer(s.FRAMEBUFFER,Tt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+At,s.RENDERBUFFER,Tt.__webglColorRenderbuffer[At]);let K=n.get(_[At]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,Tt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+At,s.TEXTURE_2D,K,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,Tt.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){let _=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[_])}}}function q(T){return Math.min(i.maxSamples,T.samples)}function gt(T){let _=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function et(T){let _=a.render.frame;h.get(T)!==_&&(h.set(T,_),T.update())}function _t(T,_){let F=T.colorSpace,V=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==ai&&F!==Dn&&(Jt.getTransfer(F)===ee?(V!==De||$!==on)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),_}function Bt(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=Y,this.setTexture2D=J,this.setTexture2DArray=G,this.setTexture3D=tt,this.setTextureCube=k,this.rebindTextures=$t,this.setupRenderTarget=Gt,this.updateRenderTargetMipmap=b,this.updateMultisampleRenderTarget=at,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Ct,this.useMultisampledRTT=gt}function gx(s,t){function e(n,i=Dn){let r,a=Jt.getTransfer(i);if(n===on)return s.UNSIGNED_BYTE;if(n===Ta)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Aa)return s.UNSIGNED_SHORT_5_5_5_1;if(n===ql)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Wl)return s.BYTE;if(n===Xl)return s.SHORT;if(n===Ji)return s.UNSIGNED_SHORT;if(n===Ea)return s.INT;if(n===Ln)return s.UNSIGNED_INT;if(n===Be)return s.FLOAT;if(n===$i)return s.HALF_FLOAT;if(n===Yl)return s.ALPHA;if(n===Zl)return s.RGB;if(n===De)return s.RGBA;if(n===zi)return s.DEPTH_COMPONENT;if(n===Qi)return s.DEPTH_STENCIL;if(n===wa)return s.RED;if(n===Xs)return s.RED_INTEGER;if(n===Jl)return s.RG;if(n===Ca)return s.RG_INTEGER;if(n===Ra)return s.RGBA_INTEGER;if(n===qs||n===Ys||n===Zs||n===Js)if(a===ee)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===qs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ys)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===qs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ys)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Js)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ia||n===Pa||n===La||n===Da)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ia)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Pa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===La)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Da)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ua||n===Na||n===Fa)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ua||n===Na)return a===ee?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Fa)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Oa||n===Ba||n===za||n===ka||n===Va||n===Ha||n===Ga||n===Wa||n===Xa||n===qa||n===Ya||n===Za||n===Ja||n===$a)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Oa)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ba)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===za)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ka)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Va)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ha)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ga)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Wa)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Xa)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===qa)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ya)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Za)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ja)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===$a)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===$s||n===Ka||n===Qa)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===$s)return a===ee?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ka)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Qa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===$l||n===ja||n===to||n===eo)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===$s)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ja)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===to)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===eo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ki?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}var _x=`
3796
+ void main() {
3797
+
3798
+ gl_Position = vec4( position, 1.0 );
3799
+
3800
+ }`,xx=`
3801
+ uniform sampler2DArray depthColor;
3802
+ uniform float depthWidth;
3803
+ uniform float depthHeight;
3804
+
3805
+ void main() {
3806
+
3807
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3808
+
3809
+ if ( coord.x >= 1.0 ) {
3810
+
3811
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3812
+
3813
+ } else {
3814
+
3815
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3816
+
3817
+ }
3818
+
3819
+ }`,xc=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let i=new Se,r=t.properties.get(i);r.__webglTexture=e.texture,(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new an({vertexShader:_x,fragmentShader:xx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new be(new zs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},vc=class extends An{constructor(t,e){super();let n=this,i=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,g=null,x=new xc,m=e.getContextAttributes(),f=null,A=null,M=[],v=[],I=new ot,w=null,R=new we;R.viewport=new Qt;let D=new we;D.viewport=new Qt;let E=[R,D],S=new da,P=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let st=M[W];return st===void 0&&(st=new Xi,M[W]=st),st.getTargetRaySpace()},this.getControllerGrip=function(W){let st=M[W];return st===void 0&&(st=new Xi,M[W]=st),st.getGripSpace()},this.getHand=function(W){let st=M[W];return st===void 0&&(st=new Xi,M[W]=st),st.getHandSpace()};function z(W){let st=v.indexOf(W.inputSource);if(st===-1)return;let wt=M[st];wt!==void 0&&(wt.update(W.inputSource,W.frame,c||a),wt.dispatchEvent({type:W.type,data:W.inputSource}))}function X(){i.removeEventListener("select",z),i.removeEventListener("selectstart",z),i.removeEventListener("selectend",z),i.removeEventListener("squeeze",z),i.removeEventListener("squeezestart",z),i.removeEventListener("squeezeend",z),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",J);for(let W=0;W<M.length;W++){let st=v[W];st!==null&&(v[W]=null,M[W].disconnect(st))}P=null,Y=null,x.reset(),t.setRenderTarget(f),p=null,d=null,u=null,i=null,A=null,Zt.stop(),n.isPresenting=!1,t.setPixelRatio(w),t.setSize(I.width,I.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){r=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(W){if(i=W,i!==null){if(f=t.getRenderTarget(),i.addEventListener("select",z),i.addEventListener("selectstart",z),i.addEventListener("selectend",z),i.addEventListener("squeeze",z),i.addEventListener("squeezestart",z),i.addEventListener("squeezeend",z),i.addEventListener("end",X),i.addEventListener("inputsourceschange",J),m.xrCompatible!==!0&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let wt=null,pt=null,Ct=null;m.depth&&(Ct=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,wt=m.stencil?Qi:zi,pt=m.stencil?Ki:Ln);let Ht={colorFormat:e.RGBA8,depthFormat:Ct,scaleFactor:r};u=new XRWebGLBinding(i,e),d=u.createProjectionLayer(Ht),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),A=new dn(d.textureWidth,d.textureHeight,{format:De,type:on,depthTexture:new Rs(d.textureWidth,d.textureHeight,pt,void 0,void 0,void 0,void 0,void 0,void 0,wt),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let wt={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,e,wt),i.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new dn(p.framebufferWidth,p.framebufferHeight,{format:De,type:on,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),Zt.setContext(i),Zt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function J(W){for(let st=0;st<W.removed.length;st++){let wt=W.removed[st],pt=v.indexOf(wt);pt>=0&&(v[pt]=null,M[pt].disconnect(wt))}for(let st=0;st<W.added.length;st++){let wt=W.added[st],pt=v.indexOf(wt);if(pt===-1){for(let Ht=0;Ht<M.length;Ht++)if(Ht>=v.length){v.push(wt),pt=Ht;break}else if(v[Ht]===null){v[Ht]=wt,pt=Ht;break}if(pt===-1)break}let Ct=M[pt];Ct&&Ct.connect(wt)}}let G=new C,tt=new C;function k(W,st,wt){G.setFromMatrixPosition(st.matrixWorld),tt.setFromMatrixPosition(wt.matrixWorld);let pt=G.distanceTo(tt),Ct=st.projectionMatrix.elements,Ht=wt.projectionMatrix.elements,It=Ct[14]/(Ct[10]-1),se=Ct[14]/(Ct[10]+1),$t=(Ct[9]+1)/Ct[5],Gt=(Ct[9]-1)/Ct[5],b=(Ct[8]-1)/Ct[0],rt=(Ht[8]+1)/Ht[0],Q=It*b,at=It*rt,q=pt/(-b+rt),gt=q*-b;if(st.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(gt),W.translateZ(q),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Ct[10]===-1)W.projectionMatrix.copy(st.projectionMatrix),W.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{let et=It+q,_t=se+q,Bt=Q-gt,T=at+(pt-gt),_=$t*se/_t*et,F=Gt*se/_t*et;W.projectionMatrix.makePerspective(Bt,T,_,F,et,_t),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function lt(W,st){st===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(st.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;let st=W.near,wt=W.far;x.texture!==null&&(x.depthNear>0&&(st=x.depthNear),x.depthFar>0&&(wt=x.depthFar)),S.near=D.near=R.near=st,S.far=D.far=R.far=wt,(P!==S.near||Y!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),P=S.near,Y=S.far),R.layers.mask=W.layers.mask|2,D.layers.mask=W.layers.mask|4,S.layers.mask=R.layers.mask|D.layers.mask;let pt=W.parent,Ct=S.cameras;lt(S,pt);for(let Ht=0;Ht<Ct.length;Ht++)lt(Ct[Ht],pt);Ct.length===2?k(S,R,D):S.projectionMatrix.copy(R.projectionMatrix),mt(W,S,pt)};function mt(W,st,wt){wt===null?W.matrix.copy(st.matrixWorld):(W.matrix.copy(wt.matrixWorld),W.matrix.invert(),W.matrix.multiply(st.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy(st.projectionMatrix),W.projectionMatrixInverse.copy(st.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=oi*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(W){l=W,d!==null&&(d.fixedFoveation=W),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=W)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(S)};let Mt=null;function kt(W,st){if(h=st.getViewerPose(c||a),g=st,h!==null){let wt=h.views;p!==null&&(t.setRenderTargetFramebuffer(A,p.framebuffer),t.setRenderTarget(A));let pt=!1;wt.length!==S.cameras.length&&(S.cameras.length=0,pt=!0);for(let It=0;It<wt.length;It++){let se=wt[It],$t=null;if(p!==null)$t=p.getViewport(se);else{let b=u.getViewSubImage(d,se);$t=b.viewport,It===0&&(t.setRenderTargetTextures(A,b.colorTexture,b.depthStencilTexture),t.setRenderTarget(A))}let Gt=E[It];Gt===void 0&&(Gt=new we,Gt.layers.enable(It),Gt.viewport=new Qt,E[It]=Gt),Gt.matrix.fromArray(se.transform.matrix),Gt.matrix.decompose(Gt.position,Gt.quaternion,Gt.scale),Gt.projectionMatrix.fromArray(se.projectionMatrix),Gt.projectionMatrixInverse.copy(Gt.projectionMatrix).invert(),Gt.viewport.set($t.x,$t.y,$t.width,$t.height),It===0&&(S.matrix.copy(Gt.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),pt===!0&&S.cameras.push(Gt)}let Ct=i.enabledFeatures;if(Ct&&Ct.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&u){let It=u.getDepthInformation(wt[0]);It&&It.isValid&&It.texture&&x.init(t,It,i.renderState)}}for(let wt=0;wt<M.length;wt++){let pt=v[wt],Ct=M[wt];pt!==null&&Ct!==void 0&&Ct.update(pt,st,c||a)}Mt&&Mt(W,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),g=null}let Zt=new Xu;Zt.setAnimationLoop(kt),this.setAnimationLoop=function(W){Mt=W},this.dispose=function(){}}},vi=new Ke,vx=new Wt;function yx(s,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,ec(s)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function i(m,f,A,M,v){f.isMeshBasicMaterial||f.isMeshLambertMaterial?r(m,f):f.isMeshToonMaterial?(r(m,f),u(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f)):f.isMeshStandardMaterial?(r(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,v)):f.isMeshMatcapMaterial?(r(m,f),g(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),x(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,A,M):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Ue&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Ue&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let A=t.get(f),M=A.envMap,v=A.envMapRotation;M&&(m.envMap.value=M,vi.copy(v),vi.x*=-1,vi.y*=-1,vi.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(vi.y*=-1,vi.z*=-1),m.envMapRotation.value.setFromMatrix4(vx.makeRotationFromEuler(vi)),m.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,A,M){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*A,m.scale.value=M*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,A){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ue&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function x(m,f){let A=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Mx(s,t,e,n){let i={},r={},a=[],o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(A,M){let v=M.program;n.uniformBlockBinding(A,v)}function c(A,M){let v=i[A.id];v===void 0&&(g(A),v=h(A),i[A.id]=v,A.addEventListener("dispose",m));let I=M.program;n.updateUBOMapping(A,I);let w=t.render.frame;r[A.id]!==w&&(d(A),r[A.id]=w)}function h(A){let M=u();A.__bindingPointIndex=M;let v=s.createBuffer(),I=A.__size,w=A.usage;return s.bindBuffer(s.UNIFORM_BUFFER,v),s.bufferData(s.UNIFORM_BUFFER,I,w),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,M,v),v}function u(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(A){let M=i[A.id],v=A.uniforms,I=A.__cache;s.bindBuffer(s.UNIFORM_BUFFER,M);for(let w=0,R=v.length;w<R;w++){let D=Array.isArray(v[w])?v[w]:[v[w]];for(let E=0,S=D.length;E<S;E++){let P=D[E];if(p(P,w,E,I)===!0){let Y=P.__offset,z=Array.isArray(P.value)?P.value:[P.value],X=0;for(let J=0;J<z.length;J++){let G=z[J],tt=x(G);typeof G=="number"||typeof G=="boolean"?(P.__data[0]=G,s.bufferSubData(s.UNIFORM_BUFFER,Y+X,P.__data)):G.isMatrix3?(P.__data[0]=G.elements[0],P.__data[1]=G.elements[1],P.__data[2]=G.elements[2],P.__data[3]=0,P.__data[4]=G.elements[3],P.__data[5]=G.elements[4],P.__data[6]=G.elements[5],P.__data[7]=0,P.__data[8]=G.elements[6],P.__data[9]=G.elements[7],P.__data[10]=G.elements[8],P.__data[11]=0):(G.toArray(P.__data,X),X+=tt.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,Y,P.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(A,M,v,I){let w=A.value,R=M+"_"+v;if(I[R]===void 0)return typeof w=="number"||typeof w=="boolean"?I[R]=w:I[R]=w.clone(),!0;{let D=I[R];if(typeof w=="number"||typeof w=="boolean"){if(D!==w)return I[R]=w,!0}else if(D.equals(w)===!1)return D.copy(w),!0}return!1}function g(A){let M=A.uniforms,v=0,I=16;for(let R=0,D=M.length;R<D;R++){let E=Array.isArray(M[R])?M[R]:[M[R]];for(let S=0,P=E.length;S<P;S++){let Y=E[S],z=Array.isArray(Y.value)?Y.value:[Y.value];for(let X=0,J=z.length;X<J;X++){let G=z[X],tt=x(G),k=v%I,lt=k%tt.boundary,mt=k+lt;v+=lt,mt!==0&&I-mt<tt.storage&&(v+=I-mt),Y.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),Y.__offset=v,v+=tt.storage}}}let w=v%I;return w>0&&(v+=I-w),A.__size=v,A.__cache={},this}function x(A){let M={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(M.boundary=4,M.storage=4):A.isVector2?(M.boundary=8,M.storage=8):A.isVector3||A.isColor?(M.boundary=16,M.storage=12):A.isVector4?(M.boundary=16,M.storage=16):A.isMatrix3?(M.boundary=48,M.storage=48):A.isMatrix4?(M.boundary=64,M.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),M}function m(A){let M=A.target;M.removeEventListener("dispose",m);let v=a.indexOf(M.__bindingPointIndex);a.splice(v,1),s.deleteBuffer(i[M.id]),delete i[M.id],delete r[M.id]}function f(){for(let A in i)s.deleteBuffer(i[A]);a=[],i={},r={}}return{bind:l,update:c,dispose:f}}var Wu=class{constructor(t={}){let{canvas:e=cu(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;let g=new Uint32Array(4),x=new Int32Array(4),m=null,f=null,A=[],M=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let v=this,I=!1;this._outputColorSpace=We;let w=0,R=0,D=null,E=-1,S=null,P=new Qt,Y=new Qt,z=null,X=new Ut(0),J=0,G=e.width,tt=e.height,k=1,lt=null,mt=null,Mt=new Qt(0,0,G,tt),kt=new Qt(0,0,G,tt),Zt=!1,W=new Wn,st=!1,wt=!1,pt=new Wt,Ct=new Wt,Ht=new C,It=new Qt,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},$t=!1;function Gt(){return D===null?k:1}let b=n;function rt(y,U){return e.getContext(y,U)}try{let y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"178"}`),e.addEventListener("webglcontextlost",yt,!1),e.addEventListener("webglcontextrestored",nt,!1),e.addEventListener("webglcontextcreationerror",Z,!1),b===null){let U="webgl2";if(b=rt(U,y),b===null)throw rt(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let Q,at,q,gt,et,_t,Bt,T,_,F,V,$,H,Tt,ct,St,At,K,xt,Dt,Lt,ht,Ot,L;function dt(){Q=new zg(b),Q.init(),ht=new gx(b,Q),at=new Lg(b,Q,t,ht),q=new px(b,Q),at.reverseDepthBuffer&&d&&q.buffers.depth.setReversed(!0),gt=new Hg(b),et=new ex,_t=new mx(b,Q,q,et,at,ht,gt),Bt=new Ug(v),T=new Bg(v),_=new Zf(b),Ot=new Ig(b,_),F=new kg(b,_,gt,Ot),V=new Wg(b,F,_,gt),xt=new Gg(b,at,_t),St=new Dg(et),$=new tx(v,Bt,T,Q,at,Ot,St),H=new yx(v,et),Tt=new ix,ct=new cx(Q),K=new Rg(v,Bt,T,q,V,p,l),At=new dx(v,V,at),L=new Mx(b,gt,at,q),Dt=new Pg(b,Q,gt),Lt=new Vg(b,Q,gt),gt.programs=$.programs,v.capabilities=at,v.extensions=Q,v.properties=et,v.renderLists=Tt,v.shadowMap=At,v.state=q,v.info=gt}dt();let j=new vc(v,b);this.xr=j,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){let y=Q.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Q.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(y){y!==void 0&&(k=y,this.setSize(G,tt,!1))},this.getSize=function(y){return y.set(G,tt)},this.setSize=function(y,U,O=!0){if(j.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=y,tt=U,e.width=Math.floor(y*k),e.height=Math.floor(U*k),O===!0&&(e.style.width=y+"px",e.style.height=U+"px"),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(G*k,tt*k).floor()},this.setDrawingBufferSize=function(y,U,O){G=y,tt=U,k=O,e.width=Math.floor(y*O),e.height=Math.floor(U*O),this.setViewport(0,0,y,U)},this.getCurrentViewport=function(y){return y.copy(P)},this.getViewport=function(y){return y.copy(Mt)},this.setViewport=function(y,U,O,B){y.isVector4?Mt.set(y.x,y.y,y.z,y.w):Mt.set(y,U,O,B),q.viewport(P.copy(Mt).multiplyScalar(k).round())},this.getScissor=function(y){return y.copy(kt)},this.setScissor=function(y,U,O,B){y.isVector4?kt.set(y.x,y.y,y.z,y.w):kt.set(y,U,O,B),q.scissor(Y.copy(kt).multiplyScalar(k).round())},this.getScissorTest=function(){return Zt},this.setScissorTest=function(y){q.setScissorTest(Zt=y)},this.setOpaqueSort=function(y){lt=y},this.setTransparentSort=function(y){mt=y},this.getClearColor=function(y){return y.copy(K.getClearColor())},this.setClearColor=function(){K.setClearColor(...arguments)},this.getClearAlpha=function(){return K.getClearAlpha()},this.setClearAlpha=function(){K.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,O=!0){let B=0;if(y){let N=!1;if(D!==null){let it=D.texture.format;N=it===Ra||it===Ca||it===Xs}if(N){let it=D.texture.type,ft=it===on||it===Ln||it===Ji||it===Ki||it===Ta||it===Aa,Et=K.getClearColor(),vt=K.getClearAlpha(),Nt=Et.r,Ft=Et.g,Rt=Et.b;ft?(g[0]=Nt,g[1]=Ft,g[2]=Rt,g[3]=vt,b.clearBufferuiv(b.COLOR,0,g)):(x[0]=Nt,x[1]=Ft,x[2]=Rt,x[3]=vt,b.clearBufferiv(b.COLOR,0,x))}else B|=b.COLOR_BUFFER_BIT}U&&(B|=b.DEPTH_BUFFER_BIT),O&&(B|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",yt,!1),e.removeEventListener("webglcontextrestored",nt,!1),e.removeEventListener("webglcontextcreationerror",Z,!1),K.dispose(),Tt.dispose(),ct.dispose(),et.dispose(),Bt.dispose(),T.dispose(),V.dispose(),Ot.dispose(),L.dispose(),$.dispose(),j.dispose(),j.removeEventListener("sessionstart",Mc),j.removeEventListener("sessionend",Sc),Yn.stop()};function yt(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),I=!0}function nt(){console.log("THREE.WebGLRenderer: Context Restored."),I=!1;let y=gt.autoReset,U=At.enabled,O=At.autoUpdate,B=At.needsUpdate,N=At.type;dt(),gt.autoReset=y,At.enabled=U,At.autoUpdate=O,At.needsUpdate=B,At.type=N}function Z(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function bt(y){let U=y.target;U.removeEventListener("dispose",bt),zt(U)}function zt(y){re(y),et.remove(y)}function re(y){let U=et.get(y).programs;U!==void 0&&(U.forEach(function(O){$.releaseProgram(O)}),y.isShaderMaterial&&$.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,O,B,N,it){U===null&&(U=se);let ft=N.isMesh&&N.matrixWorld.determinant()<0,Et=$u(y,U,O,B,N);q.setMaterial(B,ft);let vt=O.index,Nt=1;if(B.wireframe===!0){if(vt=F.getWireframeAttribute(O),vt===void 0)return;Nt=2}let Ft=O.drawRange,Rt=O.attributes.position,Yt=Ft.start*Nt,ne=(Ft.start+Ft.count)*Nt;it!==null&&(Yt=Math.max(Yt,it.start*Nt),ne=Math.min(ne,(it.start+it.count)*Nt)),vt!==null?(Yt=Math.max(Yt,0),ne=Math.min(ne,vt.count)):Rt!=null&&(Yt=Math.max(Yt,0),ne=Math.min(ne,Rt.count));let de=ne-Yt;if(de<0||de===1/0)return;Ot.setup(N,B,Et,O,vt);let ae,ie=Dt;if(vt!==null&&(ae=_.get(vt),ie=Lt,ie.setIndex(ae)),N.isMesh)B.wireframe===!0?(q.setLineWidth(B.wireframeLinewidth*Gt()),ie.setMode(b.LINES)):ie.setMode(b.TRIANGLES);else if(N.isLine){let Pt=B.linewidth;Pt===void 0&&(Pt=1),q.setLineWidth(Pt*Gt()),N.isLineSegments?ie.setMode(b.LINES):N.isLineLoop?ie.setMode(b.LINE_LOOP):ie.setMode(b.LINE_STRIP)}else N.isPoints?ie.setMode(b.POINTS):N.isSprite&&ie.setMode(b.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)li("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ie.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))ie.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{let Pt=N._multiDrawStarts,he=N._multiDrawCounts,Kt=N._multiDrawCount,ke=vt?_.get(vt).bytesPerElement:1,Si=et.get(B).currentProgram.getUniforms();for(let Ve=0;Ve<Kt;Ve++)Si.setValue(b,"_gl_DrawID",Ve),ie.render(Pt[Ve]/ke,he[Ve])}else if(N.isInstancedMesh)ie.renderInstances(Yt,de,N.count);else if(O.isInstancedBufferGeometry){let Pt=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,he=Math.min(O.instanceCount,Pt);ie.renderInstances(Yt,de,he)}else ie.render(Yt,de)};function jt(y,U,O){y.transparent===!0&&y.side===pn&&y.forceSinglePass===!1?(y.side=Ue,y.needsUpdate=!0,js(y,U,O),y.side=Tn,y.needsUpdate=!0,js(y,U,O),y.side=pn):js(y,U,O)}this.compile=function(y,U,O=null){O===null&&(O=y),f=ct.get(O),f.init(U),M.push(f),O.traverseVisible(function(N){N.isLight&&N.layers.test(U.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),y!==O&&y.traverseVisible(function(N){N.isLight&&N.layers.test(U.layers)&&(f.pushLight(N),N.castShadow&&f.pushShadow(N))}),f.setupLights();let B=new Set;return y.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;let it=N.material;if(it)if(Array.isArray(it))for(let ft=0;ft<it.length;ft++){let Et=it[ft];jt(Et,O,N),B.add(Et)}else jt(it,O,N),B.add(it)}),f=M.pop(),B},this.compileAsync=function(y,U,O=null){let B=this.compile(y,U,O);return new Promise(N=>{function it(){if(B.forEach(function(ft){et.get(ft).currentProgram.isReady()&&B.delete(ft)}),B.size===0){N(y);return}setTimeout(it,10)}Q.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let Qe=null;function gn(y){Qe&&Qe(y)}function Mc(){Yn.stop()}function Sc(){Yn.start()}let Yn=new Xu;Yn.setAnimationLoop(gn),typeof self<"u"&&Yn.setContext(self),this.setAnimationLoop=function(y){Qe=y,j.setAnimationLoop(y),y===null?Yn.stop():Yn.start()},j.addEventListener("sessionstart",Mc),j.addEventListener("sessionend",Sc),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),j.enabled===!0&&j.isPresenting===!0&&(j.cameraAutoUpdate===!0&&j.updateCamera(U),U=j.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,U,D),f=ct.get(y,M.length),f.init(U),M.push(f),Ct.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),W.setFromProjectionMatrix(Ct),wt=this.localClippingEnabled,st=St.init(this.clippingPlanes,wt),m=Tt.get(y,A.length),m.init(),A.push(m),j.enabled===!0&&j.isPresenting===!0){let it=v.xr.getDepthSensingMesh();it!==null&&lo(it,U,-1/0,v.sortObjects)}lo(y,U,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(lt,mt),$t=j.enabled===!1||j.isPresenting===!1||j.hasDepthSensing()===!1,$t&&K.addToRenderList(m,y),this.info.render.frame++,st===!0&&St.beginShadows();let O=f.state.shadowsArray;At.render(O,y,U),st===!0&&St.endShadows(),this.info.autoReset===!0&&this.info.reset();let B=m.opaque,N=m.transmissive;if(f.setupLights(),U.isArrayCamera){let it=U.cameras;if(N.length>0)for(let ft=0,Et=it.length;ft<Et;ft++){let vt=it[ft];Ec(B,N,y,vt)}$t&&K.render(y);for(let ft=0,Et=it.length;ft<Et;ft++){let vt=it[ft];bc(m,y,vt,vt.viewport)}}else N.length>0&&Ec(B,N,y,U),$t&&K.render(y),bc(m,y,U);D!==null&&R===0&&(_t.updateMultisampleRenderTarget(D),_t.updateRenderTargetMipmap(D)),y.isScene===!0&&y.onAfterRender(v,y,U),Ot.resetDefaultState(),E=-1,S=null,M.pop(),M.length>0?(f=M[M.length-1],st===!0&&St.setGlobalState(v.clippingPlanes,f.state.camera)):f=null,A.pop(),A.length>0?m=A[A.length-1]:m=null};function lo(y,U,O,B){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)O=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLight)f.pushLight(y),y.castShadow&&f.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||W.intersectsSprite(y)){B&&It.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ct);let ft=V.update(y),Et=y.material;Et.visible&&m.push(y,ft,Et,O,It.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||W.intersectsObject(y))){let ft=V.update(y),Et=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),It.copy(y.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),It.copy(ft.boundingSphere.center)),It.applyMatrix4(y.matrixWorld).applyMatrix4(Ct)),Array.isArray(Et)){let vt=ft.groups;for(let Nt=0,Ft=vt.length;Nt<Ft;Nt++){let Rt=vt[Nt],Yt=Et[Rt.materialIndex];Yt&&Yt.visible&&m.push(y,ft,Yt,O,It.z,Rt)}}else Et.visible&&m.push(y,ft,Et,O,It.z,null)}}let it=y.children;for(let ft=0,Et=it.length;ft<Et;ft++)lo(it[ft],U,O,B)}function bc(y,U,O,B){let N=y.opaque,it=y.transmissive,ft=y.transparent;f.setupLightsView(O),st===!0&&St.setGlobalState(v.clippingPlanes,O),B&&q.viewport(P.copy(B)),N.length>0&&Qs(N,U,O),it.length>0&&Qs(it,U,O),ft.length>0&&Qs(ft,U,O),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1)}function Ec(y,U,O,B){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[B.id]===void 0&&(f.state.transmissionRenderTarget[B.id]=new dn(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?$i:on,minFilter:qn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Jt.workingColorSpace}));let it=f.state.transmissionRenderTarget[B.id],ft=B.viewport||P;it.setSize(ft.z*v.transmissionResolutionScale,ft.w*v.transmissionResolutionScale);let Et=v.getRenderTarget(),vt=v.getActiveCubeFace(),Nt=v.getActiveMipmapLevel();v.setRenderTarget(it),v.getClearColor(X),J=v.getClearAlpha(),J<1&&v.setClearColor(16777215,.5),v.clear(),$t&&K.render(O);let Ft=v.toneMapping;v.toneMapping=Pn;let Rt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),f.setupLightsView(B),st===!0&&St.setGlobalState(v.clippingPlanes,B),Qs(y,O,B),_t.updateMultisampleRenderTarget(it),_t.updateRenderTargetMipmap(it),Q.has("WEBGL_multisampled_render_to_texture")===!1){let Yt=!1;for(let ne=0,de=U.length;ne<de;ne++){let ae=U[ne],ie=ae.object,Pt=ae.geometry,he=ae.material,Kt=ae.group;if(he.side===pn&&ie.layers.test(B.layers)){let ke=he.side;he.side=Ue,he.needsUpdate=!0,Tc(ie,O,B,Pt,he,Kt),he.side=ke,he.needsUpdate=!0,Yt=!0}}Yt===!0&&(_t.updateMultisampleRenderTarget(it),_t.updateRenderTargetMipmap(it))}v.setRenderTarget(Et,vt,Nt),v.setClearColor(X,J),Rt!==void 0&&(B.viewport=Rt),v.toneMapping=Ft}function Qs(y,U,O){let B=U.isScene===!0?U.overrideMaterial:null;for(let N=0,it=y.length;N<it;N++){let ft=y[N],Et=ft.object,vt=ft.geometry,Nt=ft.group,Ft=ft.material;Ft.allowOverride===!0&&B!==null&&(Ft=B),Et.layers.test(O.layers)&&Tc(Et,U,O,vt,Ft,Nt)}}function Tc(y,U,O,B,N,it){y.onBeforeRender(v,U,O,B,N,it),y.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),N.onBeforeRender(v,U,O,B,y,it),N.transparent===!0&&N.side===pn&&N.forceSinglePass===!1?(N.side=Ue,N.needsUpdate=!0,v.renderBufferDirect(O,U,B,N,y,it),N.side=Tn,N.needsUpdate=!0,v.renderBufferDirect(O,U,B,N,y,it),N.side=pn):v.renderBufferDirect(O,U,B,N,y,it),y.onAfterRender(v,U,O,B,N,it)}function js(y,U,O){U.isScene!==!0&&(U=se);let B=et.get(y),N=f.state.lights,it=f.state.shadowsArray,ft=N.state.version,Et=$.getParameters(y,N.state,it,U,O),vt=$.getProgramCacheKey(Et),Nt=B.programs;B.environment=y.isMeshStandardMaterial?U.environment:null,B.fog=U.fog,B.envMap=(y.isMeshStandardMaterial?T:Bt).get(y.envMap||B.environment),B.envMapRotation=B.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Nt===void 0&&(y.addEventListener("dispose",bt),Nt=new Map,B.programs=Nt);let Ft=Nt.get(vt);if(Ft!==void 0){if(B.currentProgram===Ft&&B.lightsStateVersion===ft)return wc(y,Et),Ft}else Et.uniforms=$.getUniforms(y),y.onBeforeCompile(Et,v),Ft=$.acquireProgram(Et,vt),Nt.set(vt,Ft),B.uniforms=Et.uniforms;let Rt=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Rt.clippingPlanes=St.uniform),wc(y,Et),B.needsLights=Qu(y),B.lightsStateVersion=ft,B.needsLights&&(Rt.ambientLightColor.value=N.state.ambient,Rt.lightProbe.value=N.state.probe,Rt.directionalLights.value=N.state.directional,Rt.directionalLightShadows.value=N.state.directionalShadow,Rt.spotLights.value=N.state.spot,Rt.spotLightShadows.value=N.state.spotShadow,Rt.rectAreaLights.value=N.state.rectArea,Rt.ltc_1.value=N.state.rectAreaLTC1,Rt.ltc_2.value=N.state.rectAreaLTC2,Rt.pointLights.value=N.state.point,Rt.pointLightShadows.value=N.state.pointShadow,Rt.hemisphereLights.value=N.state.hemi,Rt.directionalShadowMap.value=N.state.directionalShadowMap,Rt.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Rt.spotShadowMap.value=N.state.spotShadowMap,Rt.spotLightMatrix.value=N.state.spotLightMatrix,Rt.spotLightMap.value=N.state.spotLightMap,Rt.pointShadowMap.value=N.state.pointShadowMap,Rt.pointShadowMatrix.value=N.state.pointShadowMatrix),B.currentProgram=Ft,B.uniformsList=null,Ft}function Ac(y){if(y.uniformsList===null){let U=y.currentProgram.getUniforms();y.uniformsList=es.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function wc(y,U){let O=et.get(y);O.outputColorSpace=U.outputColorSpace,O.batching=U.batching,O.batchingColor=U.batchingColor,O.instancing=U.instancing,O.instancingColor=U.instancingColor,O.instancingMorph=U.instancingMorph,O.skinning=U.skinning,O.morphTargets=U.morphTargets,O.morphNormals=U.morphNormals,O.morphColors=U.morphColors,O.morphTargetsCount=U.morphTargetsCount,O.numClippingPlanes=U.numClippingPlanes,O.numIntersection=U.numClipIntersection,O.vertexAlphas=U.vertexAlphas,O.vertexTangents=U.vertexTangents,O.toneMapping=U.toneMapping}function $u(y,U,O,B,N){U.isScene!==!0&&(U=se),_t.resetTextureUnits();let it=U.fog,ft=B.isMeshStandardMaterial?U.environment:null,Et=D===null?v.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:ai,vt=(B.isMeshStandardMaterial?T:Bt).get(B.envMap||ft),Nt=B.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,Ft=!!O.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Rt=!!O.morphAttributes.position,Yt=!!O.morphAttributes.normal,ne=!!O.morphAttributes.color,de=Pn;B.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(de=v.toneMapping);let ae=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ie=ae!==void 0?ae.length:0,Pt=et.get(B),he=f.state.lights;if(st===!0&&(wt===!0||y!==S)){let Ie=y===S&&B.id===E;St.setState(B,y,Ie)}let Kt=!1;B.version===Pt.__version?(Pt.needsLights&&Pt.lightsStateVersion!==he.state.version||Pt.outputColorSpace!==Et||N.isBatchedMesh&&Pt.batching===!1||!N.isBatchedMesh&&Pt.batching===!0||N.isBatchedMesh&&Pt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Pt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Pt.instancing===!1||!N.isInstancedMesh&&Pt.instancing===!0||N.isSkinnedMesh&&Pt.skinning===!1||!N.isSkinnedMesh&&Pt.skinning===!0||N.isInstancedMesh&&Pt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Pt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Pt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Pt.instancingMorph===!1&&N.morphTexture!==null||Pt.envMap!==vt||B.fog===!0&&Pt.fog!==it||Pt.numClippingPlanes!==void 0&&(Pt.numClippingPlanes!==St.numPlanes||Pt.numIntersection!==St.numIntersection)||Pt.vertexAlphas!==Nt||Pt.vertexTangents!==Ft||Pt.morphTargets!==Rt||Pt.morphNormals!==Yt||Pt.morphColors!==ne||Pt.toneMapping!==de||Pt.morphTargetsCount!==ie)&&(Kt=!0):(Kt=!0,Pt.__version=B.version);let ke=Pt.currentProgram;Kt===!0&&(ke=js(B,U,N));let Si=!1,Ve=!1,is=!1,ce=ke.getUniforms(),qe=Pt.uniforms;if(q.useProgram(ke.program)&&(Si=!0,Ve=!0,is=!0),B.id!==E&&(E=B.id,Ve=!0),Si||S!==y){q.buffers.depth.getReversed()?(pt.copy(y.projectionMatrix),uu(pt),du(pt),ce.setValue(b,"projectionMatrix",pt)):ce.setValue(b,"projectionMatrix",y.projectionMatrix),ce.setValue(b,"viewMatrix",y.matrixWorldInverse);let Ne=ce.map.cameraPosition;Ne!==void 0&&Ne.setValue(b,Ht.setFromMatrixPosition(y.matrixWorld)),at.logarithmicDepthBuffer&&ce.setValue(b,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ce.setValue(b,"isOrthographic",y.isOrthographicCamera===!0),S!==y&&(S=y,Ve=!0,is=!0)}if(N.isSkinnedMesh){ce.setOptional(b,N,"bindMatrix"),ce.setOptional(b,N,"bindMatrixInverse");let Ie=N.skeleton;Ie&&(Ie.boneTexture===null&&Ie.computeBoneTexture(),ce.setValue(b,"boneTexture",Ie.boneTexture,_t))}N.isBatchedMesh&&(ce.setOptional(b,N,"batchingTexture"),ce.setValue(b,"batchingTexture",N._matricesTexture,_t),ce.setOptional(b,N,"batchingIdTexture"),ce.setValue(b,"batchingIdTexture",N._indirectTexture,_t),ce.setOptional(b,N,"batchingColorTexture"),N._colorsTexture!==null&&ce.setValue(b,"batchingColorTexture",N._colorsTexture,_t));let Ye=O.morphAttributes;if((Ye.position!==void 0||Ye.normal!==void 0||Ye.color!==void 0)&&xt.update(N,O,ke),(Ve||Pt.receiveShadow!==N.receiveShadow)&&(Pt.receiveShadow=N.receiveShadow,ce.setValue(b,"receiveShadow",N.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(qe.envMap.value=vt,qe.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),B.isMeshStandardMaterial&&B.envMap===null&&U.environment!==null&&(qe.envMapIntensity.value=U.environmentIntensity),Ve&&(ce.setValue(b,"toneMappingExposure",v.toneMappingExposure),Pt.needsLights&&Ku(qe,is),it&&B.fog===!0&&H.refreshFogUniforms(qe,it),H.refreshMaterialUniforms(qe,B,k,tt,f.state.transmissionRenderTarget[y.id]),es.upload(b,Ac(Pt),qe,_t)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(es.upload(b,Ac(Pt),qe,_t),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ce.setValue(b,"center",N.center),ce.setValue(b,"modelViewMatrix",N.modelViewMatrix),ce.setValue(b,"normalMatrix",N.normalMatrix),ce.setValue(b,"modelMatrix",N.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){let Ie=B.uniformsGroups;for(let Ne=0,co=Ie.length;Ne<co;Ne++){let Zn=Ie[Ne];L.update(Zn,ke),L.bind(Zn,ke)}}return ke}function Ku(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function Qu(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(y,U,O){let B=et.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),et.get(y.texture).__webglTexture=U,et.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:O,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){let O=et.get(y);O.__webglFramebuffer=U,O.__useDefaultFramebuffer=U===void 0};let ju=b.createFramebuffer();this.setRenderTarget=function(y,U=0,O=0){D=y,w=U,R=O;let B=!0,N=null,it=!1,ft=!1;if(y){let vt=et.get(y);if(vt.__useDefaultFramebuffer!==void 0)q.bindFramebuffer(b.FRAMEBUFFER,null),B=!1;else if(vt.__webglFramebuffer===void 0)_t.setupRenderTarget(y);else if(vt.__hasExternalTextures)_t.rebindTextures(y,et.get(y.texture).__webglTexture,et.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let Rt=y.depthTexture;if(vt.__boundDepthTexture!==Rt){if(Rt!==null&&et.has(Rt)&&(y.width!==Rt.image.width||y.height!==Rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");_t.setupDepthRenderbuffer(y)}}let Nt=y.texture;(Nt.isData3DTexture||Nt.isDataArrayTexture||Nt.isCompressedArrayTexture)&&(ft=!0);let Ft=et.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Ft[U])?N=Ft[U][O]:N=Ft[U],it=!0):y.samples>0&&_t.useMultisampledRTT(y)===!1?N=et.get(y).__webglMultisampledFramebuffer:Array.isArray(Ft)?N=Ft[O]:N=Ft,P.copy(y.viewport),Y.copy(y.scissor),z=y.scissorTest}else P.copy(Mt).multiplyScalar(k).floor(),Y.copy(kt).multiplyScalar(k).floor(),z=Zt;if(O!==0&&(N=ju),q.bindFramebuffer(b.FRAMEBUFFER,N)&&B&&q.drawBuffers(y,N),q.viewport(P),q.scissor(Y),q.setScissorTest(z),it){let vt=et.get(y.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+U,vt.__webglTexture,O)}else if(ft){let vt=et.get(y.texture),Nt=U;b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,vt.__webglTexture,O,Nt)}else if(y!==null&&O!==0){let vt=et.get(y.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,vt.__webglTexture,O)}E=-1},this.readRenderTargetPixels=function(y,U,O,B,N,it,ft,Et=0){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let vt=et.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ft!==void 0&&(vt=vt[ft]),vt){q.bindFramebuffer(b.FRAMEBUFFER,vt);try{let Nt=y.textures[Et],Ft=Nt.format,Rt=Nt.type;if(!at.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!at.textureTypeReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-B&&O>=0&&O<=y.height-N&&(y.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+Et),b.readPixels(U,O,B,N,ht.convert(Ft),ht.convert(Rt),it))}finally{let Nt=D!==null?et.get(D).__webglFramebuffer:null;q.bindFramebuffer(b.FRAMEBUFFER,Nt)}}},this.readRenderTargetPixelsAsync=async function(y,U,O,B,N,it,ft,Et=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let vt=et.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ft!==void 0&&(vt=vt[ft]),vt)if(U>=0&&U<=y.width-B&&O>=0&&O<=y.height-N){q.bindFramebuffer(b.FRAMEBUFFER,vt);let Nt=y.textures[Et],Ft=Nt.format,Rt=Nt.type;if(!at.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!at.textureTypeReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Yt=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,Yt),b.bufferData(b.PIXEL_PACK_BUFFER,it.byteLength,b.STREAM_READ),y.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+Et),b.readPixels(U,O,B,N,ht.convert(Ft),ht.convert(Rt),0);let ne=D!==null?et.get(D).__webglFramebuffer:null;q.bindFramebuffer(b.FRAMEBUFFER,ne);let de=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),await hu(b,de,4),b.bindBuffer(b.PIXEL_PACK_BUFFER,Yt),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,it),b.deleteBuffer(Yt),b.deleteSync(de),it}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,O=0){let B=Math.pow(2,-O),N=Math.floor(y.image.width*B),it=Math.floor(y.image.height*B),ft=U!==null?U.x:0,Et=U!==null?U.y:0;_t.setTexture2D(y,0),b.copyTexSubImage2D(b.TEXTURE_2D,O,0,0,ft,Et,N,it),q.unbindTexture()};let td=b.createFramebuffer(),ed=b.createFramebuffer();this.copyTextureToTexture=function(y,U,O=null,B=null,N=0,it=null){it===null&&(N!==0?(li("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),it=N,N=0):it=0);let ft,Et,vt,Nt,Ft,Rt,Yt,ne,de,ae=y.isCompressedTexture?y.mipmaps[it]:y.image;if(O!==null)ft=O.max.x-O.min.x,Et=O.max.y-O.min.y,vt=O.isBox3?O.max.z-O.min.z:1,Nt=O.min.x,Ft=O.min.y,Rt=O.isBox3?O.min.z:0;else{let Ye=Math.pow(2,-N);ft=Math.floor(ae.width*Ye),Et=Math.floor(ae.height*Ye),y.isDataArrayTexture?vt=ae.depth:y.isData3DTexture?vt=Math.floor(ae.depth*Ye):vt=1,Nt=0,Ft=0,Rt=0}B!==null?(Yt=B.x,ne=B.y,de=B.z):(Yt=0,ne=0,de=0);let ie=ht.convert(U.format),Pt=ht.convert(U.type),he;U.isData3DTexture?(_t.setTexture3D(U,0),he=b.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(_t.setTexture2DArray(U,0),he=b.TEXTURE_2D_ARRAY):(_t.setTexture2D(U,0),he=b.TEXTURE_2D),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,U.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,U.unpackAlignment);let Kt=b.getParameter(b.UNPACK_ROW_LENGTH),ke=b.getParameter(b.UNPACK_IMAGE_HEIGHT),Si=b.getParameter(b.UNPACK_SKIP_PIXELS),Ve=b.getParameter(b.UNPACK_SKIP_ROWS),is=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,ae.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,ae.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Nt),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ft),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Rt);let ce=y.isDataArrayTexture||y.isData3DTexture,qe=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){let Ye=et.get(y),Ie=et.get(U),Ne=et.get(Ye.__renderTarget),co=et.get(Ie.__renderTarget);q.bindFramebuffer(b.READ_FRAMEBUFFER,Ne.__webglFramebuffer),q.bindFramebuffer(b.DRAW_FRAMEBUFFER,co.__webglFramebuffer);for(let Zn=0;Zn<vt;Zn++)ce&&(b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,et.get(y).__webglTexture,N,Rt+Zn),b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,et.get(U).__webglTexture,it,de+Zn)),b.blitFramebuffer(Nt,Ft,ft,Et,Yt,ne,ft,Et,b.DEPTH_BUFFER_BIT,b.NEAREST);q.bindFramebuffer(b.READ_FRAMEBUFFER,null),q.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else if(N!==0||y.isRenderTargetTexture||et.has(y)){let Ye=et.get(y),Ie=et.get(U);q.bindFramebuffer(b.READ_FRAMEBUFFER,td),q.bindFramebuffer(b.DRAW_FRAMEBUFFER,ed);for(let Ne=0;Ne<vt;Ne++)ce?b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Ye.__webglTexture,N,Rt+Ne):b.framebufferTexture2D(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Ye.__webglTexture,N),qe?b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Ie.__webglTexture,it,de+Ne):b.framebufferTexture2D(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Ie.__webglTexture,it),N!==0?b.blitFramebuffer(Nt,Ft,ft,Et,Yt,ne,ft,Et,b.COLOR_BUFFER_BIT,b.NEAREST):qe?b.copyTexSubImage3D(he,it,Yt,ne,de+Ne,Nt,Ft,ft,Et):b.copyTexSubImage2D(he,it,Yt,ne,Nt,Ft,ft,Et);q.bindFramebuffer(b.READ_FRAMEBUFFER,null),q.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else qe?y.isDataTexture||y.isData3DTexture?b.texSubImage3D(he,it,Yt,ne,de,ft,Et,vt,ie,Pt,ae.data):U.isCompressedArrayTexture?b.compressedTexSubImage3D(he,it,Yt,ne,de,ft,Et,vt,ie,ae.data):b.texSubImage3D(he,it,Yt,ne,de,ft,Et,vt,ie,Pt,ae):y.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,it,Yt,ne,ft,Et,ie,Pt,ae.data):y.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,it,Yt,ne,ae.width,ae.height,ie,ae.data):b.texSubImage2D(b.TEXTURE_2D,it,Yt,ne,ft,Et,ie,Pt,ae);b.pixelStorei(b.UNPACK_ROW_LENGTH,Kt),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,ke),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Si),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ve),b.pixelStorei(b.UNPACK_SKIP_IMAGES,is),it===0&&U.generateMipmaps&&b.generateMipmap(he),q.unbindTexture()},this.copyTextureToTexture3D=function(y,U,O=null,B=null,N=0){return li('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(y,U,O,B,N)},this.initRenderTarget=function(y){et.get(y).__webglFramebuffer===void 0&&_t.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?_t.setTextureCube(y,0):y.isData3DTexture?_t.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?_t.setTexture2DArray(y,0):_t.setTexture2D(y,0),q.unbindTexture()},this.resetState=function(){w=0,R=0,D=null,q.reset(),Ot.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Je}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Jt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Jt._getUnpackColorSpace()}};export{ss as a,Cc as b,sd as c,Tn as d,Ue as e,pn as f,In as g,Ma as h,Fr as i,kn as j,Or as k,Oe as l,Kh as m,Ws as n,sn as o,ba as p,qn as q,on as r,Ji as s,Be as t,De as u,xs as v,Br as w,rd as x,ad as y,od as z,tu as A,Dn as B,We as C,ai as D,ei as E,ld as F,cd as G,hd as H,ud as I,dd as J,Zo as K,fd as L,Ql as M,Id as N,ot as O,wn as P,C as Q,Vt as R,Jt as S,kr as T,Vi as U,Se as V,Qt as W,dn as X,Le as Y,Ce as Z,Wt as _,Ke as $,ge as aa,Ut as ba,rn as ca,Ss as da,Me as ea,le as fa,_e as ga,be as ha,Gi as ia,pu as ja,an as ka,Wi as la,we as ma,ni as na,Jo as oa,$o as pa,Ko as qa,Qo as ra,Xr as sa,Vn as ta,jo as ua,As as va,tl as wa,hn as xa,Wn as ya,nl as za,qi as Aa,ws as Ba,Cs as Ca,il as Da,Jr as Ea,rl as Fa,al as Ga,ol as Ha,Rs as Ia,ll as Ja,Xe as Ka,Kr as La,Ns as Ma,na as Na,dl as Oa,zs as Pa,fl as Qa,pl as Ra,ia as Sa,ml as Ta,gl as Ua,sa as Va,ra as Wa,hi as Xa,ui as Ya,di as Za,fi as _a,_l as $a,Xn as ab,vl as bb,yl as cb,Sl as db,El as eb,Hs as fb,Al as gb,wl as hb,Cl as ib,Rl as jb,Il as kb,Pl as lb,oe as mb,Dl as nb,Nl as ob,Fl as pb,Ol as qb,Xt as rb,Wu as sb};