tokentracker-cli 0.25.1 → 0.26.1

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 (44) hide show
  1. package/dashboard/dist/assets/{ActivityHeatmap-CB0rCGvm.js → ActivityHeatmap-HJfo7rcM.js} +1 -1
  2. package/dashboard/dist/assets/{Card-BfKA33l_.js → Card-Cfr0E0Wz.js} +1 -1
  3. package/dashboard/dist/assets/{DashboardPage-u0vbeset.js → DashboardPage-C9s7AJGn.js} +1 -1
  4. package/dashboard/dist/assets/{DevicePage-9mF2GYDM.js → DevicePage-nTuWiKPp.js} +1 -1
  5. package/dashboard/dist/assets/{DialogTitle-BilvePW_.js → DialogTitle-pN7LLL0T.js} +1 -1
  6. package/dashboard/dist/assets/{FadeIn-DIUOdWDR.js → FadeIn-Cethnilq.js} +1 -1
  7. package/dashboard/dist/assets/{HeaderGithubStar-jwgY8DT_.js → HeaderGithubStar-BlFpjeo_.js} +1 -1
  8. package/dashboard/dist/assets/{IpCheckPage-BAJ9oJk5.js → IpCheckPage-BOdpC7Vz.js} +1 -1
  9. package/dashboard/dist/assets/{LandingPage-Bi7T_UG3.js → LandingPage-BLwuivpe.js} +178 -178
  10. package/dashboard/dist/assets/LeaderboardAvatar-YTyY4aXZ.js +1 -0
  11. package/dashboard/dist/assets/{LeaderboardPage-BMLXmGUV.js → LeaderboardPage-gFR0vPvr.js} +3 -3
  12. package/dashboard/dist/assets/LeaderboardProfileModal-BcWHDNeB.js +32 -0
  13. package/dashboard/dist/assets/LeaderboardProfilePage-Cs8q1bC3.js +1 -0
  14. package/dashboard/dist/assets/{LimitsPage-DFntRPF-.js → LimitsPage-CpJJYTf7.js} +1 -1
  15. package/dashboard/dist/assets/{LocalOnlyNotice-kpOEyGcQ.js → LocalOnlyNotice-CpDbMHwk.js} +1 -1
  16. package/dashboard/dist/assets/{LoginPage-J437b8fG.js → LoginPage-Bt__H6vA.js} +1 -1
  17. package/dashboard/dist/assets/{PopoverPopup-CETYhElJ.js → PopoverPopup-VkUE6Upg.js} +1 -1
  18. package/dashboard/dist/assets/{ProviderIcon-GLSK86ul.js → ProviderIcon-ZR0OqB1p.js} +1 -1
  19. package/dashboard/dist/assets/{SettingsPage-Ce-EIZCo.js → SettingsPage-C84PN3v9.js} +1 -1
  20. package/dashboard/dist/assets/{SkillsPage-BCg2tPe8.js → SkillsPage-ef6zakUe.js} +1 -1
  21. package/dashboard/dist/assets/{WidgetsPage-B8eoNh1B.js → WidgetsPage-DDhU5s8J.js} +1 -1
  22. package/dashboard/dist/assets/{WrappedPage-57yACpcn.js → WrappedPage-CkhfXeDA.js} +1 -1
  23. package/dashboard/dist/assets/{arrow-up-right-kKTEYa77.js → arrow-up-right-DYnM2tgP.js} +1 -1
  24. package/dashboard/dist/assets/check-Bvx0yS_d.js +1 -0
  25. package/dashboard/dist/assets/{chevron-down-CYErdTR9.js → chevron-down-RUhbteo7.js} +1 -1
  26. package/dashboard/dist/assets/{download-CSjtsR81.js → download-DZDad53i.js} +1 -1
  27. package/dashboard/dist/assets/{info-Y0vVD3FZ.js → info-CltCR93q.js} +1 -1
  28. package/dashboard/dist/assets/{main-CrjJx0KR.js → main-DJTTgo6E.js} +14 -13
  29. package/dashboard/dist/assets/main-DwtQoM3t.css +1 -0
  30. package/dashboard/dist/assets/{use-limits-display-prefs-Csc65P9G.js → use-limits-display-prefs-CP4Lbqep.js} +1 -1
  31. package/dashboard/dist/assets/{use-native-settings-BeIgnIwx.js → use-native-settings-BFBncMgz.js} +1 -1
  32. package/dashboard/dist/assets/{use-reduced-motion-DZ7zH0oK.js → use-reduced-motion-CFAKElbg.js} +1 -1
  33. package/dashboard/dist/assets/{use-usage-limits-ClpyKC2F.js → use-usage-limits-DGZzfMZ1.js} +1 -1
  34. package/dashboard/dist/assets/{useCurrency-M999w0v1.js → useCurrency-Dyt-pin3.js} +1 -1
  35. package/dashboard/dist/index.html +2 -2
  36. package/dashboard/dist/share.html +2 -2
  37. package/package.json +1 -1
  38. package/src/lib/pricing/seed-snapshot.json +1 -1
  39. package/src/lib/rollout.js +1 -1
  40. package/dashboard/dist/assets/LeaderboardAvatar-DK4zB40R.js +0 -1
  41. package/dashboard/dist/assets/LeaderboardProfileModal-DgDySCa4.js +0 -32
  42. package/dashboard/dist/assets/LeaderboardProfilePage-BoI-B3yY.js +0 -1
  43. package/dashboard/dist/assets/check-BwEiSCgu.js +0 -1
  44. package/dashboard/dist/assets/main-CvieAP2Q.css +0 -1
@@ -1,10 +1,10 @@
1
- import{r as He,C as $,U as Pl,L as Sr,S as as,a8 as Dl,D as Er,B as kt,Z as Ll,a7 as Il}from"./main-CrjJx0KR.js";import{H as Fl}from"./HeaderGithubStar-jwgY8DT_.js";import{u as Ul}from"./use-reduced-motion-DZ7zH0oK.js";function Nl(){if(typeof window>"u")return!1;const n=window.location.hostname;return n==="localhost"||n==="127.0.0.1"||n==="::1"}function Ol(){return Nl()?"/":"/dashboard"}const ta="183",Bl=0,Ea=1,zl=2,ir=1,Gl=2,yi=3,An=0,At=1,cn=2,un=0,Gn=1,ya=2,ba=3,Ta=4,Vl=5,Nn=100,Hl=101,kl=102,Wl=103,Xl=104,ql=200,Yl=201,jl=202,$l=203,os=204,ls=205,Zl=206,Kl=207,Jl=208,Ql=209,ec=210,tc=211,nc=212,ic=213,rc=214,cs=0,hs=1,us=2,li=3,fs=4,ds=5,ps=6,ms=7,Oo=0,sc=1,ac=2,$t=0,Bo=1,zo=2,Go=3,Vo=4,Ho=5,ko=6,Wo=7,Xo=300,Vn=301,ci=302,yr=303,br=304,pr=306,gs=1e3,hn=1001,_s=1002,xt=1003,oc=1004,Fi=1005,Et=1006,Tr=1007,Bn=1008,It=1009,qo=1010,Yo=1011,Ai=1012,na=1013,Kt=1014,Yt=1015,pn=1016,ia=1017,ra=1018,wi=1020,jo=35902,$o=35899,Zo=1021,Ko=1022,zt=1023,mn=1026,zn=1027,Jo=1028,sa=1029,hi=1030,aa=1031,oa=1033,rr=33776,sr=33777,ar=33778,or=33779,xs=35840,vs=35841,Ms=35842,Ss=35843,Es=36196,ys=37492,bs=37496,Ts=37488,As=37489,ws=37490,Rs=37491,Cs=37808,Ps=37809,Ds=37810,Ls=37811,Is=37812,Fs=37813,Us=37814,Ns=37815,Os=37816,Bs=37817,zs=37818,Gs=37819,Vs=37820,Hs=37821,ks=36492,Ws=36494,Xs=36495,qs=36283,Ys=36284,js=36285,$s=36286,lc=3200,cc=0,hc=1,bn="",Lt="srgb",Hn="srgb-linear",cr="linear",Ke="srgb",qn=7680,Aa=519,uc=512,fc=513,dc=514,la=515,pc=516,mc=517,ca=518,gc=519,wa=35044,Ra="300 es",jt=2e3,hr=2001;function _c(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ur(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function xc(){const n=ur("canvas");return n.style.display="block",n}const Ca={};function Pa(...n){const e="THREE."+n.shift();console.log(e,...n)}function Qo(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Le(...n){n=Qo(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function qe(...n){n=Qo(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function fr(...n){const e=n.join(" ");e in Ca||(Ca[e]=!0,Le(...n))}function vc(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const Mc={[cs]:hs,[us]:ps,[fs]:ms,[li]:ds,[hs]:cs,[ps]:us,[ms]:fs,[ds]:li};class fi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const Mt=["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"],Ar=Math.PI/180,Zs=180/Math.PI;function Ci(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Mt[n&255]+Mt[n>>8&255]+Mt[n>>16&255]+Mt[n>>24&255]+"-"+Mt[e&255]+Mt[e>>8&255]+"-"+Mt[e>>16&15|64]+Mt[e>>24&255]+"-"+Mt[t&63|128]+Mt[t>>8&255]+"-"+Mt[t>>16&255]+Mt[t>>24&255]+Mt[i&255]+Mt[i>>8&255]+Mt[i>>16&255]+Mt[i>>24&255]).toLowerCase()}function ke(n,e,t){return Math.max(e,Math.min(t,n))}function Sc(n,e){return(n%e+e)%e}function wr(n,e,t){return(1-t)*n+t*e}function mi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Tt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class $e{constructor(e=0,t=0){$e.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class di{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],p=i[r+3],h=s[a+0],d=s[a+1],g=s[a+2],v=s[a+3];if(p!==v||l!==h||c!==d||u!==g){let m=l*h+c*d+u*g+p*v;m<0&&(h=-h,d=-d,g=-g,v=-v,m=-m);let f=1-o;if(m<.9995){const S=Math.acos(m),b=Math.sin(S);f=Math.sin(f*S)/b,o=Math.sin(o*S)/b,l=l*f+h*o,c=c*f+d*o,u=u*f+g*o,p=p*f+v*o}else{l=l*f+h*o,c=c*f+d*o,u=u*f+g*o,p=p*f+v*o;const S=1/Math.sqrt(l*l+c*c+u*u+p*p);l*=S,c*=S,u*=S,p*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=p}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],p=s[a],h=s[a+1],d=s[a+2],g=s[a+3];return e[t]=o*g+u*p+l*d-c*h,e[t+1]=l*g+u*h+c*p-o*d,e[t+2]=c*g+u*d+o*h-l*p,e[t+3]=u*g-o*p-l*h-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),p=o(s/2),h=l(i/2),d=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=h*u*p+c*d*g,this._y=c*d*p-h*u*g,this._z=c*u*g+h*d*p,this._w=c*u*p-h*d*g;break;case"YXZ":this._x=h*u*p+c*d*g,this._y=c*d*p-h*u*g,this._z=c*u*g-h*d*p,this._w=c*u*p+h*d*g;break;case"ZXY":this._x=h*u*p-c*d*g,this._y=c*d*p+h*u*g,this._z=c*u*g+h*d*p,this._w=c*u*p-h*d*g;break;case"ZYX":this._x=h*u*p-c*d*g,this._y=c*d*p+h*u*g,this._z=c*u*g-h*d*p,this._w=c*u*p+h*d*g;break;case"YZX":this._x=h*u*p+c*d*g,this._y=c*d*p+h*u*g,this._z=c*u*g-h*d*p,this._w=c*u*p-h*d*g;break;case"XZY":this._x=h*u*p-c*d*g,this._y=c*d*p-h*u*g,this._z=c*u*g+h*d*p,this._w=c*u*p+h*d*g;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],p=t[10],h=i+o+p;if(h>0){const d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-l)*d,this._y=(s-c)*d,this._z=(a-r)*d}else if(i>o&&i>p){const d=2*Math.sqrt(1+i-o-p);this._w=(u-l)/d,this._x=.25*d,this._y=(r+a)/d,this._z=(s+c)/d}else if(o>p){const d=2*Math.sqrt(1+o-i-p);this._w=(s-c)/d,this._x=(r+a)/d,this._y=.25*d,this._z=(l+u)/d}else{const d=2*Math.sqrt(1+p-i-o);this._w=(a-r)/d,this._x=(s+c)/d,this._y=(l+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ke(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{constructor(e=0,t=0,i=0){k.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Da.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Da.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),p=2*(s*i-a*t);return this.x=t+l*c+a*p-o*u,this.y=i+l*u+o*c-s*p,this.z=r+l*p+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Rr.copy(this).projectOnVector(e),this.sub(Rr)}reflect(e){return this.sub(Rr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Rr=new k,Da=new di;class Oe{constructor(e,t,i,r,s,a,o,l,c){Oe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],p=i[7],h=i[2],d=i[5],g=i[8],v=r[0],m=r[3],f=r[6],S=r[1],b=r[4],E=r[7],R=r[2],A=r[5],C=r[8];return s[0]=a*v+o*S+l*R,s[3]=a*m+o*b+l*A,s[6]=a*f+o*E+l*C,s[1]=c*v+u*S+p*R,s[4]=c*m+u*b+p*A,s[7]=c*f+u*E+p*C,s[2]=h*v+d*S+g*R,s[5]=h*m+d*b+g*A,s[8]=h*f+d*E+g*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],p=u*a-o*c,h=o*l-u*s,d=c*s-a*l,g=t*p+i*h+r*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=p*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=h*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=d*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Cr.makeScale(e,t)),this}rotate(e){return this.premultiply(Cr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Cr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Cr=new Oe,La=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ia=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ec(){const n={enabled:!0,workingColorSpace:Hn,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ke&&(r.r=fn(r.r),r.g=fn(r.g),r.b=fn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ke&&(r.r=oi(r.r),r.g=oi(r.g),r.b=oi(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===bn?cr:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return fr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return fr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Hn]:{primaries:e,whitePoint:i,transfer:cr,toXYZ:La,fromXYZ:Ia,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Lt},outputColorSpaceConfig:{drawingBufferColorSpace:Lt}},[Lt]:{primaries:e,whitePoint:i,transfer:Ke,toXYZ:La,fromXYZ:Ia,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Lt}}}),n}const We=Ec();function fn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function oi(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Yn;class yc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Yn===void 0&&(Yn=ur("canvas")),Yn.width=e.width,Yn.height=e.height;const r=Yn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Yn}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ur("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=fn(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(fn(t[i]/255)*255):t[i]=fn(t[i]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let bc=0;class ha{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:bc++}),this.uuid=Ci(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Pr(r[a].image)):s.push(Pr(r[a]))}else s=Pr(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function Pr(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?yc.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Le("Texture: Unable to serialize Texture."),{})}let Tc=0;const Dr=new k;class bt extends fi{constructor(e=bt.DEFAULT_IMAGE,t=bt.DEFAULT_MAPPING,i=hn,r=hn,s=Et,a=Bn,o=zt,l=It,c=bt.DEFAULT_ANISOTROPY,u=bn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tc++}),this.uuid=Ci(),this.name="",this.source=new ha(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new $e(0,0),this.repeat=new $e(1,1),this.center=new $e(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Dr).x}get height(){return this.source.getSize(Dr).y}get depth(){return this.source.getSize(Dr).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Xo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gs:e.x=e.x-Math.floor(e.x);break;case hn:e.x=e.x<0?0:1;break;case _s:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case gs:e.y=e.y-Math.floor(e.y);break;case hn:e.y=e.y<0?0:1;break;case _s:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}bt.DEFAULT_IMAGE=null;bt.DEFAULT_MAPPING=Xo;bt.DEFAULT_ANISOTROPY=1;class ct{constructor(e=0,t=0,i=0,r=1){ct.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],u=l[4],p=l[8],h=l[1],d=l[5],g=l[9],v=l[2],m=l[6],f=l[10];if(Math.abs(u-h)<.01&&Math.abs(p-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(p+v)<.1&&Math.abs(g+m)<.1&&Math.abs(c+d+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,E=(d+1)/2,R=(f+1)/2,A=(u+h)/4,C=(p+v)/4,x=(g+m)/4;return b>E&&b>R?b<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(b),r=A/i,s=C/i):E>R?E<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(E),i=A/r,s=x/r):R<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(R),i=C/s,r=x/s),this.set(i,r,s,t),this}let S=Math.sqrt((m-g)*(m-g)+(p-v)*(p-v)+(h-u)*(h-u));return Math.abs(S)<.001&&(S=1),this.x=(m-g)/S,this.y=(p-v)/S,this.z=(h-u)/S,this.w=Math.acos((c+d+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this.w=ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this.w=ke(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ac extends fi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Et,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:i.depth},s=new bt(r),a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Et,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ha(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zt extends Ac{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class el extends bt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=xt,this.minFilter=xt,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class wc extends bt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=xt,this.minFilter=xt,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ft{constructor(e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m){ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m)}set(e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=u,f[10]=p,f[14]=h,f[3]=d,f[7]=g,f[11]=v,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 ft().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/jn.setFromMatrixColumn(e,0).length(),s=1/jn.setFromMatrixColumn(e,1).length(),a=1/jn.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const h=a*u,d=a*p,g=o*u,v=o*p;t[0]=l*u,t[4]=-l*p,t[8]=c,t[1]=d+g*c,t[5]=h-v*c,t[9]=-o*l,t[2]=v-h*c,t[6]=g+d*c,t[10]=a*l}else if(e.order==="YXZ"){const h=l*u,d=l*p,g=c*u,v=c*p;t[0]=h+v*o,t[4]=g*o-d,t[8]=a*c,t[1]=a*p,t[5]=a*u,t[9]=-o,t[2]=d*o-g,t[6]=v+h*o,t[10]=a*l}else if(e.order==="ZXY"){const h=l*u,d=l*p,g=c*u,v=c*p;t[0]=h-v*o,t[4]=-a*p,t[8]=g+d*o,t[1]=d+g*o,t[5]=a*u,t[9]=v-h*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const h=a*u,d=a*p,g=o*u,v=o*p;t[0]=l*u,t[4]=g*c-d,t[8]=h*c+v,t[1]=l*p,t[5]=v*c+h,t[9]=d*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const h=a*l,d=a*c,g=o*l,v=o*c;t[0]=l*u,t[4]=v-h*p,t[8]=g*p+d,t[1]=p,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=d*p+g,t[10]=h-v*p}else if(e.order==="XZY"){const h=a*l,d=a*c,g=o*l,v=o*c;t[0]=l*u,t[4]=-p,t[8]=c*u,t[1]=h*p+v,t[5]=a*u,t[9]=d*p-g,t[2]=g*p-d,t[6]=o*u,t[10]=v*p+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Rc,e,Cc)}lookAt(e,t,i){const r=this.elements;return Rt.subVectors(e,t),Rt.lengthSq()===0&&(Rt.z=1),Rt.normalize(),xn.crossVectors(i,Rt),xn.lengthSq()===0&&(Math.abs(i.z)===1?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),xn.crossVectors(i,Rt)),xn.normalize(),Ui.crossVectors(Rt,xn),r[0]=xn.x,r[4]=Ui.x,r[8]=Rt.x,r[1]=xn.y,r[5]=Ui.y,r[9]=Rt.y,r[2]=xn.z,r[6]=Ui.z,r[10]=Rt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],p=i[5],h=i[9],d=i[13],g=i[2],v=i[6],m=i[10],f=i[14],S=i[3],b=i[7],E=i[11],R=i[15],A=r[0],C=r[4],x=r[8],y=r[12],G=r[1],w=r[5],F=r[9],N=r[13],L=r[2],B=r[6],H=r[10],O=r[14],J=r[3],Z=r[7],le=r[11],de=r[15];return s[0]=a*A+o*G+l*L+c*J,s[4]=a*C+o*w+l*B+c*Z,s[8]=a*x+o*F+l*H+c*le,s[12]=a*y+o*N+l*O+c*de,s[1]=u*A+p*G+h*L+d*J,s[5]=u*C+p*w+h*B+d*Z,s[9]=u*x+p*F+h*H+d*le,s[13]=u*y+p*N+h*O+d*de,s[2]=g*A+v*G+m*L+f*J,s[6]=g*C+v*w+m*B+f*Z,s[10]=g*x+v*F+m*H+f*le,s[14]=g*y+v*N+m*O+f*de,s[3]=S*A+b*G+E*L+R*J,s[7]=S*C+b*w+E*B+R*Z,s[11]=S*x+b*F+E*H+R*le,s[15]=S*y+b*N+E*O+R*de,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],p=e[6],h=e[10],d=e[14],g=e[3],v=e[7],m=e[11],f=e[15],S=l*d-c*h,b=o*d-c*p,E=o*h-l*p,R=a*d-c*u,A=a*h-l*u,C=a*p-o*u;return t*(v*S-m*b+f*E)-i*(g*S-m*R+f*A)+r*(g*b-v*R+f*C)-s*(g*E-v*A+m*C)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],p=e[9],h=e[10],d=e[11],g=e[12],v=e[13],m=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-p*g,y=u*m-h*g,G=u*f-d*g,w=p*m-h*v,F=p*f-d*v,N=h*f-d*m,L=S*N-b*F+E*w+R*G-A*y+C*x;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/L;return e[0]=(o*N-l*F+c*w)*B,e[1]=(r*F-i*N-s*w)*B,e[2]=(v*C-m*A+f*R)*B,e[3]=(h*A-p*C-d*R)*B,e[4]=(l*G-a*N-c*y)*B,e[5]=(t*N-r*G+s*y)*B,e[6]=(m*E-g*C-f*b)*B,e[7]=(u*C-h*E+d*b)*B,e[8]=(a*F-o*G+c*x)*B,e[9]=(i*G-t*F-s*x)*B,e[10]=(g*A-v*E+f*S)*B,e[11]=(p*E-u*A-d*S)*B,e[12]=(o*y-a*w-l*x)*B,e[13]=(t*w-i*y+r*x)*B,e[14]=(v*b-g*R-m*S)*B,e[15]=(u*R-p*b+h*S)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,p=o+o,h=s*c,d=s*u,g=s*p,v=a*u,m=a*p,f=o*p,S=l*c,b=l*u,E=l*p,R=i.x,A=i.y,C=i.z;return r[0]=(1-(v+f))*R,r[1]=(d+E)*R,r[2]=(g-b)*R,r[3]=0,r[4]=(d-E)*A,r[5]=(1-(h+f))*A,r[6]=(m+S)*A,r[7]=0,r[8]=(g+b)*C,r[9]=(m-S)*C,r[10]=(1-(h+v))*C,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinant();if(s===0)return i.set(1,1,1),t.identity(),this;let a=jn.set(r[0],r[1],r[2]).length();const o=jn.set(r[4],r[5],r[6]).length(),l=jn.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Ut.copy(this);const c=1/a,u=1/o,p=1/l;return Ut.elements[0]*=c,Ut.elements[1]*=c,Ut.elements[2]*=c,Ut.elements[4]*=u,Ut.elements[5]*=u,Ut.elements[6]*=u,Ut.elements[8]*=p,Ut.elements[9]*=p,Ut.elements[10]*=p,t.setFromRotationMatrix(Ut),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,s,a,o=jt,l=!1){const c=this.elements,u=2*s/(t-e),p=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r);let g,v;if(l)g=s/(a-s),v=a*s/(a-s);else if(o===jt)g=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===hr)g=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=p,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=jt,l=!1){const c=this.elements,u=2/(t-e),p=2/(i-r),h=-(t+e)/(t-e),d=-(i+r)/(i-r);let g,v;if(l)g=1/(a-s),v=a/(a-s);else if(o===jt)g=-2/(a-s),v=-(a+s)/(a-s);else if(o===hr)g=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=p,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const jn=new k,Ut=new ft,Rc=new k(0,0,0),Cc=new k(1,1,1),xn=new k,Ui=new k,Rt=new k,Fa=new ft,Ua=new di;let kn=class tl{constructor(e=0,t=0,i=0,r=tl.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],p=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-p,d),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ke(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Fa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Fa,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ua.setFromEuler(this),this.setFromQuaternion(Ua,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};kn.DEFAULT_ORDER="XYZ";class nl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Pc=0;const Na=new k,$n=new di,rn=new ft,Ni=new k,gi=new k,Dc=new k,Lc=new di,Oa=new k(1,0,0),Ba=new k(0,1,0),za=new k(0,0,1),Ga={type:"added"},Ic={type:"removed"},Zn={type:"childadded",child:null},Lr={type:"childremoved",child:null};class Pt extends fi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Pc++}),this.uuid=Ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new k,t=new kn,i=new di,r=new k(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ft},normalMatrix:{value:new Oe}}),this.matrix=new ft,this.matrixWorld=new ft,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nl,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.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return $n.setFromAxisAngle(e,t),this.quaternion.multiply($n),this}rotateOnWorldAxis(e,t){return $n.setFromAxisAngle(e,t),this.quaternion.premultiply($n),this}rotateX(e){return this.rotateOnAxis(Oa,e)}rotateY(e){return this.rotateOnAxis(Ba,e)}rotateZ(e){return this.rotateOnAxis(za,e)}translateOnAxis(e,t){return Na.copy(e).applyQuaternion(this.quaternion),this.position.add(Na.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Oa,e)}translateY(e){return this.translateOnAxis(Ba,e)}translateZ(e){return this.translateOnAxis(za,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(rn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ni.copy(e):Ni.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),gi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rn.lookAt(gi,Ni,this.up):rn.lookAt(Ni,gi,this.up),this.quaternion.setFromRotationMatrix(rn),r&&(rn.extractRotation(r.matrixWorld),$n.setFromRotationMatrix(rn),this.quaternion.premultiply($n.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(qe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ga),Zn.child=e,this.dispatchEvent(Zn),Zn.child=null):qe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ic),Lr.child=e,this.dispatchEvent(Lr),Lr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),rn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),rn.multiply(e.parent.matrixWorld)),e.applyMatrix4(rn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ga),Zn.child=e,this.dispatchEvent(Zn),Zn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gi,e,Dc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gi,Lc,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*r,s[13]+=i-s[1]*t-s[5]*i-s[9]*r,s[14]+=r-s[2]*t-s[6]*i-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const p=l[c];s(e.shapes,p)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),p=a(e.shapes),h=a(e.skeletons),d=a(e.animations),g=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),p.length>0&&(i.shapes=p),h.length>0&&(i.skeletons=h),d.length>0&&(i.animations=d),g.length>0&&(i.nodes=g)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Pt.DEFAULT_UP=new k(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Oi extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Fc={type:"move"};class Ir{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Oi,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 Oi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Oi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),f=this._getHandJoint(c,v);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}const u=c.joints["index-finger-tip"],p=c.joints["thumb-tip"],h=u.position.distanceTo(p.position),d=.02,g=.005;c.inputState.pinching&&h>d+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=d-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Fc)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Oi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const il={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},vn={h:0,s:0,l:0},Bi={h:0,s:0,l:0};function Fr(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class tt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,We.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=We.workingColorSpace){return this.r=e,this.g=t,this.b=i,We.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=We.workingColorSpace){if(e=Sc(e,1),t=ke(t,0,1),i=ke(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Fr(a,s,e+1/3),this.g=Fr(a,s,e),this.b=Fr(a,s,e-1/3)}return We.colorSpaceToWorking(this,r),this}setStyle(e,t=Lt){function i(s){s!==void 0&&parseFloat(s)<1&&Le("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Lt){const i=il[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Le("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fn(e.r),this.g=fn(e.g),this.b=fn(e.b),this}copyLinearToSRGB(e){return this.r=oi(e.r),this.g=oi(e.g),this.b=oi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Lt){return We.workingToColorSpace(St.copy(this),e),Math.round(ke(St.r*255,0,255))*65536+Math.round(ke(St.g*255,0,255))*256+Math.round(ke(St.b*255,0,255))}getHexString(e=Lt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=We.workingColorSpace){We.workingToColorSpace(St.copy(this),t);const i=St.r,r=St.g,s=St.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const p=a-o;switch(c=u<=.5?p/(a+o):p/(2-a-o),a){case i:l=(r-s)/p+(r<s?6:0);break;case r:l=(s-i)/p+2;break;case s:l=(i-r)/p+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=We.workingColorSpace){return We.workingToColorSpace(St.copy(this),t),e.r=St.r,e.g=St.g,e.b=St.b,e}getStyle(e=Lt){We.workingToColorSpace(St.copy(this),e);const t=St.r,i=St.g,r=St.b;return e!==Lt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(vn),this.setHSL(vn.h+e,vn.s+t,vn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(vn),e.getHSL(Bi);const i=wr(vn.h,Bi.h,t),r=wr(vn.s,Bi.s,t),s=wr(vn.l,Bi.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const St=new tt;tt.NAMES=il;class Uc extends Pt{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 kn,this.environmentIntensity=1,this.environmentRotation=new kn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Nt=new k,sn=new k,Ur=new k,an=new k,Kn=new k,Jn=new k,Va=new k,Nr=new k,Or=new k,Br=new k,zr=new ct,Gr=new ct,Vr=new ct;let _i=class ai{constructor(e=new k,t=new k,i=new k){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Nt.subVectors(e,t),r.cross(Nt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Nt.subVectors(r,t),sn.subVectors(i,t),Ur.subVectors(e,t);const a=Nt.dot(Nt),o=Nt.dot(sn),l=Nt.dot(Ur),c=sn.dot(sn),u=sn.dot(Ur),p=a*c-o*o;if(p===0)return s.set(0,0,0),null;const h=1/p,d=(c*l-o*u)*h,g=(a*u-o*l)*h;return s.set(1-d-g,g,d)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,an)===null?!1:an.x>=0&&an.y>=0&&an.x+an.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,an)===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(s,an.x),l.addScaledVector(a,an.y),l.addScaledVector(o,an.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return zr.setScalar(0),Gr.setScalar(0),Vr.setScalar(0),zr.fromBufferAttribute(e,t),Gr.fromBufferAttribute(e,i),Vr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(zr,s.x),a.addScaledVector(Gr,s.y),a.addScaledVector(Vr,s.z),a}static isFrontFacing(e,t,i,r){return Nt.subVectors(i,t),sn.subVectors(e,t),Nt.cross(sn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Nt.subVectors(this.c,this.b),sn.subVectors(this.a,this.b),Nt.cross(sn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ai.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ai.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return ai.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return ai.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ai.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Kn.subVectors(r,i),Jn.subVectors(s,i),Nr.subVectors(e,i);const l=Kn.dot(Nr),c=Jn.dot(Nr);if(l<=0&&c<=0)return t.copy(i);Or.subVectors(e,r);const u=Kn.dot(Or),p=Jn.dot(Or);if(u>=0&&p<=u)return t.copy(r);const h=l*p-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Kn,a);Br.subVectors(e,s);const d=Kn.dot(Br),g=Jn.dot(Br);if(g>=0&&d<=g)return t.copy(s);const v=d*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(Jn,o);const m=u*g-d*p;if(m<=0&&p-u>=0&&d-g>=0)return Va.subVectors(s,r),o=(p-u)/(p-u+(d-g)),t.copy(r).addScaledVector(Va,o);const f=1/(m+v+h);return a=v*f,o=h*f,t.copy(i).addScaledVector(Kn,a).addScaledVector(Jn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Pi{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ot.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ot.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Ot.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ot):Ot.fromBufferAttribute(s,a),Ot.applyMatrix4(e.matrixWorld),this.expandByPoint(Ot);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),zi.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),zi.copy(i.boundingBox)),zi.applyMatrix4(e.matrixWorld),this.union(zi)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ot),Ot.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xi),Gi.subVectors(this.max,xi),Qn.subVectors(e.a,xi),ei.subVectors(e.b,xi),ti.subVectors(e.c,xi),Mn.subVectors(ei,Qn),Sn.subVectors(ti,ei),Cn.subVectors(Qn,ti);let t=[0,-Mn.z,Mn.y,0,-Sn.z,Sn.y,0,-Cn.z,Cn.y,Mn.z,0,-Mn.x,Sn.z,0,-Sn.x,Cn.z,0,-Cn.x,-Mn.y,Mn.x,0,-Sn.y,Sn.x,0,-Cn.y,Cn.x,0];return!Hr(t,Qn,ei,ti,Gi)||(t=[1,0,0,0,1,0,0,0,1],!Hr(t,Qn,ei,ti,Gi))?!1:(Vi.crossVectors(Mn,Sn),t=[Vi.x,Vi.y,Vi.z],Hr(t,Qn,ei,ti,Gi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ot).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ot).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(on[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),on[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),on[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),on[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),on[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),on[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),on[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),on[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(on),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const on=[new k,new k,new k,new k,new k,new k,new k,new k],Ot=new k,zi=new Pi,Qn=new k,ei=new k,ti=new k,Mn=new k,Sn=new k,Cn=new k,xi=new k,Gi=new k,Vi=new k,Pn=new k;function Hr(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Pn.fromArray(n,s);const o=r.x*Math.abs(Pn.x)+r.y*Math.abs(Pn.y)+r.z*Math.abs(Pn.z),l=e.dot(Pn),c=t.dot(Pn),u=i.dot(Pn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const ut=new k,Hi=new $e;let Nc=0;class Vt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Nc++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=wa,this.updateRanges=[],this.gpuType=Yt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Hi.fromBufferAttribute(this,t),Hi.applyMatrix3(e),this.setXY(t,Hi.x,Hi.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix3(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix4(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyNormalMatrix(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.transformDirection(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=mi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Tt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array),s=Tt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==wa&&(e.usage=this.usage),e}}class rl extends Vt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class sl extends Vt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class dn extends Vt{constructor(e,t,i){super(new Float32Array(e),t,i)}}const Oc=new Pi,vi=new k,kr=new k;class ua{constructor(e=new k,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Oc.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vi.subVectors(e,this.center);const t=vi.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(vi,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(kr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vi.copy(e.center).add(kr)),this.expandByPoint(vi.copy(e.center).sub(kr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Bc=0;const Dt=new ft,Wr=new Pt,ni=new k,Ct=new Pi,Mi=new Pi,gt=new k;class en extends fi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Bc++}),this.uuid=Ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(_c(e)?sl:rl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Oe().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Dt.makeRotationFromQuaternion(e),this.applyMatrix4(Dt),this}rotateX(e){return Dt.makeRotationX(e),this.applyMatrix4(Dt),this}rotateY(e){return Dt.makeRotationY(e),this.applyMatrix4(Dt),this}rotateZ(e){return Dt.makeRotationZ(e),this.applyMatrix4(Dt),this}translate(e,t,i){return Dt.makeTranslation(e,t,i),this.applyMatrix4(Dt),this}scale(e,t,i){return Dt.makeScale(e,t,i),this.applyMatrix4(Dt),this}lookAt(e){return Wr.lookAt(e),Wr.updateMatrix(),this.applyMatrix4(Wr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ni).negate(),this.translate(ni.x,ni.y,ni.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new dn(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];Ct.setFromBufferAttribute(s),this.morphTargetsRelative?(gt.addVectors(this.boundingBox.min,Ct.min),this.boundingBox.expandByPoint(gt),gt.addVectors(this.boundingBox.max,Ct.max),this.boundingBox.expandByPoint(gt)):(this.boundingBox.expandByPoint(Ct.min),this.boundingBox.expandByPoint(Ct.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&qe('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 ua);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){const i=this.boundingSphere.center;if(Ct.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Mi.setFromBufferAttribute(o),this.morphTargetsRelative?(gt.addVectors(Ct.min,Mi.min),Ct.expandByPoint(gt),gt.addVectors(Ct.max,Mi.max),Ct.expandByPoint(gt)):(Ct.expandByPoint(Mi.min),Ct.expandByPoint(Mi.max))}Ct.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)gt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(gt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)gt.fromBufferAttribute(o,c),l&&(ni.fromBufferAttribute(e,c),gt.add(ni)),r=Math.max(r,i.distanceToSquared(gt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&qe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Vt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let x=0;x<i.count;x++)o[x]=new k,l[x]=new k;const c=new k,u=new k,p=new k,h=new $e,d=new $e,g=new $e,v=new k,m=new k;function f(x,y,G){c.fromBufferAttribute(i,x),u.fromBufferAttribute(i,y),p.fromBufferAttribute(i,G),h.fromBufferAttribute(s,x),d.fromBufferAttribute(s,y),g.fromBufferAttribute(s,G),u.sub(c),p.sub(c),d.sub(h),g.sub(h);const w=1/(d.x*g.y-g.x*d.y);isFinite(w)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(p,-d.y).multiplyScalar(w),m.copy(p).multiplyScalar(d.x).addScaledVector(u,-g.x).multiplyScalar(w),o[x].add(v),o[y].add(v),o[G].add(v),l[x].add(m),l[y].add(m),l[G].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let x=0,y=S.length;x<y;++x){const G=S[x],w=G.start,F=G.count;for(let N=w,L=w+F;N<L;N+=3)f(e.getX(N+0),e.getX(N+1),e.getX(N+2))}const b=new k,E=new k,R=new k,A=new k;function C(x){R.fromBufferAttribute(r,x),A.copy(R);const y=o[x];b.copy(y),b.sub(R.multiplyScalar(R.dot(y))).normalize(),E.crossVectors(A,y);const w=E.dot(l[x])<0?-1:1;a.setXYZW(x,b.x,b.y,b.z,w)}for(let x=0,y=S.length;x<y;++x){const G=S[x],w=G.start,F=G.count;for(let N=w,L=w+F;N<L;N+=3)C(e.getX(N+0)),C(e.getX(N+1)),C(e.getX(N+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,d=i.count;h<d;h++)i.setXYZ(h,0,0,0);const r=new k,s=new k,a=new k,o=new k,l=new k,c=new k,u=new k,p=new k;if(e)for(let h=0,d=e.count;h<d;h+=3){const g=e.getX(h+0),v=e.getX(h+1),m=e.getX(h+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),u.subVectors(a,s),p.subVectors(r,s),u.cross(p),o.fromBufferAttribute(i,g),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,m),o.add(u),l.add(u),c.add(u),i.setXYZ(g,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let h=0,d=t.count;h<d;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),p.subVectors(r,s),u.cross(p),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)gt.fromBufferAttribute(e,t),gt.normalize(),e.setXYZ(t,gt.x,gt.y,gt.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,p=o.normalized,h=new c.constructor(l.length*u);let d=0,g=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?d=l[v]*o.data.stride+o.offset:d=l[v]*u;for(let f=0;f<u;f++)h[g++]=c[d++]}return new Vt(h,u,p)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new en,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,p=c.length;u<p;u++){const h=c[u],d=e(h,i);l.push(d)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let p=0,h=c.length;p<h;p++){const d=c[p];u.push(d.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],p=s[c];for(let h=0,d=p.length;h<d;h++)u.push(p[h].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const p=a[c];this.addGroup(p.start,p.count,p.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let zc=0;class mr extends fi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zc++}),this.uuid=Ci(),this.name="",this.type="Material",this.blending=Gn,this.side=An,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=os,this.blendDst=ls,this.blendEquation=Nn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new tt(0,0,0),this.blendAlpha=0,this.depthFunc=li,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Aa,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qn,this.stencilZFail=qn,this.stencilZPass=qn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Gn&&(i.blending=this.blending),this.side!==An&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==os&&(i.blendSrc=this.blendSrc),this.blendDst!==ls&&(i.blendDst=this.blendDst),this.blendEquation!==Nn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==li&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Aa&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==qn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==qn&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const ln=new k,Xr=new k,ki=new k,En=new k,qr=new k,Wi=new k,Yr=new k;class Gc{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ln)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ln.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ln.copy(this.origin).addScaledVector(this.direction,t),ln.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Xr.copy(e).add(t).multiplyScalar(.5),ki.copy(t).sub(e).normalize(),En.copy(this.origin).sub(Xr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ki),o=En.dot(this.direction),l=-En.dot(ki),c=En.lengthSq(),u=Math.abs(1-a*a);let p,h,d,g;if(u>0)if(p=a*l-o,h=a*o-l,g=s*u,p>=0)if(h>=-g)if(h<=g){const v=1/u;p*=v,h*=v,d=p*(p+a*h+2*o)+h*(a*p+h+2*l)+c}else h=s,p=Math.max(0,-(a*h+o)),d=-p*p+h*(h+2*l)+c;else h=-s,p=Math.max(0,-(a*h+o)),d=-p*p+h*(h+2*l)+c;else h<=-g?(p=Math.max(0,-(-a*s+o)),h=p>0?-s:Math.min(Math.max(-s,-l),s),d=-p*p+h*(h+2*l)+c):h<=g?(p=0,h=Math.min(Math.max(-s,-l),s),d=h*(h+2*l)+c):(p=Math.max(0,-(a*s+o)),h=p>0?s:Math.min(Math.max(-s,-l),s),d=-p*p+h*(h+2*l)+c);else h=a>0?-s:s,p=Math.max(0,-(a*h+o)),d=-p*p+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(Xr).addScaledVector(ki,h),d}intersectSphere(e,t){ln.subVectors(e.center,this.origin);const i=ln.dot(this.direction),r=ln.dot(ln)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,p=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),p>=0?(o=(e.min.z-h.z)*p,l=(e.max.z-h.z)*p):(o=(e.max.z-h.z)*p,l=(e.min.z-h.z)*p),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,ln)!==null}intersectTriangle(e,t,i,r,s){qr.subVectors(t,e),Wi.subVectors(i,e),Yr.crossVectors(qr,Wi);let a=this.direction.dot(Yr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;En.subVectors(this.origin,e);const l=o*this.direction.dot(Wi.crossVectors(En,Wi));if(l<0)return null;const c=o*this.direction.dot(qr.cross(En));if(c<0||l+c>a)return null;const u=-o*En.dot(Yr);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class al extends mr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tt(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 kn,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ha=new ft,Dn=new Gc,Xi=new ua,ka=new k,qi=new k,Yi=new k,ji=new k,jr=new k,$i=new k,Wa=new k,Zi=new k;let Jt=class extends Pt{constructor(e=new en,t=new al){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){$i.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],p=s[l];u!==0&&(jr.fromBufferAttribute(p,e),a?$i.addScaledVector(jr,u):$i.addScaledVector(jr.sub(t),u))}t.add($i)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Xi.copy(i.boundingSphere),Xi.applyMatrix4(s),Dn.copy(e.ray).recast(e.near),!(Xi.containsPoint(Dn.origin)===!1&&(Dn.intersectSphere(Xi,ka)===null||Dn.origin.distanceToSquared(ka)>(e.far-e.near)**2))&&(Ha.copy(s).invert(),Dn.copy(e.ray).applyMatrix4(Ha),!(i.boundingBox!==null&&Dn.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Dn)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,p=s.attributes.normal,h=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const m=h[g],f=a[m.materialIndex],S=Math.max(m.start,d.start),b=Math.min(o.count,Math.min(m.start+m.count,d.start+d.count));for(let E=S,R=b;E<R;E+=3){const A=o.getX(E),C=o.getX(E+1),x=o.getX(E+2);r=Ki(this,f,e,i,c,u,p,A,C,x),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(o.count,d.start+d.count);for(let m=g,f=v;m<f;m+=3){const S=o.getX(m),b=o.getX(m+1),E=o.getX(m+2);r=Ki(this,a,e,i,c,u,p,S,b,E),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const m=h[g],f=a[m.materialIndex],S=Math.max(m.start,d.start),b=Math.min(l.count,Math.min(m.start+m.count,d.start+d.count));for(let E=S,R=b;E<R;E+=3){const A=E,C=E+1,x=E+2;r=Ki(this,f,e,i,c,u,p,A,C,x),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(l.count,d.start+d.count);for(let m=g,f=v;m<f;m+=3){const S=m,b=m+1,E=m+2;r=Ki(this,a,e,i,c,u,p,S,b,E),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}};function Vc(n,e,t,i,r,s,a,o){let l;if(e.side===At?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===An,o),l===null)return null;Zi.copy(o),Zi.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Zi);return c<t.near||c>t.far?null:{distance:c,point:Zi.clone(),object:n}}function Ki(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,qi),n.getVertexPosition(l,Yi),n.getVertexPosition(c,ji);const u=Vc(n,e,t,i,qi,Yi,ji,Wa);if(u){const p=new k;_i.getBarycoord(Wa,qi,Yi,ji,p),r&&(u.uv=_i.getInterpolatedAttribute(r,o,l,c,p,new $e)),s&&(u.uv1=_i.getInterpolatedAttribute(s,o,l,c,p,new $e)),a&&(u.normal=_i.getInterpolatedAttribute(a,o,l,c,p,new k),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new k,materialIndex:0};_i.getNormal(qi,Yi,ji,h.normal),u.face=h,u.barycoord=p}return u}class Hc extends bt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=xt,u=xt,p,h){super(null,a,o,l,c,u,r,s,p,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $r=new k,kc=new k,Wc=new Oe;class Un{constructor(e=new k(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=$r.subVectors(i,t).cross(kc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta($r),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Wc.getNormalMatrix(e),r=this.coplanarPoint($r).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ln=new ua,Xc=new $e(.5,.5),Ji=new k;class ol{constructor(e=new Un,t=new Un,i=new Un,r=new Un,s=new Un,a=new Un){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=jt,i=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],u=s[4],p=s[5],h=s[6],d=s[7],g=s[8],v=s[9],m=s[10],f=s[11],S=s[12],b=s[13],E=s[14],R=s[15];if(r[0].setComponents(c-a,d-u,f-g,R-S).normalize(),r[1].setComponents(c+a,d+u,f+g,R+S).normalize(),r[2].setComponents(c+o,d+p,f+v,R+b).normalize(),r[3].setComponents(c-o,d-p,f-v,R-b).normalize(),i)r[4].setComponents(l,h,m,E).normalize(),r[5].setComponents(c-l,d-h,f-m,R-E).normalize();else if(r[4].setComponents(c-l,d-h,f-m,R-E).normalize(),t===jt)r[5].setComponents(c+l,d+h,f+m,R+E).normalize();else if(t===hr)r[5].setComponents(l,h,m,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ln.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ln.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ln)}intersectsSprite(e){Ln.center.set(0,0,0);const t=Xc.distanceTo(e.center);return Ln.radius=.7071067811865476+t,Ln.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ln)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Ji.x=r.normal.x>0?e.max.x:e.min.x,Ji.y=r.normal.y>0?e.max.y:e.min.y,Ji.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ji)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ll extends bt{constructor(e=[],t=Vn,i,r,s,a,o,l,c,u){super(e,t,i,r,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ri extends bt{constructor(e,t,i=Kt,r,s,a,o=xt,l=xt,c,u=mn,p=1){if(u!==mn&&u!==zn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:p};super(h,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ha(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class qc extends Ri{constructor(e,t=Kt,i=Vn,r,s,a=xt,o=xt,l,c=mn){const u={width:e,height:e,depth:1},p=[u,u,u,u,u,u];super(e,e,t,i,r,s,a,o,l,c),this.image=p,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class cl extends bt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Di extends en{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],p=[];let h=0,d=0;g("z","y","x",-1,-1,i,t,e,a,s,0),g("z","y","x",1,-1,i,t,-e,a,s,1),g("x","z","y",1,1,e,i,t,r,a,2),g("x","z","y",1,-1,e,i,-t,r,a,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new dn(c,3)),this.setAttribute("normal",new dn(u,3)),this.setAttribute("uv",new dn(p,2));function g(v,m,f,S,b,E,R,A,C,x,y){const G=E/C,w=R/x,F=E/2,N=R/2,L=A/2,B=C+1,H=x+1;let O=0,J=0;const Z=new k;for(let le=0;le<H;le++){const de=le*w-N;for(let ue=0;ue<B;ue++){const Pe=ue*G-F;Z[v]=Pe*S,Z[m]=de*b,Z[f]=L,c.push(Z.x,Z.y,Z.z),Z[v]=0,Z[m]=0,Z[f]=A>0?1:-1,u.push(Z.x,Z.y,Z.z),p.push(ue/C),p.push(1-le/x),O+=1}}for(let le=0;le<x;le++)for(let de=0;de<C;de++){const ue=h+de+B*le,Pe=h+de+B*(le+1),nt=h+(de+1)+B*(le+1),Je=h+(de+1)+B*le;l.push(ue,Pe,Je),l.push(Pe,nt,Je),J+=6}o.addGroup(d,J,y),d+=J,h+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Di(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class gr extends en{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,u=l+1,p=e/o,h=t/l,d=[],g=[],v=[],m=[];for(let f=0;f<u;f++){const S=f*h-a;for(let b=0;b<c;b++){const E=b*p-s;g.push(E,-S,0),v.push(0,0,1),m.push(b/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let S=0;S<o;S++){const b=S+c*f,E=S+c*(f+1),R=S+1+c*(f+1),A=S+1+c*f;d.push(b,E,A),d.push(E,R,A)}this.setIndex(d),this.setAttribute("position",new dn(g,3)),this.setAttribute("normal",new dn(v,3)),this.setAttribute("uv",new dn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gr(e.width,e.height,e.widthSegments,e.heightSegments)}}function ui(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function yt(n){const e={};for(let t=0;t<n.length;t++){const i=ui(n[t]);for(const r in i)e[r]=i[r]}return e}function Yc(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function hl(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:We.workingColorSpace}const jc={clone:ui,merge:yt};var $c=`void main() {
1
+ import{r as He,C as $,U as Pl,T as Dl,L as mi,a8 as Ll,S as Il,D as Er,B as kt,Z as Fl,a7 as Ul}from"./main-DJTTgo6E.js";import{H as Nl}from"./HeaderGithubStar-BlFpjeo_.js";import{u as Ol}from"./use-reduced-motion-CFAKElbg.js";function Bl(){if(typeof window>"u")return!1;const n=window.location.hostname;return n==="localhost"||n==="127.0.0.1"||n==="::1"}function Sa(){return Bl()?"/":"/dashboard"}const ea="183",zl=0,Ea=1,Gl=2,rr=1,Vl=2,bi=3,An=0,At=1,cn=2,un=0,Gn=1,ya=2,ba=3,Ta=4,Hl=5,Nn=100,kl=101,Wl=102,Xl=103,ql=104,Yl=200,jl=201,$l=202,Zl=203,as=204,os=205,Kl=206,Jl=207,Ql=208,ec=209,tc=210,nc=211,ic=212,rc=213,sc=214,ls=0,cs=1,hs=2,li=3,us=4,fs=5,ds=6,ps=7,Oo=0,ac=1,oc=2,$t=0,Bo=1,zo=2,Go=3,Vo=4,Ho=5,ko=6,Wo=7,Xo=300,Vn=301,ci=302,yr=303,br=304,mr=306,ms=1e3,hn=1001,gs=1002,xt=1003,lc=1004,Ui=1005,Et=1006,Tr=1007,Bn=1008,It=1009,qo=1010,Yo=1011,wi=1012,ta=1013,Kt=1014,Yt=1015,pn=1016,na=1017,ia=1018,Ri=1020,jo=35902,$o=35899,Zo=1021,Ko=1022,zt=1023,mn=1026,zn=1027,Jo=1028,ra=1029,hi=1030,sa=1031,aa=1033,sr=33776,ar=33777,or=33778,lr=33779,_s=35840,xs=35841,vs=35842,Ms=35843,Ss=36196,Es=37492,ys=37496,bs=37488,Ts=37489,As=37490,ws=37491,Rs=37808,Cs=37809,Ps=37810,Ds=37811,Ls=37812,Is=37813,Fs=37814,Us=37815,Ns=37816,Os=37817,Bs=37818,zs=37819,Gs=37820,Vs=37821,Hs=36492,ks=36494,Ws=36495,Xs=36283,qs=36284,Ys=36285,js=36286,cc=3200,hc=0,uc=1,bn="",Lt="srgb",Hn="srgb-linear",hr="linear",Ke="srgb",qn=7680,Aa=519,fc=512,dc=513,pc=514,oa=515,mc=516,gc=517,la=518,_c=519,wa=35044,Ra="300 es",jt=2e3,ur=2001;function xc(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function fr(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function vc(){const n=fr("canvas");return n.style.display="block",n}const Ca={};function Pa(...n){const e="THREE."+n.shift();console.log(e,...n)}function Qo(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Le(...n){n=Qo(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function qe(...n){n=Qo(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function dr(...n){const e=n.join(" ");e in Ca||(Ca[e]=!0,Le(...n))}function Mc(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const Sc={[ls]:cs,[hs]:ds,[us]:ps,[li]:fs,[cs]:ls,[ds]:hs,[ps]:us,[fs]:li};class fi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const Mt=["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"],Ar=Math.PI/180,$s=180/Math.PI;function Pi(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Mt[n&255]+Mt[n>>8&255]+Mt[n>>16&255]+Mt[n>>24&255]+"-"+Mt[e&255]+Mt[e>>8&255]+"-"+Mt[e>>16&15|64]+Mt[e>>24&255]+"-"+Mt[t&63|128]+Mt[t>>8&255]+"-"+Mt[t>>16&255]+Mt[t>>24&255]+Mt[i&255]+Mt[i>>8&255]+Mt[i>>16&255]+Mt[i>>24&255]).toLowerCase()}function ke(n,e,t){return Math.max(e,Math.min(t,n))}function Ec(n,e){return(n%e+e)%e}function wr(n,e,t){return(1-t)*n+t*e}function gi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Tt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class $e{constructor(e=0,t=0){$e.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class di{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],u=i[r+2],m=i[r+3],h=s[a+0],p=s[a+1],g=s[a+2],v=s[a+3];if(m!==v||l!==h||c!==p||u!==g){let d=l*h+c*p+u*g+m*v;d<0&&(h=-h,p=-p,g=-g,v=-v,d=-d);let f=1-o;if(d<.9995){const S=Math.acos(d),b=Math.sin(S);f=Math.sin(f*S)/b,o=Math.sin(o*S)/b,l=l*f+h*o,c=c*f+p*o,u=u*f+g*o,m=m*f+v*o}else{l=l*f+h*o,c=c*f+p*o,u=u*f+g*o,m=m*f+v*o;const S=1/Math.sqrt(l*l+c*c+u*u+m*m);l*=S,c*=S,u*=S,m*=S}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=m}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],m=s[a],h=s[a+1],p=s[a+2],g=s[a+3];return e[t]=o*g+u*m+l*p-c*h,e[t+1]=l*g+u*h+c*m-o*p,e[t+2]=c*g+u*p+o*h-l*m,e[t+3]=u*g-o*m-l*h-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(r/2),m=o(s/2),h=l(i/2),p=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=h*u*m+c*p*g,this._y=c*p*m-h*u*g,this._z=c*u*g+h*p*m,this._w=c*u*m-h*p*g;break;case"YXZ":this._x=h*u*m+c*p*g,this._y=c*p*m-h*u*g,this._z=c*u*g-h*p*m,this._w=c*u*m+h*p*g;break;case"ZXY":this._x=h*u*m-c*p*g,this._y=c*p*m+h*u*g,this._z=c*u*g+h*p*m,this._w=c*u*m-h*p*g;break;case"ZYX":this._x=h*u*m-c*p*g,this._y=c*p*m+h*u*g,this._z=c*u*g-h*p*m,this._w=c*u*m+h*p*g;break;case"YZX":this._x=h*u*m+c*p*g,this._y=c*p*m+h*u*g,this._z=c*u*g-h*p*m,this._w=c*u*m-h*p*g;break;case"XZY":this._x=h*u*m-c*p*g,this._y=c*p*m-h*u*g,this._z=c*u*g+h*p*m,this._w=c*u*m+h*p*g;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],m=t[10],h=i+o+m;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(i>o&&i>m){const p=2*Math.sqrt(1+i-o-m);this._w=(u-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>m){const p=2*Math.sqrt(1+o-i-m);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+m-i-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ke(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+r*c-s*l,this._y=r*u+a*l+s*o-i*c,this._z=s*u+a*c+i*l-r*o,this._w=a*u-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class k{constructor(e=0,t=0,i=0){k.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Da.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Da.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),u=2*(o*t-s*r),m=2*(s*i-a*t);return this.x=t+l*c+a*m-o*u,this.y=i+l*u+o*c-s*m,this.z=r+l*m+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Rr.copy(this).projectOnVector(e),this.sub(Rr)}reflect(e){return this.sub(Rr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(ke(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Rr=new k,Da=new di;class Oe{constructor(e,t,i,r,s,a,o,l,c){Oe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],m=i[7],h=i[2],p=i[5],g=i[8],v=r[0],d=r[3],f=r[6],S=r[1],b=r[4],E=r[7],R=r[2],A=r[5],C=r[8];return s[0]=a*v+o*S+l*R,s[3]=a*d+o*b+l*A,s[6]=a*f+o*E+l*C,s[1]=c*v+u*S+m*R,s[4]=c*d+u*b+m*A,s[7]=c*f+u*E+m*C,s[2]=h*v+p*S+g*R,s[5]=h*d+p*b+g*A,s[8]=h*f+p*E+g*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*s*u+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],m=u*a-o*c,h=o*l-u*s,p=c*s-a*l,g=t*m+i*h+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=m*v,e[1]=(r*c-u*i)*v,e[2]=(o*i-r*a)*v,e[3]=h*v,e[4]=(u*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Cr.makeScale(e,t)),this}rotate(e){return this.premultiply(Cr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Cr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Cr=new Oe,La=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ia=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function yc(){const n={enabled:!0,workingColorSpace:Hn,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ke&&(r.r=fn(r.r),r.g=fn(r.g),r.b=fn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ke&&(r.r=oi(r.r),r.g=oi(r.g),r.b=oi(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===bn?hr:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return dr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return dr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Hn]:{primaries:e,whitePoint:i,transfer:hr,toXYZ:La,fromXYZ:Ia,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Lt},outputColorSpaceConfig:{drawingBufferColorSpace:Lt}},[Lt]:{primaries:e,whitePoint:i,transfer:Ke,toXYZ:La,fromXYZ:Ia,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Lt}}}),n}const We=yc();function fn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function oi(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Yn;class bc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Yn===void 0&&(Yn=fr("canvas")),Yn.width=e.width,Yn.height=e.height;const r=Yn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Yn}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=fr("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=fn(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(fn(t[i]/255)*255):t[i]=fn(t[i]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Tc=0;class ca{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Tc++}),this.uuid=Pi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Pr(r[a].image)):s.push(Pr(r[a]))}else s=Pr(r);i.url=s}return t||(e.images[this.uuid]=i),i}}function Pr(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?bc.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Le("Texture: Unable to serialize Texture."),{})}let Ac=0;const Dr=new k;class bt extends fi{constructor(e=bt.DEFAULT_IMAGE,t=bt.DEFAULT_MAPPING,i=hn,r=hn,s=Et,a=Bn,o=zt,l=It,c=bt.DEFAULT_ANISOTROPY,u=bn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ac++}),this.uuid=Pi(),this.name="",this.source=new ca(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new $e(0,0),this.repeat=new $e(1,1),this.center=new $e(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Dr).x}get height(){return this.source.getSize(Dr).y}get depth(){return this.source.getSize(Dr).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Xo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ms:e.x=e.x-Math.floor(e.x);break;case hn:e.x=e.x<0?0:1;break;case gs:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ms:e.y=e.y-Math.floor(e.y);break;case hn:e.y=e.y<0?0:1;break;case gs:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}bt.DEFAULT_IMAGE=null;bt.DEFAULT_MAPPING=Xo;bt.DEFAULT_ANISOTROPY=1;class ct{constructor(e=0,t=0,i=0,r=1){ct.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const l=e.elements,c=l[0],u=l[4],m=l[8],h=l[1],p=l[5],g=l[9],v=l[2],d=l[6],f=l[10];if(Math.abs(u-h)<.01&&Math.abs(m-v)<.01&&Math.abs(g-d)<.01){if(Math.abs(u+h)<.1&&Math.abs(m+v)<.1&&Math.abs(g+d)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,E=(p+1)/2,R=(f+1)/2,A=(u+h)/4,C=(m+v)/4,x=(g+d)/4;return b>E&&b>R?b<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(b),r=A/i,s=C/i):E>R?E<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(E),i=A/r,s=x/r):R<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(R),i=C/s,r=x/s),this.set(i,r,s,t),this}let S=Math.sqrt((d-g)*(d-g)+(m-v)*(m-v)+(h-u)*(h-u));return Math.abs(S)<.001&&(S=1),this.x=(d-g)/S,this.y=(m-v)/S,this.z=(h-u)/S,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ke(this.x,e.x,t.x),this.y=ke(this.y,e.y,t.y),this.z=ke(this.z,e.z,t.z),this.w=ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ke(this.x,e,t),this.y=ke(this.y,e,t),this.z=ke(this.z,e,t),this.w=ke(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ke(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class wc extends fi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Et,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:i.depth},s=new bt(r),a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Et,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ca(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zt extends wc{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class el extends bt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=xt,this.minFilter=xt,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Rc extends bt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=xt,this.minFilter=xt,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ft{constructor(e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d){ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d)}set(e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=u,f[10]=m,f[14]=h,f[3]=p,f[7]=g,f[11]=v,f[15]=d,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 ft().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/jn.setFromMatrixColumn(e,0).length(),s=1/jn.setFromMatrixColumn(e,1).length(),a=1/jn.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),m=Math.sin(s);if(e.order==="XYZ"){const h=a*u,p=a*m,g=o*u,v=o*m;t[0]=l*u,t[4]=-l*m,t[8]=c,t[1]=p+g*c,t[5]=h-v*c,t[9]=-o*l,t[2]=v-h*c,t[6]=g+p*c,t[10]=a*l}else if(e.order==="YXZ"){const h=l*u,p=l*m,g=c*u,v=c*m;t[0]=h+v*o,t[4]=g*o-p,t[8]=a*c,t[1]=a*m,t[5]=a*u,t[9]=-o,t[2]=p*o-g,t[6]=v+h*o,t[10]=a*l}else if(e.order==="ZXY"){const h=l*u,p=l*m,g=c*u,v=c*m;t[0]=h-v*o,t[4]=-a*m,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*u,t[9]=v-h*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const h=a*u,p=a*m,g=o*u,v=o*m;t[0]=l*u,t[4]=g*c-p,t[8]=h*c+v,t[1]=l*m,t[5]=v*c+h,t[9]=p*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const h=a*l,p=a*c,g=o*l,v=o*c;t[0]=l*u,t[4]=v-h*m,t[8]=g*m+p,t[1]=m,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=p*m+g,t[10]=h-v*m}else if(e.order==="XZY"){const h=a*l,p=a*c,g=o*l,v=o*c;t[0]=l*u,t[4]=-m,t[8]=c*u,t[1]=h*m+v,t[5]=a*u,t[9]=p*m-g,t[2]=g*m-p,t[6]=o*u,t[10]=v*m+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Cc,e,Pc)}lookAt(e,t,i){const r=this.elements;return Rt.subVectors(e,t),Rt.lengthSq()===0&&(Rt.z=1),Rt.normalize(),xn.crossVectors(i,Rt),xn.lengthSq()===0&&(Math.abs(i.z)===1?Rt.x+=1e-4:Rt.z+=1e-4,Rt.normalize(),xn.crossVectors(i,Rt)),xn.normalize(),Ni.crossVectors(Rt,xn),r[0]=xn.x,r[4]=Ni.x,r[8]=Rt.x,r[1]=xn.y,r[5]=Ni.y,r[9]=Rt.y,r[2]=xn.z,r[6]=Ni.z,r[10]=Rt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],u=i[1],m=i[5],h=i[9],p=i[13],g=i[2],v=i[6],d=i[10],f=i[14],S=i[3],b=i[7],E=i[11],R=i[15],A=r[0],C=r[4],x=r[8],y=r[12],G=r[1],w=r[5],F=r[9],N=r[13],L=r[2],B=r[6],H=r[10],O=r[14],J=r[3],Z=r[7],le=r[11],de=r[15];return s[0]=a*A+o*G+l*L+c*J,s[4]=a*C+o*w+l*B+c*Z,s[8]=a*x+o*F+l*H+c*le,s[12]=a*y+o*N+l*O+c*de,s[1]=u*A+m*G+h*L+p*J,s[5]=u*C+m*w+h*B+p*Z,s[9]=u*x+m*F+h*H+p*le,s[13]=u*y+m*N+h*O+p*de,s[2]=g*A+v*G+d*L+f*J,s[6]=g*C+v*w+d*B+f*Z,s[10]=g*x+v*F+d*H+f*le,s[14]=g*y+v*N+d*O+f*de,s[3]=S*A+b*G+E*L+R*J,s[7]=S*C+b*w+E*B+R*Z,s[11]=S*x+b*F+E*H+R*le,s[15]=S*y+b*N+E*O+R*de,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],m=e[6],h=e[10],p=e[14],g=e[3],v=e[7],d=e[11],f=e[15],S=l*p-c*h,b=o*p-c*m,E=o*h-l*m,R=a*p-c*u,A=a*h-l*u,C=a*m-o*u;return t*(v*S-d*b+f*E)-i*(g*S-d*R+f*A)+r*(g*b-v*R+f*C)-s*(g*E-v*A+d*C)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],m=e[9],h=e[10],p=e[11],g=e[12],v=e[13],d=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-m*g,y=u*d-h*g,G=u*f-p*g,w=m*d-h*v,F=m*f-p*v,N=h*f-p*d,L=S*N-b*F+E*w+R*G-A*y+C*x;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const B=1/L;return e[0]=(o*N-l*F+c*w)*B,e[1]=(r*F-i*N-s*w)*B,e[2]=(v*C-d*A+f*R)*B,e[3]=(h*A-m*C-p*R)*B,e[4]=(l*G-a*N-c*y)*B,e[5]=(t*N-r*G+s*y)*B,e[6]=(d*E-g*C-f*b)*B,e[7]=(u*C-h*E+p*b)*B,e[8]=(a*F-o*G+c*x)*B,e[9]=(i*G-t*F-s*x)*B,e[10]=(g*A-v*E+f*S)*B,e[11]=(m*E-u*A-p*S)*B,e[12]=(o*y-a*w-l*x)*B,e[13]=(t*w-i*y+r*x)*B,e[14]=(v*b-g*R-d*S)*B,e[15]=(u*R-m*b+h*S)*B,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*a,0,c*l-r*o,u*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,u=a+a,m=o+o,h=s*c,p=s*u,g=s*m,v=a*u,d=a*m,f=o*m,S=l*c,b=l*u,E=l*m,R=i.x,A=i.y,C=i.z;return r[0]=(1-(v+f))*R,r[1]=(p+E)*R,r[2]=(g-b)*R,r[3]=0,r[4]=(p-E)*A,r[5]=(1-(h+f))*A,r[6]=(d+S)*A,r[7]=0,r[8]=(g+b)*C,r[9]=(d-S)*C,r[10]=(1-(h+v))*C,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinant();if(s===0)return i.set(1,1,1),t.identity(),this;let a=jn.set(r[0],r[1],r[2]).length();const o=jn.set(r[4],r[5],r[6]).length(),l=jn.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Ut.copy(this);const c=1/a,u=1/o,m=1/l;return Ut.elements[0]*=c,Ut.elements[1]*=c,Ut.elements[2]*=c,Ut.elements[4]*=u,Ut.elements[5]*=u,Ut.elements[6]*=u,Ut.elements[8]*=m,Ut.elements[9]*=m,Ut.elements[10]*=m,t.setFromRotationMatrix(Ut),i.x=a,i.y=o,i.z=l,this}makePerspective(e,t,i,r,s,a,o=jt,l=!1){const c=this.elements,u=2*s/(t-e),m=2*s/(i-r),h=(t+e)/(t-e),p=(i+r)/(i-r);let g,v;if(l)g=s/(a-s),v=a*s/(a-s);else if(o===jt)g=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===ur)g=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=m,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=jt,l=!1){const c=this.elements,u=2/(t-e),m=2/(i-r),h=-(t+e)/(t-e),p=-(i+r)/(i-r);let g,v;if(l)g=1/(a-s),v=a/(a-s);else if(o===jt)g=-2/(a-s),v=-(a+s)/(a-s);else if(o===ur)g=-1/(a-s),v=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=m,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const jn=new k,Ut=new ft,Cc=new k(0,0,0),Pc=new k(1,1,1),xn=new k,Ni=new k,Rt=new k,Fa=new ft,Ua=new di;let kn=class tl{constructor(e=0,t=0,i=0,r=tl.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],u=r[9],m=r[2],h=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ke(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-m,s),this._z=0);break;case"ZXY":this._x=Math.asin(ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-m,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ke(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-m,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Fa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Fa,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ua.setFromEuler(this),this.setFromQuaternion(Ua,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};kn.DEFAULT_ORDER="XYZ";class nl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Dc=0;const Na=new k,$n=new di,rn=new ft,Oi=new k,_i=new k,Lc=new k,Ic=new di,Oa=new k(1,0,0),Ba=new k(0,1,0),za=new k(0,0,1),Ga={type:"added"},Fc={type:"removed"},Zn={type:"childadded",child:null},Lr={type:"childremoved",child:null};class Pt extends fi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Dc++}),this.uuid=Pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new k,t=new kn,i=new di,r=new k(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ft},normalMatrix:{value:new Oe}}),this.matrix=new ft,this.matrixWorld=new ft,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nl,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.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return $n.setFromAxisAngle(e,t),this.quaternion.multiply($n),this}rotateOnWorldAxis(e,t){return $n.setFromAxisAngle(e,t),this.quaternion.premultiply($n),this}rotateX(e){return this.rotateOnAxis(Oa,e)}rotateY(e){return this.rotateOnAxis(Ba,e)}rotateZ(e){return this.rotateOnAxis(za,e)}translateOnAxis(e,t){return Na.copy(e).applyQuaternion(this.quaternion),this.position.add(Na.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Oa,e)}translateY(e){return this.translateOnAxis(Ba,e)}translateZ(e){return this.translateOnAxis(za,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(rn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Oi.copy(e):Oi.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),_i.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rn.lookAt(_i,Oi,this.up):rn.lookAt(Oi,_i,this.up),this.quaternion.setFromRotationMatrix(rn),r&&(rn.extractRotation(r.matrixWorld),$n.setFromRotationMatrix(rn),this.quaternion.premultiply($n.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(qe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ga),Zn.child=e,this.dispatchEvent(Zn),Zn.child=null):qe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Fc),Lr.child=e,this.dispatchEvent(Lr),Lr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),rn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),rn.multiply(e.parent.matrixWorld)),e.applyMatrix4(rn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ga),Zn.child=e,this.dispatchEvent(Zn),Zn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_i,e,Lc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_i,Ic,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,i=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*r,s[13]+=i-s[1]*t-s[5]*i-s[9]*r,s[14]+=r-s[2]*t-s[6]*i-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const m=l[c];s(e.shapes,m)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),m=a(e.shapes),h=a(e.skeletons),p=a(e.animations),g=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),m.length>0&&(i.shapes=m),h.length>0&&(i.skeletons=h),p.length>0&&(i.animations=p),g.length>0&&(i.nodes=g)}return i.object=r,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Pt.DEFAULT_UP=new k(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Bi extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Uc={type:"move"};class Ir{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bi,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 Bi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const d=t.getJointPose(v,i),f=this._getHandJoint(c,v);d!==null&&(f.matrix.fromArray(d.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=d.radius),f.visible=d!==null}const u=c.joints["index-finger-tip"],m=c.joints["thumb-tip"],h=u.position.distanceTo(m.position),p=.02,g=.005;c.inputState.pinching&&h>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Uc)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Bi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const il={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},vn={h:0,s:0,l:0},zi={h:0,s:0,l:0};function Fr(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class tt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,We.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=We.workingColorSpace){return this.r=e,this.g=t,this.b=i,We.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=We.workingColorSpace){if(e=Ec(e,1),t=ke(t,0,1),i=ke(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Fr(a,s,e+1/3),this.g=Fr(a,s,e),this.b=Fr(a,s,e-1/3)}return We.colorSpaceToWorking(this,r),this}setStyle(e,t=Lt){function i(s){s!==void 0&&parseFloat(s)<1&&Le("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Lt){const i=il[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Le("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fn(e.r),this.g=fn(e.g),this.b=fn(e.b),this}copyLinearToSRGB(e){return this.r=oi(e.r),this.g=oi(e.g),this.b=oi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Lt){return We.workingToColorSpace(St.copy(this),e),Math.round(ke(St.r*255,0,255))*65536+Math.round(ke(St.g*255,0,255))*256+Math.round(ke(St.b*255,0,255))}getHexString(e=Lt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=We.workingColorSpace){We.workingToColorSpace(St.copy(this),t);const i=St.r,r=St.g,s=St.b,a=Math.max(i,r,s),o=Math.min(i,r,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const m=a-o;switch(c=u<=.5?m/(a+o):m/(2-a-o),a){case i:l=(r-s)/m+(r<s?6:0);break;case r:l=(s-i)/m+2;break;case s:l=(i-r)/m+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=We.workingColorSpace){return We.workingToColorSpace(St.copy(this),t),e.r=St.r,e.g=St.g,e.b=St.b,e}getStyle(e=Lt){We.workingToColorSpace(St.copy(this),e);const t=St.r,i=St.g,r=St.b;return e!==Lt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(vn),this.setHSL(vn.h+e,vn.s+t,vn.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(vn),e.getHSL(zi);const i=wr(vn.h,zi.h,t),r=wr(vn.s,zi.s,t),s=wr(vn.l,zi.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const St=new tt;tt.NAMES=il;class Nc extends Pt{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 kn,this.environmentIntensity=1,this.environmentRotation=new kn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Nt=new k,sn=new k,Ur=new k,an=new k,Kn=new k,Jn=new k,Va=new k,Nr=new k,Or=new k,Br=new k,zr=new ct,Gr=new ct,Vr=new ct;let xi=class ai{constructor(e=new k,t=new k,i=new k){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Nt.subVectors(e,t),r.cross(Nt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Nt.subVectors(r,t),sn.subVectors(i,t),Ur.subVectors(e,t);const a=Nt.dot(Nt),o=Nt.dot(sn),l=Nt.dot(Ur),c=sn.dot(sn),u=sn.dot(Ur),m=a*c-o*o;if(m===0)return s.set(0,0,0),null;const h=1/m,p=(c*l-o*u)*h,g=(a*u-o*l)*h;return s.set(1-p-g,g,p)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,an)===null?!1:an.x>=0&&an.y>=0&&an.x+an.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,an)===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(s,an.x),l.addScaledVector(a,an.y),l.addScaledVector(o,an.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return zr.setScalar(0),Gr.setScalar(0),Vr.setScalar(0),zr.fromBufferAttribute(e,t),Gr.fromBufferAttribute(e,i),Vr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(zr,s.x),a.addScaledVector(Gr,s.y),a.addScaledVector(Vr,s.z),a}static isFrontFacing(e,t,i,r){return Nt.subVectors(i,t),sn.subVectors(e,t),Nt.cross(sn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Nt.subVectors(this.c,this.b),sn.subVectors(this.a,this.b),Nt.cross(sn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ai.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ai.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return ai.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return ai.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ai.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;Kn.subVectors(r,i),Jn.subVectors(s,i),Nr.subVectors(e,i);const l=Kn.dot(Nr),c=Jn.dot(Nr);if(l<=0&&c<=0)return t.copy(i);Or.subVectors(e,r);const u=Kn.dot(Or),m=Jn.dot(Or);if(u>=0&&m<=u)return t.copy(r);const h=l*m-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Kn,a);Br.subVectors(e,s);const p=Kn.dot(Br),g=Jn.dot(Br);if(g>=0&&p<=g)return t.copy(s);const v=p*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(Jn,o);const d=u*g-p*m;if(d<=0&&m-u>=0&&p-g>=0)return Va.subVectors(s,r),o=(m-u)/(m-u+(p-g)),t.copy(r).addScaledVector(Va,o);const f=1/(d+v+h);return a=v*f,o=h*f,t.copy(i).addScaledVector(Kn,a).addScaledVector(Jn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Di{constructor(e=new k(1/0,1/0,1/0),t=new k(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ot.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Ot.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Ot.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ot):Ot.fromBufferAttribute(s,a),Ot.applyMatrix4(e.matrixWorld),this.expandByPoint(Ot);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Gi.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Gi.copy(i.boundingBox)),Gi.applyMatrix4(e.matrixWorld),this.union(Gi)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ot),Ot.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(vi),Vi.subVectors(this.max,vi),Qn.subVectors(e.a,vi),ei.subVectors(e.b,vi),ti.subVectors(e.c,vi),Mn.subVectors(ei,Qn),Sn.subVectors(ti,ei),Cn.subVectors(Qn,ti);let t=[0,-Mn.z,Mn.y,0,-Sn.z,Sn.y,0,-Cn.z,Cn.y,Mn.z,0,-Mn.x,Sn.z,0,-Sn.x,Cn.z,0,-Cn.x,-Mn.y,Mn.x,0,-Sn.y,Sn.x,0,-Cn.y,Cn.x,0];return!Hr(t,Qn,ei,ti,Vi)||(t=[1,0,0,0,1,0,0,0,1],!Hr(t,Qn,ei,ti,Vi))?!1:(Hi.crossVectors(Mn,Sn),t=[Hi.x,Hi.y,Hi.z],Hr(t,Qn,ei,ti,Vi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ot).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ot).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(on[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),on[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),on[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),on[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),on[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),on[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),on[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),on[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(on),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const on=[new k,new k,new k,new k,new k,new k,new k,new k],Ot=new k,Gi=new Di,Qn=new k,ei=new k,ti=new k,Mn=new k,Sn=new k,Cn=new k,vi=new k,Vi=new k,Hi=new k,Pn=new k;function Hr(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Pn.fromArray(n,s);const o=r.x*Math.abs(Pn.x)+r.y*Math.abs(Pn.y)+r.z*Math.abs(Pn.z),l=e.dot(Pn),c=t.dot(Pn),u=i.dot(Pn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const ut=new k,ki=new $e;let Oc=0;class Vt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Oc++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=wa,this.updateRanges=[],this.gpuType=Yt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)ki.fromBufferAttribute(this,t),ki.applyMatrix3(e),this.setXY(t,ki.x,ki.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix3(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix4(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.applyNormalMatrix(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ut.fromBufferAttribute(this,t),ut.transformDirection(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=gi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Tt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=gi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=gi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=gi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=gi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Tt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Tt(t,this.array),i=Tt(i,this.array),r=Tt(r,this.array),s=Tt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==wa&&(e.usage=this.usage),e}}class rl extends Vt{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class sl extends Vt{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class dn extends Vt{constructor(e,t,i){super(new Float32Array(e),t,i)}}const Bc=new Di,Mi=new k,kr=new k;class ha{constructor(e=new k,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Bc.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Mi.subVectors(e,this.center);const t=Mi.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Mi,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(kr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mi.copy(e.center).add(kr)),this.expandByPoint(Mi.copy(e.center).sub(kr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let zc=0;const Dt=new ft,Wr=new Pt,ni=new k,Ct=new Di,Si=new Di,gt=new k;class en extends fi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zc++}),this.uuid=Pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(xc(e)?sl:rl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Oe().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Dt.makeRotationFromQuaternion(e),this.applyMatrix4(Dt),this}rotateX(e){return Dt.makeRotationX(e),this.applyMatrix4(Dt),this}rotateY(e){return Dt.makeRotationY(e),this.applyMatrix4(Dt),this}rotateZ(e){return Dt.makeRotationZ(e),this.applyMatrix4(Dt),this}translate(e,t,i){return Dt.makeTranslation(e,t,i),this.applyMatrix4(Dt),this}scale(e,t,i){return Dt.makeScale(e,t,i),this.applyMatrix4(Dt),this}lookAt(e){return Wr.lookAt(e),Wr.updateMatrix(),this.applyMatrix4(Wr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ni).negate(),this.translate(ni.x,ni.y,ni.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new dn(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Di);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const s=t[i];Ct.setFromBufferAttribute(s),this.morphTargetsRelative?(gt.addVectors(this.boundingBox.min,Ct.min),this.boundingBox.expandByPoint(gt),gt.addVectors(this.boundingBox.max,Ct.max),this.boundingBox.expandByPoint(gt)):(this.boundingBox.expandByPoint(Ct.min),this.boundingBox.expandByPoint(Ct.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&qe('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 ha);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){const i=this.boundingSphere.center;if(Ct.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Si.setFromBufferAttribute(o),this.morphTargetsRelative?(gt.addVectors(Ct.min,Si.min),Ct.expandByPoint(gt),gt.addVectors(Ct.max,Si.max),Ct.expandByPoint(gt)):(Ct.expandByPoint(Si.min),Ct.expandByPoint(Si.max))}Ct.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)gt.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(gt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)gt.fromBufferAttribute(o,c),l&&(ni.fromBufferAttribute(e,c),gt.add(ni)),r=Math.max(r,i.distanceToSquared(gt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&qe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Vt(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let x=0;x<i.count;x++)o[x]=new k,l[x]=new k;const c=new k,u=new k,m=new k,h=new $e,p=new $e,g=new $e,v=new k,d=new k;function f(x,y,G){c.fromBufferAttribute(i,x),u.fromBufferAttribute(i,y),m.fromBufferAttribute(i,G),h.fromBufferAttribute(s,x),p.fromBufferAttribute(s,y),g.fromBufferAttribute(s,G),u.sub(c),m.sub(c),p.sub(h),g.sub(h);const w=1/(p.x*g.y-g.x*p.y);isFinite(w)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(m,-p.y).multiplyScalar(w),d.copy(m).multiplyScalar(p.x).addScaledVector(u,-g.x).multiplyScalar(w),o[x].add(v),o[y].add(v),o[G].add(v),l[x].add(d),l[y].add(d),l[G].add(d))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let x=0,y=S.length;x<y;++x){const G=S[x],w=G.start,F=G.count;for(let N=w,L=w+F;N<L;N+=3)f(e.getX(N+0),e.getX(N+1),e.getX(N+2))}const b=new k,E=new k,R=new k,A=new k;function C(x){R.fromBufferAttribute(r,x),A.copy(R);const y=o[x];b.copy(y),b.sub(R.multiplyScalar(R.dot(y))).normalize(),E.crossVectors(A,y);const w=E.dot(l[x])<0?-1:1;a.setXYZW(x,b.x,b.y,b.z,w)}for(let x=0,y=S.length;x<y;++x){const G=S[x],w=G.start,F=G.count;for(let N=w,L=w+F;N<L;N+=3)C(e.getX(N+0)),C(e.getX(N+1)),C(e.getX(N+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,p=i.count;h<p;h++)i.setXYZ(h,0,0,0);const r=new k,s=new k,a=new k,o=new k,l=new k,c=new k,u=new k,m=new k;if(e)for(let h=0,p=e.count;h<p;h+=3){const g=e.getX(h+0),v=e.getX(h+1),d=e.getX(h+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,d),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),o.fromBufferAttribute(i,g),l.fromBufferAttribute(i,v),c.fromBufferAttribute(i,d),o.add(u),l.add(u),c.add(u),i.setXYZ(g,o.x,o.y,o.z),i.setXYZ(v,l.x,l.y,l.z),i.setXYZ(d,c.x,c.y,c.z)}else for(let h=0,p=t.count;h<p;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)gt.fromBufferAttribute(e,t),gt.normalize(),e.setXYZ(t,gt.x,gt.y,gt.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,m=o.normalized,h=new c.constructor(l.length*u);let p=0,g=0;for(let v=0,d=l.length;v<d;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*u;for(let f=0;f<u;f++)h[g++]=c[p++]}return new Vt(h,u,m)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new en,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,m=c.length;u<m;u++){const h=c[u],p=e(h,i);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let m=0,h=c.length;m<h;m++){const p=c[m];u.push(p.toJSON(e.data))}u.length>0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],m=s[c];for(let h=0,p=m.length;h<p;h++)u.push(m[h].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const m=a[c];this.addGroup(m.start,m.count,m.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Gc=0;class gr extends fi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gc++}),this.uuid=Pi(),this.name="",this.type="Material",this.blending=Gn,this.side=An,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=as,this.blendDst=os,this.blendEquation=Nn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new tt(0,0,0),this.blendAlpha=0,this.depthFunc=li,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Aa,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qn,this.stencilZFail=qn,this.stencilZPass=qn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Gn&&(i.blending=this.blending),this.side!==An&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==as&&(i.blendSrc=this.blendSrc),this.blendDst!==os&&(i.blendDst=this.blendDst),this.blendEquation!==Nn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==li&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Aa&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qn&&(i.stencilFail=this.stencilFail),this.stencilZFail!==qn&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==qn&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const ln=new k,Xr=new k,Wi=new k,En=new k,qr=new k,Xi=new k,Yr=new k;class Vc{constructor(e=new k,t=new k(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ln)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ln.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ln.copy(this.origin).addScaledVector(this.direction,t),ln.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Xr.copy(e).add(t).multiplyScalar(.5),Wi.copy(t).sub(e).normalize(),En.copy(this.origin).sub(Xr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Wi),o=En.dot(this.direction),l=-En.dot(Wi),c=En.lengthSq(),u=Math.abs(1-a*a);let m,h,p,g;if(u>0)if(m=a*l-o,h=a*o-l,g=s*u,m>=0)if(h>=-g)if(h<=g){const v=1/u;m*=v,h*=v,p=m*(m+a*h+2*o)+h*(a*m+h+2*l)+c}else h=s,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*l)+c;else h=-s,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*l)+c;else h<=-g?(m=Math.max(0,-(-a*s+o)),h=m>0?-s:Math.min(Math.max(-s,-l),s),p=-m*m+h*(h+2*l)+c):h<=g?(m=0,h=Math.min(Math.max(-s,-l),s),p=h*(h+2*l)+c):(m=Math.max(0,-(a*s+o)),h=m>0?s:Math.min(Math.max(-s,-l),s),p=-m*m+h*(h+2*l)+c);else h=a>0?-s:s,m=Math.max(0,-(a*h+o)),p=-m*m+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(Xr).addScaledVector(Wi,h),p}intersectSphere(e,t){ln.subVectors(e.center,this.origin);const i=ln.dot(this.direction),r=ln.dot(ln)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,m=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),m>=0?(o=(e.min.z-h.z)*m,l=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,l=(e.min.z-h.z)*m),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,ln)!==null}intersectTriangle(e,t,i,r,s){qr.subVectors(t,e),Xi.subVectors(i,e),Yr.crossVectors(qr,Xi);let a=this.direction.dot(Yr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;En.subVectors(this.origin,e);const l=o*this.direction.dot(Xi.crossVectors(En,Xi));if(l<0)return null;const c=o*this.direction.dot(qr.cross(En));if(c<0||l+c>a)return null;const u=-o*En.dot(Yr);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class al extends gr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tt(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 kn,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ha=new ft,Dn=new Vc,qi=new ha,ka=new k,Yi=new k,ji=new k,$i=new k,jr=new k,Zi=new k,Wa=new k,Ki=new k;let Jt=class extends Pt{constructor(e=new en,t=new al){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Zi.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],m=s[l];u!==0&&(jr.fromBufferAttribute(m,e),a?Zi.addScaledVector(jr,u):Zi.addScaledVector(jr.sub(t),u))}t.add(Zi)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),qi.copy(i.boundingSphere),qi.applyMatrix4(s),Dn.copy(e.ray).recast(e.near),!(qi.containsPoint(Dn.origin)===!1&&(Dn.intersectSphere(qi,ka)===null||Dn.origin.distanceToSquared(ka)>(e.far-e.near)**2))&&(Ha.copy(s).invert(),Dn.copy(e.ray).applyMatrix4(Ha),!(i.boundingBox!==null&&Dn.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Dn)))}_computeIntersections(e,t,i){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,m=s.attributes.normal,h=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const d=h[g],f=a[d.materialIndex],S=Math.max(d.start,p.start),b=Math.min(o.count,Math.min(d.start+d.count,p.start+p.count));for(let E=S,R=b;E<R;E+=3){const A=o.getX(E),C=o.getX(E+1),x=o.getX(E+2);r=Ji(this,f,e,i,c,u,m,A,C,x),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=d.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let d=g,f=v;d<f;d+=3){const S=o.getX(d),b=o.getX(d+1),E=o.getX(d+2);r=Ji(this,a,e,i,c,u,m,S,b,E),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,v=h.length;g<v;g++){const d=h[g],f=a[d.materialIndex],S=Math.max(d.start,p.start),b=Math.min(l.count,Math.min(d.start+d.count,p.start+p.count));for(let E=S,R=b;E<R;E+=3){const A=E,C=E+1,x=E+2;r=Ji(this,f,e,i,c,u,m,A,C,x),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=d.materialIndex,t.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let d=g,f=v;d<f;d+=3){const S=d,b=d+1,E=d+2;r=Ji(this,a,e,i,c,u,m,S,b,E),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}};function Hc(n,e,t,i,r,s,a,o){let l;if(e.side===At?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===An,o),l===null)return null;Ki.copy(o),Ki.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Ki);return c<t.near||c>t.far?null:{distance:c,point:Ki.clone(),object:n}}function Ji(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,Yi),n.getVertexPosition(l,ji),n.getVertexPosition(c,$i);const u=Hc(n,e,t,i,Yi,ji,$i,Wa);if(u){const m=new k;xi.getBarycoord(Wa,Yi,ji,$i,m),r&&(u.uv=xi.getInterpolatedAttribute(r,o,l,c,m,new $e)),s&&(u.uv1=xi.getInterpolatedAttribute(s,o,l,c,m,new $e)),a&&(u.normal=xi.getInterpolatedAttribute(a,o,l,c,m,new k),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new k,materialIndex:0};xi.getNormal(Yi,ji,$i,h.normal),u.face=h,u.barycoord=m}return u}class kc extends bt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=xt,u=xt,m,h){super(null,a,o,l,c,u,r,s,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $r=new k,Wc=new k,Xc=new Oe;class Un{constructor(e=new k(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=$r.subVectors(i,t).cross(Wc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta($r),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Xc.getNormalMatrix(e),r=this.coplanarPoint($r).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ln=new ha,qc=new $e(.5,.5),Qi=new k;class ol{constructor(e=new Un,t=new Un,i=new Un,r=new Un,s=new Un,a=new Un){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=jt,i=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],u=s[4],m=s[5],h=s[6],p=s[7],g=s[8],v=s[9],d=s[10],f=s[11],S=s[12],b=s[13],E=s[14],R=s[15];if(r[0].setComponents(c-a,p-u,f-g,R-S).normalize(),r[1].setComponents(c+a,p+u,f+g,R+S).normalize(),r[2].setComponents(c+o,p+m,f+v,R+b).normalize(),r[3].setComponents(c-o,p-m,f-v,R-b).normalize(),i)r[4].setComponents(l,h,d,E).normalize(),r[5].setComponents(c-l,p-h,f-d,R-E).normalize();else if(r[4].setComponents(c-l,p-h,f-d,R-E).normalize(),t===jt)r[5].setComponents(c+l,p+h,f+d,R+E).normalize();else if(t===ur)r[5].setComponents(l,h,d,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ln.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ln.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ln)}intersectsSprite(e){Ln.center.set(0,0,0);const t=qc.distanceTo(e.center);return Ln.radius=.7071067811865476+t,Ln.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ln)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Qi.x=r.normal.x>0?e.max.x:e.min.x,Qi.y=r.normal.y>0?e.max.y:e.min.y,Qi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Qi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ll extends bt{constructor(e=[],t=Vn,i,r,s,a,o,l,c,u){super(e,t,i,r,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ci extends bt{constructor(e,t,i=Kt,r,s,a,o=xt,l=xt,c,u=mn,m=1){if(u!==mn&&u!==zn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:m};super(h,r,s,a,o,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ca(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Yc extends Ci{constructor(e,t=Kt,i=Vn,r,s,a=xt,o=xt,l,c=mn){const u={width:e,height:e,depth:1},m=[u,u,u,u,u,u];super(e,e,t,i,r,s,a,o,l,c),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class cl extends bt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Li extends en{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],m=[];let h=0,p=0;g("z","y","x",-1,-1,i,t,e,a,s,0),g("z","y","x",1,-1,i,t,-e,a,s,1),g("x","z","y",1,1,e,i,t,r,a,2),g("x","z","y",1,-1,e,i,-t,r,a,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new dn(c,3)),this.setAttribute("normal",new dn(u,3)),this.setAttribute("uv",new dn(m,2));function g(v,d,f,S,b,E,R,A,C,x,y){const G=E/C,w=R/x,F=E/2,N=R/2,L=A/2,B=C+1,H=x+1;let O=0,J=0;const Z=new k;for(let le=0;le<H;le++){const de=le*w-N;for(let ue=0;ue<B;ue++){const Pe=ue*G-F;Z[v]=Pe*S,Z[d]=de*b,Z[f]=L,c.push(Z.x,Z.y,Z.z),Z[v]=0,Z[d]=0,Z[f]=A>0?1:-1,u.push(Z.x,Z.y,Z.z),m.push(ue/C),m.push(1-le/x),O+=1}}for(let le=0;le<x;le++)for(let de=0;de<C;de++){const ue=h+de+B*le,Pe=h+de+B*(le+1),nt=h+(de+1)+B*(le+1),Je=h+(de+1)+B*le;l.push(ue,Pe,Je),l.push(Pe,nt,Je),J+=6}o.addGroup(p,J,y),p+=J,h+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Li(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class _r extends en{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,u=l+1,m=e/o,h=t/l,p=[],g=[],v=[],d=[];for(let f=0;f<u;f++){const S=f*h-a;for(let b=0;b<c;b++){const E=b*m-s;g.push(E,-S,0),v.push(0,0,1),d.push(b/o),d.push(1-f/l)}}for(let f=0;f<l;f++)for(let S=0;S<o;S++){const b=S+c*f,E=S+c*(f+1),R=S+1+c*(f+1),A=S+1+c*f;p.push(b,E,A),p.push(E,R,A)}this.setIndex(p),this.setAttribute("position",new dn(g,3)),this.setAttribute("normal",new dn(v,3)),this.setAttribute("uv",new dn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _r(e.width,e.height,e.widthSegments,e.heightSegments)}}function ui(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function yt(n){const e={};for(let t=0;t<n.length;t++){const i=ui(n[t]);for(const r in i)e[r]=i[r]}return e}function jc(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function hl(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:We.workingColorSpace}const $c={clone:ui,merge:yt};var Zc=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,Zc=`void main() {
3
+ }`,Kc=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`;class Qt extends mr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=$c,this.fragmentShader=Zc,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ui(e.uniforms),this.uniformsGroups=Yc(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class ul extends Qt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Kc extends mr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=lc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Jc extends mr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Qi=new k,er=new di,Wt=new k;class fl extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ft,this.projectionMatrix=new ft,this.projectionMatrixInverse=new ft,this.coordinateSystem=jt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Qi,er,Wt),Wt.x===1&&Wt.y===1&&Wt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Qi,er,Wt.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(Qi,er,Wt),Wt.x===1&&Wt.y===1&&Wt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Qi,er,Wt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const yn=new k,Xa=new $e,qa=new $e;class Bt extends fl{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Zs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ar*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Zs*2*Math.atan(Math.tan(Ar*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yn.x,yn.y).multiplyScalar(-e/yn.z),yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(yn.x,yn.y).multiplyScalar(-e/yn.z)}getViewSize(e,t){return this.getViewBounds(e,Xa,qa),t.subVectors(qa,Xa)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ar*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class fa extends fl{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const ii=-90,ri=1;class Qc extends Pt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Bt(ii,ri,e,t);r.layers=this.layers,this.add(r);const s=new Bt(ii,ri,e,t);s.layers=this.layers,this.add(s);const a=new Bt(ii,ri,e,t);a.layers=this.layers,this.add(a);const o=new Bt(ii,ri,e,t);o.layers=this.layers,this.add(o);const l=new Bt(ii,ri,e,t);l.layers=this.layers,this.add(l);const c=new Bt(ii,ri,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===jt)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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(e===hr)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,p=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(p,h,d),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class eh extends Bt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Le("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}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 e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Ya(n,e,t,i){const r=nh(i);switch(t){case Zo:return n*e;case Jo:return n*e/r.components*r.byteLength;case sa:return n*e/r.components*r.byteLength;case hi:return n*e*2/r.components*r.byteLength;case aa:return n*e*2/r.components*r.byteLength;case Ko:return n*e*3/r.components*r.byteLength;case zt:return n*e*4/r.components*r.byteLength;case oa:return n*e*4/r.components*r.byteLength;case rr:case sr:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ar:case or:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case vs:case Ss:return Math.max(n,16)*Math.max(e,8)/4;case xs:case Ms:return Math.max(n,8)*Math.max(e,8)/2;case Es:case ys:case Ts:case As:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case bs:case ws:case Rs:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Cs:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ps:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ds:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Ls:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Is:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Fs:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Us:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ns:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Os:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Bs:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case zs:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Gs:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Vs:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Hs:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case ks:case Ws:case Xs:return Math.ceil(n/4)*Math.ceil(e/4)*16;case qs:case Ys:return Math.ceil(n/4)*Math.ceil(e/4)*8;case js:case $s:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function nh(n){switch(n){case It:case qo:return{byteLength:1,components:1};case Ai:case Yo:case pn:return{byteLength:2,components:1};case ia:case ra:return{byteLength:2,components:4};case Kt:case na:case Yt:return{byteLength:4,components:1};case jo:case $o:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ta}}));typeof window<"u"&&(window.__THREE__?Le("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ta);function dl(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function ih(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,p=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let d;if(c instanceof Float32Array)d=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)d=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?d=n.HALF_FLOAT:d=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)d=n.SHORT;else if(c instanceof Uint32Array)d=n.UNSIGNED_INT;else if(c instanceof Int32Array)d=n.INT;else if(c instanceof Int8Array)d=n.BYTE;else if(c instanceof Uint8Array)d=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)d=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:d,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:p}}function i(o,l,c){const u=l.array,p=l.updateRanges;if(n.bindBuffer(c,o),p.length===0)n.bufferSubData(c,0,u);else{p.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<p.length;d++){const g=p[h],v=p[d];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++h,p[h]=v)}p.length=h+1;for(let d=0,g=p.length;d<g;d++){const v=p[d];n.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(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.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var rh=`#ifdef USE_ALPHAHASH
5
+ }`;class Qt extends gr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zc,this.fragmentShader=Kc,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ui(e.uniforms),this.uniformsGroups=jc(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class ul extends Qt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Jc extends gr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Qc extends gr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const er=new k,tr=new di,Wt=new k;class fl extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ft,this.projectionMatrix=new ft,this.projectionMatrixInverse=new ft,this.coordinateSystem=jt,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(er,tr,Wt),Wt.x===1&&Wt.y===1&&Wt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(er,tr,Wt.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(er,tr,Wt),Wt.x===1&&Wt.y===1&&Wt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(er,tr,Wt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const yn=new k,Xa=new $e,qa=new $e;class Bt extends fl{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$s*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ar*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $s*2*Math.atan(Math.tan(Ar*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yn.x,yn.y).multiplyScalar(-e/yn.z),yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(yn.x,yn.y).multiplyScalar(-e/yn.z)}getViewSize(e,t){return this.getViewBounds(e,Xa,qa),t.subVectors(qa,Xa)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ar*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class ua extends fl{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const ii=-90,ri=1;class eh extends Pt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Bt(ii,ri,e,t);r.layers=this.layers,this.add(r);const s=new Bt(ii,ri,e,t);s.layers=this.layers,this.add(s);const a=new Bt(ii,ri,e,t);a.layers=this.layers,this.add(a);const o=new Bt(ii,ri,e,t);o.layers=this.layers,this.add(o);const l=new Bt(ii,ri,e,t);l.layers=this.layers,this.add(l);const c=new Bt(ii,ri,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===jt)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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(e===ur)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let d=!1;e.isWebGLRenderer===!0?d=e.state.buffers.depth.getReversed():d=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,r),d&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(m,h,p),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class th extends Bt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class nh{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Le("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}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 e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Ya(n,e,t,i){const r=ih(i);switch(t){case Zo:return n*e;case Jo:return n*e/r.components*r.byteLength;case ra:return n*e/r.components*r.byteLength;case hi:return n*e*2/r.components*r.byteLength;case sa:return n*e*2/r.components*r.byteLength;case Ko:return n*e*3/r.components*r.byteLength;case zt:return n*e*4/r.components*r.byteLength;case aa:return n*e*4/r.components*r.byteLength;case sr:case ar:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case or:case lr:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case xs:case Ms:return Math.max(n,16)*Math.max(e,8)/4;case _s:case vs:return Math.max(n,8)*Math.max(e,8)/2;case Ss:case Es:case bs:case Ts:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ys:case As:case ws:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Rs:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Cs:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ps:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Ds:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Ls:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Is:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Fs:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Us:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Ns:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Os:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Bs:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case zs:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Gs:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Vs:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Hs:case ks:case Ws:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Xs:case qs:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ys:case js:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ih(n){switch(n){case It:case qo:return{byteLength:1,components:1};case wi:case Yo:case pn:return{byteLength:2,components:1};case na:case ia:return{byteLength:2,components:4};case Kt:case ta:case Yt:return{byteLength:4,components:1};case jo:case $o:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ea}}));typeof window<"u"&&(window.__THREE__?Le("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ea);function dl(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function rh(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,m=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:m}}function i(o,l,c){const u=l.array,m=l.updateRanges;if(n.bindBuffer(c,o),m.length===0)n.bufferSubData(c,0,u);else{m.sort((p,g)=>p.start-g.start);let h=0;for(let p=1;p<m.length;p++){const g=m[h],v=m[p];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++h,m[h]=v)}m.length=h+1;for(let p=0,g=m.length;p<g;p++){const v=m[p];n.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(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.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var sh=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,sh=`#ifdef USE_ALPHAHASH
7
+ #endif`,ah=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
9
9
  float hash2D( vec2 value ) {
10
10
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -39,20 +39,20 @@ import{r as He,C as $,U as Pl,L as Sr,S as as,a8 as Dl,D as Er,B as kt,Z as Ll,a
39
39
  : cases.z;
40
40
  return clamp( threshold , 1.0e-6, 1.0 );
41
41
  }
42
- #endif`,ah=`#ifdef USE_ALPHAMAP
43
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
42
  #endif`,oh=`#ifdef USE_ALPHAMAP
43
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
+ #endif`,lh=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,lh=`#ifdef USE_ALPHATEST
46
+ #endif`,ch=`#ifdef USE_ALPHATEST
47
47
  #ifdef ALPHA_TO_COVERAGE
48
48
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
49
49
  if ( diffuseColor.a == 0.0 ) discard;
50
50
  #else
51
51
  if ( diffuseColor.a < alphaTest ) discard;
52
52
  #endif
53
- #endif`,ch=`#ifdef USE_ALPHATEST
53
+ #endif`,hh=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,hh=`#ifdef USE_AOMAP
55
+ #endif`,uh=`#ifdef USE_AOMAP
56
56
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
57
57
  reflectedLight.indirectDiffuse *= ambientOcclusion;
58
58
  #if defined( USE_CLEARCOAT )
@@ -65,10 +65,10 @@ import{r as He,C as $,U as Pl,L as Sr,S as as,a8 as Dl,D as Er,B as kt,Z as Ll,a
65
65
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
66
66
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
67
67
  #endif
68
- #endif`,uh=`#ifdef USE_AOMAP
68
+ #endif`,fh=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,fh=`#ifdef USE_BATCHING
71
+ #endif`,dh=`#ifdef USE_BATCHING
72
72
  #if ! defined( GL_ANGLE_multi_draw )
73
73
  #define gl_DrawID _gl_DrawID
74
74
  uniform int _gl_DrawID;
@@ -102,15 +102,15 @@ import{r as He,C as $,U as Pl,L as Sr,S as as,a8 as Dl,D as Er,B as kt,Z as Ll,a
102
102
  int y = j / size;
103
103
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
104
104
  }
105
- #endif`,dh=`#ifdef USE_BATCHING
105
+ #endif`,ph=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,ph=`vec3 transformed = vec3( position );
107
+ #endif`,mh=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,mh=`vec3 objectNormal = vec3( normal );
110
+ #endif`,gh=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,gh=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,_h=`float G_BlinnPhong_Implicit( ) {
114
114
  return 0.25;
115
115
  }
116
116
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
124
124
  float G = G_BlinnPhong_Implicit( );
125
125
  float D = D_BlinnPhong( shininess, dotNH );
126
126
  return F * ( G * D );
127
- } // validated`,_h=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,xh=`#ifdef USE_IRIDESCENCE
128
128
  const mat3 XYZ_TO_REC709 = mat3(
129
129
  3.2404542, -0.9692660, 0.0556434,
130
130
  -1.5371385, 1.8760108, -0.2040259,
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
187
187
  }
188
188
  return max( I, vec3( 0.0 ) );
189
189
  }
190
- #endif`,xh=`#ifdef USE_BUMPMAP
190
+ #endif`,vh=`#ifdef USE_BUMPMAP
191
191
  uniform sampler2D bumpMap;
192
192
  uniform float bumpScale;
193
193
  vec2 dHdxy_fwd() {
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
208
208
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
209
209
  return normalize( abs( fDet ) * surf_norm - vGrad );
210
210
  }
211
- #endif`,vh=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,Mh=`#if NUM_CLIPPING_PLANES > 0
212
212
  vec4 plane;
213
213
  #ifdef ALPHA_TO_COVERAGE
214
214
  float distanceToPlane, distanceGradient;
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
254
254
  if ( clipped ) discard;
255
255
  #endif
256
256
  #endif
257
- #endif`,Mh=`#if NUM_CLIPPING_PLANES > 0
258
- varying vec3 vClipPosition;
259
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
257
  #endif`,Sh=`#if NUM_CLIPPING_PLANES > 0
261
258
  varying vec3 vClipPosition;
259
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
262
260
  #endif`,Eh=`#if NUM_CLIPPING_PLANES > 0
261
+ varying vec3 vClipPosition;
262
+ #endif`,yh=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,yh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
- diffuseColor *= vColor;
266
264
  #endif`,bh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
- varying vec4 vColor;
268
- #endif`,Th=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
265
+ diffuseColor *= vColor;
266
+ #endif`,Th=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
269
267
  varying vec4 vColor;
270
268
  #endif`,Ah=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
+ varying vec4 vColor;
270
+ #endif`,wh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
271
271
  vColor = vec4( 1.0 );
272
272
  #endif
273
273
  #ifdef USE_COLOR_ALPHA
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
280
280
  #endif
281
281
  #ifdef USE_BATCHING_COLOR
282
282
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
283
- #endif`,wh=`#define PI 3.141592653589793
283
+ #endif`,Rh=`#define PI 3.141592653589793
284
284
  #define PI2 6.283185307179586
285
285
  #define PI_HALF 1.5707963267948966
286
286
  #define RECIPROCAL_PI 0.3183098861837907
@@ -347,7 +347,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
347
347
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
348
348
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
349
349
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
350
- } // validated`,Rh=`#ifdef ENVMAP_TYPE_CUBE_UV
350
+ } // validated`,Ch=`#ifdef ENVMAP_TYPE_CUBE_UV
351
351
  #define cubeUV_minMipLevel 4.0
352
352
  #define cubeUV_minTileSize 16.0
353
353
  float getFace( vec3 direction ) {
@@ -440,7 +440,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
440
440
  return vec4( mix( color0, color1, mipF ), 1.0 );
441
441
  }
442
442
  }
443
- #endif`,Ch=`vec3 transformedNormal = objectNormal;
443
+ #endif`,Ph=`vec3 transformedNormal = objectNormal;
444
444
  #ifdef USE_TANGENT
445
445
  vec3 transformedTangent = objectTangent;
446
446
  #endif
@@ -469,21 +469,21 @@ transformedNormal = normalMatrix * transformedNormal;
469
469
  #ifdef FLIP_SIDED
470
470
  transformedTangent = - transformedTangent;
471
471
  #endif
472
- #endif`,Ph=`#ifdef USE_DISPLACEMENTMAP
472
+ #endif`,Dh=`#ifdef USE_DISPLACEMENTMAP
473
473
  uniform sampler2D displacementMap;
474
474
  uniform float displacementScale;
475
475
  uniform float displacementBias;
476
- #endif`,Dh=`#ifdef USE_DISPLACEMENTMAP
476
+ #endif`,Lh=`#ifdef USE_DISPLACEMENTMAP
477
477
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
478
- #endif`,Lh=`#ifdef USE_EMISSIVEMAP
478
+ #endif`,Ih=`#ifdef USE_EMISSIVEMAP
479
479
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
480
480
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
481
481
  emissiveColor = sRGBTransferEOTF( emissiveColor );
482
482
  #endif
483
483
  totalEmissiveRadiance *= emissiveColor.rgb;
484
- #endif`,Ih=`#ifdef USE_EMISSIVEMAP
484
+ #endif`,Fh=`#ifdef USE_EMISSIVEMAP
485
485
  uniform sampler2D emissiveMap;
486
- #endif`,Fh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Uh=`vec4 LinearTransferOETF( in vec4 value ) {
486
+ #endif`,Uh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Nh=`vec4 LinearTransferOETF( in vec4 value ) {
487
487
  return value;
488
488
  }
489
489
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -491,7 +491,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
491
491
  }
492
492
  vec4 sRGBTransferOETF( in vec4 value ) {
493
493
  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 );
494
- }`,Nh=`#ifdef USE_ENVMAP
494
+ }`,Oh=`#ifdef USE_ENVMAP
495
495
  #ifdef ENV_WORLDPOS
496
496
  vec3 cameraToFrag;
497
497
  if ( isOrthographic ) {
@@ -518,7 +518,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
518
518
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
519
519
  #endif
520
520
  #endif
521
- #endif`,Oh=`#ifdef USE_ENVMAP
521
+ #endif`,Bh=`#ifdef USE_ENVMAP
522
522
  uniform float envMapIntensity;
523
523
  uniform float flipEnvMap;
524
524
  uniform mat3 envMapRotation;
@@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
527
527
  #else
528
528
  uniform sampler2D envMap;
529
529
  #endif
530
- #endif`,Bh=`#ifdef USE_ENVMAP
530
+ #endif`,zh=`#ifdef USE_ENVMAP
531
531
  uniform float reflectivity;
532
532
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
533
533
  #define ENV_WORLDPOS
@@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
538
538
  #else
539
539
  varying vec3 vReflect;
540
540
  #endif
541
- #endif`,zh=`#ifdef USE_ENVMAP
541
+ #endif`,Gh=`#ifdef USE_ENVMAP
542
542
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
543
543
  #define ENV_WORLDPOS
544
544
  #endif
@@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
549
549
  varying vec3 vReflect;
550
550
  uniform float refractionRatio;
551
551
  #endif
552
- #endif`,Gh=`#ifdef USE_ENVMAP
552
+ #endif`,Vh=`#ifdef USE_ENVMAP
553
553
  #ifdef ENV_WORLDPOS
554
554
  vWorldPosition = worldPosition.xyz;
555
555
  #else
@@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
566
566
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
567
567
  #endif
568
568
  #endif
569
- #endif`,Vh=`#ifdef USE_FOG
570
- vFogDepth = - mvPosition.z;
571
569
  #endif`,Hh=`#ifdef USE_FOG
572
- varying float vFogDepth;
570
+ vFogDepth = - mvPosition.z;
573
571
  #endif`,kh=`#ifdef USE_FOG
572
+ varying float vFogDepth;
573
+ #endif`,Wh=`#ifdef USE_FOG
574
574
  #ifdef FOG_EXP2
575
575
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
576
576
  #else
577
577
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
578
578
  #endif
579
579
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
580
- #endif`,Wh=`#ifdef USE_FOG
580
+ #endif`,Xh=`#ifdef USE_FOG
581
581
  uniform vec3 fogColor;
582
582
  varying float vFogDepth;
583
583
  #ifdef FOG_EXP2
@@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
586
586
  uniform float fogNear;
587
587
  uniform float fogFar;
588
588
  #endif
589
- #endif`,Xh=`#ifdef USE_GRADIENTMAP
589
+ #endif`,qh=`#ifdef USE_GRADIENTMAP
590
590
  uniform sampler2D gradientMap;
591
591
  #endif
592
592
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
598
598
  vec2 fw = fwidth( coord ) * 0.5;
599
599
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
600
600
  #endif
601
- }`,qh=`#ifdef USE_LIGHTMAP
601
+ }`,Yh=`#ifdef USE_LIGHTMAP
602
602
  uniform sampler2D lightMap;
603
603
  uniform float lightMapIntensity;
604
- #endif`,Yh=`LambertMaterial material;
604
+ #endif`,jh=`LambertMaterial material;
605
605
  material.diffuseColor = diffuseColor.rgb;
606
- material.specularStrength = specularStrength;`,jh=`varying vec3 vViewPosition;
606
+ material.specularStrength = specularStrength;`,$h=`varying vec3 vViewPosition;
607
607
  struct LambertMaterial {
608
608
  vec3 diffuseColor;
609
609
  float specularStrength;
@@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
617
617
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
618
618
  }
619
619
  #define RE_Direct RE_Direct_Lambert
620
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,$h=`uniform bool receiveShadow;
620
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Zh=`uniform bool receiveShadow;
621
621
  uniform vec3 ambientLightColor;
622
622
  #if defined( USE_LIGHT_PROBES )
623
623
  uniform vec3 lightProbe[ 9 ];
@@ -733,7 +733,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
733
733
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
734
734
  return irradiance;
735
735
  }
736
- #endif`,Zh=`#ifdef USE_ENVMAP
736
+ #endif`,Kh=`#ifdef USE_ENVMAP
737
737
  vec3 getIBLIrradiance( const in vec3 normal ) {
738
738
  #ifdef ENVMAP_TYPE_CUBE_UV
739
739
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -766,8 +766,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
766
766
  #endif
767
767
  }
768
768
  #endif
769
- #endif`,Kh=`ToonMaterial material;
770
- material.diffuseColor = diffuseColor.rgb;`,Jh=`varying vec3 vViewPosition;
769
+ #endif`,Jh=`ToonMaterial material;
770
+ material.diffuseColor = diffuseColor.rgb;`,Qh=`varying vec3 vViewPosition;
771
771
  struct ToonMaterial {
772
772
  vec3 diffuseColor;
773
773
  };
@@ -779,11 +779,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
779
779
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
780
780
  }
781
781
  #define RE_Direct RE_Direct_Toon
782
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Qh=`BlinnPhongMaterial material;
782
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,eu=`BlinnPhongMaterial material;
783
783
  material.diffuseColor = diffuseColor.rgb;
784
784
  material.specularColor = specular;
785
785
  material.specularShininess = shininess;
786
- material.specularStrength = specularStrength;`,eu=`varying vec3 vViewPosition;
786
+ material.specularStrength = specularStrength;`,tu=`varying vec3 vViewPosition;
787
787
  struct BlinnPhongMaterial {
788
788
  vec3 diffuseColor;
789
789
  vec3 specularColor;
@@ -800,7 +800,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
800
800
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
801
801
  }
802
802
  #define RE_Direct RE_Direct_BlinnPhong
803
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,tu=`PhysicalMaterial material;
803
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,nu=`PhysicalMaterial material;
804
804
  material.diffuseColor = diffuseColor.rgb;
805
805
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
806
806
  material.metalness = metalnessFactor;
@@ -890,7 +890,7 @@ material.roughness = min( material.roughness, 1.0 );
890
890
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
891
891
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
892
892
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
893
- #endif`,nu=`uniform sampler2D dfgLUT;
893
+ #endif`,iu=`uniform sampler2D dfgLUT;
894
894
  struct PhysicalMaterial {
895
895
  vec3 diffuseColor;
896
896
  vec3 diffuseContribution;
@@ -1251,7 +1251,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1251
1251
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1252
1252
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1253
1253
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1254
- }`,iu=`
1254
+ }`,ru=`
1255
1255
  vec3 geometryPosition = - vViewPosition;
1256
1256
  vec3 geometryNormal = normal;
1257
1257
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1368,7 +1368,7 @@ IncidentLight directLight;
1368
1368
  #if defined( RE_IndirectSpecular )
1369
1369
  vec3 radiance = vec3( 0.0 );
1370
1370
  vec3 clearcoatRadiance = vec3( 0.0 );
1371
- #endif`,ru=`#if defined( RE_IndirectDiffuse )
1371
+ #endif`,su=`#if defined( RE_IndirectDiffuse )
1372
1372
  #ifdef USE_LIGHTMAP
1373
1373
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1374
1374
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1389,7 +1389,7 @@ IncidentLight directLight;
1389
1389
  #ifdef USE_CLEARCOAT
1390
1390
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1391
1391
  #endif
1392
- #endif`,su=`#if defined( RE_IndirectDiffuse )
1392
+ #endif`,au=`#if defined( RE_IndirectDiffuse )
1393
1393
  #if defined( LAMBERT ) || defined( PHONG )
1394
1394
  irradiance += iblIrradiance;
1395
1395
  #endif
@@ -1397,27 +1397,27 @@ IncidentLight directLight;
1397
1397
  #endif
1398
1398
  #if defined( RE_IndirectSpecular )
1399
1399
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1400
- #endif`,au=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1401
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1402
1400
  #endif`,ou=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1401
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1402
+ #endif`,lu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1403
1403
  uniform float logDepthBufFC;
1404
1404
  varying float vFragDepth;
1405
1405
  varying float vIsPerspective;
1406
- #endif`,lu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1406
+ #endif`,cu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1407
1407
  varying float vFragDepth;
1408
1408
  varying float vIsPerspective;
1409
- #endif`,cu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1409
+ #endif`,hu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1410
1410
  vFragDepth = 1.0 + gl_Position.w;
1411
1411
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1412
- #endif`,hu=`#ifdef USE_MAP
1412
+ #endif`,uu=`#ifdef USE_MAP
1413
1413
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1414
1414
  #ifdef DECODE_VIDEO_TEXTURE
1415
1415
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1416
1416
  #endif
1417
1417
  diffuseColor *= sampledDiffuseColor;
1418
- #endif`,uu=`#ifdef USE_MAP
1418
+ #endif`,fu=`#ifdef USE_MAP
1419
1419
  uniform sampler2D map;
1420
- #endif`,fu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1420
+ #endif`,du=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1421
1421
  #if defined( USE_POINTS_UV )
1422
1422
  vec2 uv = vUv;
1423
1423
  #else
@@ -1429,7 +1429,7 @@ IncidentLight directLight;
1429
1429
  #endif
1430
1430
  #ifdef USE_ALPHAMAP
1431
1431
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1432
- #endif`,du=`#if defined( USE_POINTS_UV )
1432
+ #endif`,pu=`#if defined( USE_POINTS_UV )
1433
1433
  varying vec2 vUv;
1434
1434
  #else
1435
1435
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1441,19 +1441,19 @@ IncidentLight directLight;
1441
1441
  #endif
1442
1442
  #ifdef USE_ALPHAMAP
1443
1443
  uniform sampler2D alphaMap;
1444
- #endif`,pu=`float metalnessFactor = metalness;
1444
+ #endif`,mu=`float metalnessFactor = metalness;
1445
1445
  #ifdef USE_METALNESSMAP
1446
1446
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1447
1447
  metalnessFactor *= texelMetalness.b;
1448
- #endif`,mu=`#ifdef USE_METALNESSMAP
1448
+ #endif`,gu=`#ifdef USE_METALNESSMAP
1449
1449
  uniform sampler2D metalnessMap;
1450
- #endif`,gu=`#ifdef USE_INSTANCING_MORPH
1450
+ #endif`,_u=`#ifdef USE_INSTANCING_MORPH
1451
1451
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1452
1452
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1453
1453
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1454
1454
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1455
1455
  }
1456
- #endif`,_u=`#if defined( USE_MORPHCOLORS )
1456
+ #endif`,xu=`#if defined( USE_MORPHCOLORS )
1457
1457
  vColor *= morphTargetBaseInfluence;
1458
1458
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1459
1459
  #if defined( USE_COLOR_ALPHA )
@@ -1462,12 +1462,12 @@ IncidentLight directLight;
1462
1462
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1463
1463
  #endif
1464
1464
  }
1465
- #endif`,xu=`#ifdef USE_MORPHNORMALS
1465
+ #endif`,vu=`#ifdef USE_MORPHNORMALS
1466
1466
  objectNormal *= morphTargetBaseInfluence;
1467
1467
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
1468
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1469
1469
  }
1470
- #endif`,vu=`#ifdef USE_MORPHTARGETS
1470
+ #endif`,Mu=`#ifdef USE_MORPHTARGETS
1471
1471
  #ifndef USE_INSTANCING_MORPH
1472
1472
  uniform float morphTargetBaseInfluence;
1473
1473
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1481,12 +1481,12 @@ IncidentLight directLight;
1481
1481
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1482
1482
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1483
1483
  }
1484
- #endif`,Mu=`#ifdef USE_MORPHTARGETS
1484
+ #endif`,Su=`#ifdef USE_MORPHTARGETS
1485
1485
  transformed *= morphTargetBaseInfluence;
1486
1486
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1487
1487
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1488
1488
  }
1489
- #endif`,Su=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1489
+ #endif`,Eu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1490
1490
  #ifdef FLAT_SHADED
1491
1491
  vec3 fdx = dFdx( vViewPosition );
1492
1492
  vec3 fdy = dFdy( vViewPosition );
@@ -1527,7 +1527,7 @@ IncidentLight directLight;
1527
1527
  tbn2[1] *= faceDirection;
1528
1528
  #endif
1529
1529
  #endif
1530
- vec3 nonPerturbedNormal = normal;`,Eu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1530
+ vec3 nonPerturbedNormal = normal;`,yu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1531
1531
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1532
1532
  #ifdef FLIP_SIDED
1533
1533
  normal = - normal;
@@ -1542,25 +1542,25 @@ vec3 nonPerturbedNormal = normal;`,Eu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1542
1542
  normal = normalize( tbn * mapN );
1543
1543
  #elif defined( USE_BUMPMAP )
1544
1544
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1545
- #endif`,yu=`#ifndef FLAT_SHADED
1545
+ #endif`,bu=`#ifndef FLAT_SHADED
1546
1546
  varying vec3 vNormal;
1547
1547
  #ifdef USE_TANGENT
1548
1548
  varying vec3 vTangent;
1549
1549
  varying vec3 vBitangent;
1550
1550
  #endif
1551
- #endif`,bu=`#ifndef FLAT_SHADED
1551
+ #endif`,Tu=`#ifndef FLAT_SHADED
1552
1552
  varying vec3 vNormal;
1553
1553
  #ifdef USE_TANGENT
1554
1554
  varying vec3 vTangent;
1555
1555
  varying vec3 vBitangent;
1556
1556
  #endif
1557
- #endif`,Tu=`#ifndef FLAT_SHADED
1557
+ #endif`,Au=`#ifndef FLAT_SHADED
1558
1558
  vNormal = normalize( transformedNormal );
1559
1559
  #ifdef USE_TANGENT
1560
1560
  vTangent = normalize( transformedTangent );
1561
1561
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1562
1562
  #endif
1563
- #endif`,Au=`#ifdef USE_NORMALMAP
1563
+ #endif`,wu=`#ifdef USE_NORMALMAP
1564
1564
  uniform sampler2D normalMap;
1565
1565
  uniform vec2 normalScale;
1566
1566
  #endif
@@ -1582,13 +1582,13 @@ vec3 nonPerturbedNormal = normal;`,Eu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1582
1582
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1583
1583
  return mat3( T * scale, B * scale, N );
1584
1584
  }
1585
- #endif`,wu=`#ifdef USE_CLEARCOAT
1585
+ #endif`,Ru=`#ifdef USE_CLEARCOAT
1586
1586
  vec3 clearcoatNormal = nonPerturbedNormal;
1587
- #endif`,Ru=`#ifdef USE_CLEARCOAT_NORMALMAP
1587
+ #endif`,Cu=`#ifdef USE_CLEARCOAT_NORMALMAP
1588
1588
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1589
1589
  clearcoatMapN.xy *= clearcoatNormalScale;
1590
1590
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1591
- #endif`,Cu=`#ifdef USE_CLEARCOATMAP
1591
+ #endif`,Pu=`#ifdef USE_CLEARCOATMAP
1592
1592
  uniform sampler2D clearcoatMap;
1593
1593
  #endif
1594
1594
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1597,18 +1597,18 @@ vec3 nonPerturbedNormal = normal;`,Eu=`#ifdef USE_NORMALMAP_OBJECTSPACE
1597
1597
  #endif
1598
1598
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1599
1599
  uniform sampler2D clearcoatRoughnessMap;
1600
- #endif`,Pu=`#ifdef USE_IRIDESCENCEMAP
1600
+ #endif`,Du=`#ifdef USE_IRIDESCENCEMAP
1601
1601
  uniform sampler2D iridescenceMap;
1602
1602
  #endif
1603
1603
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1604
1604
  uniform sampler2D iridescenceThicknessMap;
1605
- #endif`,Du=`#ifdef OPAQUE
1605
+ #endif`,Lu=`#ifdef OPAQUE
1606
1606
  diffuseColor.a = 1.0;
1607
1607
  #endif
1608
1608
  #ifdef USE_TRANSMISSION
1609
1609
  diffuseColor.a *= material.transmissionAlpha;
1610
1610
  #endif
1611
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Lu=`vec3 packNormalToRGB( const in vec3 normal ) {
1611
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Iu=`vec3 packNormalToRGB( const in vec3 normal ) {
1612
1612
  return normalize( normal ) * 0.5 + 0.5;
1613
1613
  }
1614
1614
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1687,9 +1687,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1687
1687
  #else
1688
1688
  return ( near * far ) / ( ( far - near ) * depth - far );
1689
1689
  #endif
1690
- }`,Iu=`#ifdef PREMULTIPLIED_ALPHA
1690
+ }`,Fu=`#ifdef PREMULTIPLIED_ALPHA
1691
1691
  gl_FragColor.rgb *= gl_FragColor.a;
1692
- #endif`,Fu=`vec4 mvPosition = vec4( transformed, 1.0 );
1692
+ #endif`,Uu=`vec4 mvPosition = vec4( transformed, 1.0 );
1693
1693
  #ifdef USE_BATCHING
1694
1694
  mvPosition = batchingMatrix * mvPosition;
1695
1695
  #endif
@@ -1697,22 +1697,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1697
1697
  mvPosition = instanceMatrix * mvPosition;
1698
1698
  #endif
1699
1699
  mvPosition = modelViewMatrix * mvPosition;
1700
- gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
1700
+ gl_Position = projectionMatrix * mvPosition;`,Nu=`#ifdef DITHERING
1701
1701
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1702
- #endif`,Nu=`#ifdef DITHERING
1702
+ #endif`,Ou=`#ifdef DITHERING
1703
1703
  vec3 dithering( vec3 color ) {
1704
1704
  float grid_position = rand( gl_FragCoord.xy );
1705
1705
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1706
1706
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1707
1707
  return color + dither_shift_RGB;
1708
1708
  }
1709
- #endif`,Ou=`float roughnessFactor = roughness;
1709
+ #endif`,Bu=`float roughnessFactor = roughness;
1710
1710
  #ifdef USE_ROUGHNESSMAP
1711
1711
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1712
1712
  roughnessFactor *= texelRoughness.g;
1713
- #endif`,Bu=`#ifdef USE_ROUGHNESSMAP
1713
+ #endif`,zu=`#ifdef USE_ROUGHNESSMAP
1714
1714
  uniform sampler2D roughnessMap;
1715
- #endif`,zu=`#if NUM_SPOT_LIGHT_COORDS > 0
1715
+ #endif`,Gu=`#if NUM_SPOT_LIGHT_COORDS > 0
1716
1716
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1717
1717
  #endif
1718
1718
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1912,7 +1912,7 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
1912
1912
  }
1913
1913
  #endif
1914
1914
  #endif
1915
- #endif`,Gu=`#if NUM_SPOT_LIGHT_COORDS > 0
1915
+ #endif`,Vu=`#if NUM_SPOT_LIGHT_COORDS > 0
1916
1916
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1917
1917
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1918
1918
  #endif
@@ -1953,7 +1953,7 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
1953
1953
  };
1954
1954
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1955
1955
  #endif
1956
- #endif`,Vu=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1956
+ #endif`,Hu=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1957
1957
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1958
1958
  vec4 shadowWorldPosition;
1959
1959
  #endif
@@ -1985,7 +1985,7 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
1985
1985
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1986
1986
  }
1987
1987
  #pragma unroll_loop_end
1988
- #endif`,Hu=`float getShadowMask() {
1988
+ #endif`,ku=`float getShadowMask() {
1989
1989
  float shadow = 1.0;
1990
1990
  #ifdef USE_SHADOWMAP
1991
1991
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2017,12 +2017,12 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
2017
2017
  #endif
2018
2018
  #endif
2019
2019
  return shadow;
2020
- }`,ku=`#ifdef USE_SKINNING
2020
+ }`,Wu=`#ifdef USE_SKINNING
2021
2021
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2022
2022
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2023
2023
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2024
2024
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2025
- #endif`,Wu=`#ifdef USE_SKINNING
2025
+ #endif`,Xu=`#ifdef USE_SKINNING
2026
2026
  uniform mat4 bindMatrix;
2027
2027
  uniform mat4 bindMatrixInverse;
2028
2028
  uniform highp sampler2D boneTexture;
@@ -2037,7 +2037,7 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
2037
2037
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2038
2038
  return mat4( v1, v2, v3, v4 );
2039
2039
  }
2040
- #endif`,Xu=`#ifdef USE_SKINNING
2040
+ #endif`,qu=`#ifdef USE_SKINNING
2041
2041
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2042
2042
  vec4 skinned = vec4( 0.0 );
2043
2043
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2045,7 +2045,7 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
2045
2045
  skinned += boneMatZ * skinVertex * skinWeight.z;
2046
2046
  skinned += boneMatW * skinVertex * skinWeight.w;
2047
2047
  transformed = ( bindMatrixInverse * skinned ).xyz;
2048
- #endif`,qu=`#ifdef USE_SKINNING
2048
+ #endif`,Yu=`#ifdef USE_SKINNING
2049
2049
  mat4 skinMatrix = mat4( 0.0 );
2050
2050
  skinMatrix += skinWeight.x * boneMatX;
2051
2051
  skinMatrix += skinWeight.y * boneMatY;
@@ -2056,17 +2056,17 @@ gl_Position = projectionMatrix * mvPosition;`,Uu=`#ifdef DITHERING
2056
2056
  #ifdef USE_TANGENT
2057
2057
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2058
2058
  #endif
2059
- #endif`,Yu=`float specularStrength;
2059
+ #endif`,ju=`float specularStrength;
2060
2060
  #ifdef USE_SPECULARMAP
2061
2061
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2062
2062
  specularStrength = texelSpecular.r;
2063
2063
  #else
2064
2064
  specularStrength = 1.0;
2065
- #endif`,ju=`#ifdef USE_SPECULARMAP
2065
+ #endif`,$u=`#ifdef USE_SPECULARMAP
2066
2066
  uniform sampler2D specularMap;
2067
- #endif`,$u=`#if defined( TONE_MAPPING )
2067
+ #endif`,Zu=`#if defined( TONE_MAPPING )
2068
2068
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2069
- #endif`,Zu=`#ifndef saturate
2069
+ #endif`,Ku=`#ifndef saturate
2070
2070
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2071
2071
  #endif
2072
2072
  uniform float toneMappingExposure;
@@ -2163,7 +2163,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2163
2163
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2164
2164
  return mix( color, vec3( newPeak ), g );
2165
2165
  }
2166
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISSION
2166
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ju=`#ifdef USE_TRANSMISSION
2167
2167
  material.transmission = transmission;
2168
2168
  material.transmissionAlpha = 1.0;
2169
2169
  material.thickness = thickness;
@@ -2184,7 +2184,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2184
2184
  material.attenuationColor, material.attenuationDistance );
2185
2185
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2186
2186
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2187
- #endif`,Ju=`#ifdef USE_TRANSMISSION
2187
+ #endif`,Qu=`#ifdef USE_TRANSMISSION
2188
2188
  uniform float transmission;
2189
2189
  uniform float thickness;
2190
2190
  uniform float attenuationDistance;
@@ -2310,7 +2310,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2310
2310
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2311
2311
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2312
2312
  }
2313
- #endif`,Qu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2313
+ #endif`,ef=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2314
2314
  varying vec2 vUv;
2315
2315
  #endif
2316
2316
  #ifdef USE_MAP
@@ -2380,7 +2380,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2380
2380
  #ifdef USE_THICKNESSMAP
2381
2381
  uniform mat3 thicknessMapTransform;
2382
2382
  varying vec2 vThicknessMapUv;
2383
- #endif`,ef=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2383
+ #endif`,tf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2384
2384
  varying vec2 vUv;
2385
2385
  #endif
2386
2386
  #ifdef USE_MAP
@@ -2474,7 +2474,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2474
2474
  #ifdef USE_THICKNESSMAP
2475
2475
  uniform mat3 thicknessMapTransform;
2476
2476
  varying vec2 vThicknessMapUv;
2477
- #endif`,tf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2477
+ #endif`,nf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2478
2478
  vUv = vec3( uv, 1 ).xy;
2479
2479
  #endif
2480
2480
  #ifdef USE_MAP
@@ -2545,7 +2545,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2545
2545
  #endif
2546
2546
  #ifdef USE_THICKNESSMAP
2547
2547
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2548
- #endif`,nf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2548
+ #endif`,rf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2549
2549
  vec4 worldPosition = vec4( transformed, 1.0 );
2550
2550
  #ifdef USE_BATCHING
2551
2551
  worldPosition = batchingMatrix * worldPosition;
@@ -2554,12 +2554,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Ku=`#ifdef USE_TRANSMISS
2554
2554
  worldPosition = instanceMatrix * worldPosition;
2555
2555
  #endif
2556
2556
  worldPosition = modelMatrix * worldPosition;
2557
- #endif`;const rf=`varying vec2 vUv;
2557
+ #endif`;const sf=`varying vec2 vUv;
2558
2558
  uniform mat3 uvTransform;
2559
2559
  void main() {
2560
2560
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2561
2561
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2562
- }`,sf=`uniform sampler2D t2D;
2562
+ }`,af=`uniform sampler2D t2D;
2563
2563
  uniform float backgroundIntensity;
2564
2564
  varying vec2 vUv;
2565
2565
  void main() {
@@ -2571,14 +2571,14 @@ void main() {
2571
2571
  gl_FragColor = texColor;
2572
2572
  #include <tonemapping_fragment>
2573
2573
  #include <colorspace_fragment>
2574
- }`,af=`varying vec3 vWorldDirection;
2574
+ }`,of=`varying vec3 vWorldDirection;
2575
2575
  #include <common>
2576
2576
  void main() {
2577
2577
  vWorldDirection = transformDirection( position, modelMatrix );
2578
2578
  #include <begin_vertex>
2579
2579
  #include <project_vertex>
2580
2580
  gl_Position.z = gl_Position.w;
2581
- }`,of=`#ifdef ENVMAP_TYPE_CUBE
2581
+ }`,lf=`#ifdef ENVMAP_TYPE_CUBE
2582
2582
  uniform samplerCube envMap;
2583
2583
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2584
2584
  uniform sampler2D envMap;
@@ -2601,14 +2601,14 @@ void main() {
2601
2601
  gl_FragColor = texColor;
2602
2602
  #include <tonemapping_fragment>
2603
2603
  #include <colorspace_fragment>
2604
- }`,lf=`varying vec3 vWorldDirection;
2604
+ }`,cf=`varying vec3 vWorldDirection;
2605
2605
  #include <common>
2606
2606
  void main() {
2607
2607
  vWorldDirection = transformDirection( position, modelMatrix );
2608
2608
  #include <begin_vertex>
2609
2609
  #include <project_vertex>
2610
2610
  gl_Position.z = gl_Position.w;
2611
- }`,cf=`uniform samplerCube tCube;
2611
+ }`,hf=`uniform samplerCube tCube;
2612
2612
  uniform float tFlip;
2613
2613
  uniform float opacity;
2614
2614
  varying vec3 vWorldDirection;
@@ -2618,7 +2618,7 @@ void main() {
2618
2618
  gl_FragColor.a *= opacity;
2619
2619
  #include <tonemapping_fragment>
2620
2620
  #include <colorspace_fragment>
2621
- }`,hf=`#include <common>
2621
+ }`,uf=`#include <common>
2622
2622
  #include <batching_pars_vertex>
2623
2623
  #include <uv_pars_vertex>
2624
2624
  #include <displacementmap_pars_vertex>
@@ -2645,7 +2645,7 @@ void main() {
2645
2645
  #include <logdepthbuf_vertex>
2646
2646
  #include <clipping_planes_vertex>
2647
2647
  vHighPrecisionZW = gl_Position.zw;
2648
- }`,uf=`#if DEPTH_PACKING == 3200
2648
+ }`,ff=`#if DEPTH_PACKING == 3200
2649
2649
  uniform float opacity;
2650
2650
  #endif
2651
2651
  #include <common>
@@ -2683,7 +2683,7 @@ void main() {
2683
2683
  #elif DEPTH_PACKING == 3203
2684
2684
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2685
2685
  #endif
2686
- }`,ff=`#define DISTANCE
2686
+ }`,df=`#define DISTANCE
2687
2687
  varying vec3 vWorldPosition;
2688
2688
  #include <common>
2689
2689
  #include <batching_pars_vertex>
@@ -2710,7 +2710,7 @@ void main() {
2710
2710
  #include <worldpos_vertex>
2711
2711
  #include <clipping_planes_vertex>
2712
2712
  vWorldPosition = worldPosition.xyz;
2713
- }`,df=`#define DISTANCE
2713
+ }`,pf=`#define DISTANCE
2714
2714
  uniform vec3 referencePosition;
2715
2715
  uniform float nearDistance;
2716
2716
  uniform float farDistance;
@@ -2733,13 +2733,13 @@ void main () {
2733
2733
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2734
2734
  dist = saturate( dist );
2735
2735
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2736
- }`,pf=`varying vec3 vWorldDirection;
2736
+ }`,mf=`varying vec3 vWorldDirection;
2737
2737
  #include <common>
2738
2738
  void main() {
2739
2739
  vWorldDirection = transformDirection( position, modelMatrix );
2740
2740
  #include <begin_vertex>
2741
2741
  #include <project_vertex>
2742
- }`,mf=`uniform sampler2D tEquirect;
2742
+ }`,gf=`uniform sampler2D tEquirect;
2743
2743
  varying vec3 vWorldDirection;
2744
2744
  #include <common>
2745
2745
  void main() {
@@ -2748,7 +2748,7 @@ void main() {
2748
2748
  gl_FragColor = texture2D( tEquirect, sampleUV );
2749
2749
  #include <tonemapping_fragment>
2750
2750
  #include <colorspace_fragment>
2751
- }`,gf=`uniform float scale;
2751
+ }`,_f=`uniform float scale;
2752
2752
  attribute float lineDistance;
2753
2753
  varying float vLineDistance;
2754
2754
  #include <common>
@@ -2770,7 +2770,7 @@ void main() {
2770
2770
  #include <logdepthbuf_vertex>
2771
2771
  #include <clipping_planes_vertex>
2772
2772
  #include <fog_vertex>
2773
- }`,_f=`uniform vec3 diffuse;
2773
+ }`,xf=`uniform vec3 diffuse;
2774
2774
  uniform float opacity;
2775
2775
  uniform float dashSize;
2776
2776
  uniform float totalSize;
@@ -2798,7 +2798,7 @@ void main() {
2798
2798
  #include <colorspace_fragment>
2799
2799
  #include <fog_fragment>
2800
2800
  #include <premultiplied_alpha_fragment>
2801
- }`,xf=`#include <common>
2801
+ }`,vf=`#include <common>
2802
2802
  #include <batching_pars_vertex>
2803
2803
  #include <uv_pars_vertex>
2804
2804
  #include <envmap_pars_vertex>
@@ -2830,7 +2830,7 @@ void main() {
2830
2830
  #include <worldpos_vertex>
2831
2831
  #include <envmap_vertex>
2832
2832
  #include <fog_vertex>
2833
- }`,vf=`uniform vec3 diffuse;
2833
+ }`,Mf=`uniform vec3 diffuse;
2834
2834
  uniform float opacity;
2835
2835
  #ifndef FLAT_SHADED
2836
2836
  varying vec3 vNormal;
@@ -2878,7 +2878,7 @@ void main() {
2878
2878
  #include <fog_fragment>
2879
2879
  #include <premultiplied_alpha_fragment>
2880
2880
  #include <dithering_fragment>
2881
- }`,Mf=`#define LAMBERT
2881
+ }`,Sf=`#define LAMBERT
2882
2882
  varying vec3 vViewPosition;
2883
2883
  #include <common>
2884
2884
  #include <batching_pars_vertex>
@@ -2917,7 +2917,7 @@ void main() {
2917
2917
  #include <envmap_vertex>
2918
2918
  #include <shadowmap_vertex>
2919
2919
  #include <fog_vertex>
2920
- }`,Sf=`#define LAMBERT
2920
+ }`,Ef=`#define LAMBERT
2921
2921
  uniform vec3 diffuse;
2922
2922
  uniform vec3 emissive;
2923
2923
  uniform float opacity;
@@ -2975,7 +2975,7 @@ void main() {
2975
2975
  #include <fog_fragment>
2976
2976
  #include <premultiplied_alpha_fragment>
2977
2977
  #include <dithering_fragment>
2978
- }`,Ef=`#define MATCAP
2978
+ }`,yf=`#define MATCAP
2979
2979
  varying vec3 vViewPosition;
2980
2980
  #include <common>
2981
2981
  #include <batching_pars_vertex>
@@ -3009,7 +3009,7 @@ void main() {
3009
3009
  #include <clipping_planes_vertex>
3010
3010
  #include <fog_vertex>
3011
3011
  vViewPosition = - mvPosition.xyz;
3012
- }`,yf=`#define MATCAP
3012
+ }`,bf=`#define MATCAP
3013
3013
  uniform vec3 diffuse;
3014
3014
  uniform float opacity;
3015
3015
  uniform sampler2D matcap;
@@ -3055,7 +3055,7 @@ void main() {
3055
3055
  #include <fog_fragment>
3056
3056
  #include <premultiplied_alpha_fragment>
3057
3057
  #include <dithering_fragment>
3058
- }`,bf=`#define NORMAL
3058
+ }`,Tf=`#define NORMAL
3059
3059
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3060
3060
  varying vec3 vViewPosition;
3061
3061
  #endif
@@ -3088,7 +3088,7 @@ void main() {
3088
3088
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3089
3089
  vViewPosition = - mvPosition.xyz;
3090
3090
  #endif
3091
- }`,Tf=`#define NORMAL
3091
+ }`,Af=`#define NORMAL
3092
3092
  uniform float opacity;
3093
3093
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3094
3094
  varying vec3 vViewPosition;
@@ -3109,7 +3109,7 @@ void main() {
3109
3109
  #ifdef OPAQUE
3110
3110
  gl_FragColor.a = 1.0;
3111
3111
  #endif
3112
- }`,Af=`#define PHONG
3112
+ }`,wf=`#define PHONG
3113
3113
  varying vec3 vViewPosition;
3114
3114
  #include <common>
3115
3115
  #include <batching_pars_vertex>
@@ -3148,7 +3148,7 @@ void main() {
3148
3148
  #include <envmap_vertex>
3149
3149
  #include <shadowmap_vertex>
3150
3150
  #include <fog_vertex>
3151
- }`,wf=`#define PHONG
3151
+ }`,Rf=`#define PHONG
3152
3152
  uniform vec3 diffuse;
3153
3153
  uniform vec3 emissive;
3154
3154
  uniform vec3 specular;
@@ -3208,7 +3208,7 @@ void main() {
3208
3208
  #include <fog_fragment>
3209
3209
  #include <premultiplied_alpha_fragment>
3210
3210
  #include <dithering_fragment>
3211
- }`,Rf=`#define STANDARD
3211
+ }`,Cf=`#define STANDARD
3212
3212
  varying vec3 vViewPosition;
3213
3213
  #ifdef USE_TRANSMISSION
3214
3214
  varying vec3 vWorldPosition;
@@ -3251,7 +3251,7 @@ void main() {
3251
3251
  #ifdef USE_TRANSMISSION
3252
3252
  vWorldPosition = worldPosition.xyz;
3253
3253
  #endif
3254
- }`,Cf=`#define STANDARD
3254
+ }`,Pf=`#define STANDARD
3255
3255
  #ifdef PHYSICAL
3256
3256
  #define IOR
3257
3257
  #define USE_SPECULAR
@@ -3376,7 +3376,7 @@ void main() {
3376
3376
  #include <fog_fragment>
3377
3377
  #include <premultiplied_alpha_fragment>
3378
3378
  #include <dithering_fragment>
3379
- }`,Pf=`#define TOON
3379
+ }`,Df=`#define TOON
3380
3380
  varying vec3 vViewPosition;
3381
3381
  #include <common>
3382
3382
  #include <batching_pars_vertex>
@@ -3413,7 +3413,7 @@ void main() {
3413
3413
  #include <worldpos_vertex>
3414
3414
  #include <shadowmap_vertex>
3415
3415
  #include <fog_vertex>
3416
- }`,Df=`#define TOON
3416
+ }`,Lf=`#define TOON
3417
3417
  uniform vec3 diffuse;
3418
3418
  uniform vec3 emissive;
3419
3419
  uniform float opacity;
@@ -3465,7 +3465,7 @@ void main() {
3465
3465
  #include <fog_fragment>
3466
3466
  #include <premultiplied_alpha_fragment>
3467
3467
  #include <dithering_fragment>
3468
- }`,Lf=`uniform float size;
3468
+ }`,If=`uniform float size;
3469
3469
  uniform float scale;
3470
3470
  #include <common>
3471
3471
  #include <color_pars_vertex>
@@ -3496,7 +3496,7 @@ void main() {
3496
3496
  #include <clipping_planes_vertex>
3497
3497
  #include <worldpos_vertex>
3498
3498
  #include <fog_vertex>
3499
- }`,If=`uniform vec3 diffuse;
3499
+ }`,Ff=`uniform vec3 diffuse;
3500
3500
  uniform float opacity;
3501
3501
  #include <common>
3502
3502
  #include <color_pars_fragment>
@@ -3521,7 +3521,7 @@ void main() {
3521
3521
  #include <colorspace_fragment>
3522
3522
  #include <fog_fragment>
3523
3523
  #include <premultiplied_alpha_fragment>
3524
- }`,Ff=`#include <common>
3524
+ }`,Uf=`#include <common>
3525
3525
  #include <batching_pars_vertex>
3526
3526
  #include <fog_pars_vertex>
3527
3527
  #include <morphtarget_pars_vertex>
@@ -3544,7 +3544,7 @@ void main() {
3544
3544
  #include <worldpos_vertex>
3545
3545
  #include <shadowmap_vertex>
3546
3546
  #include <fog_vertex>
3547
- }`,Uf=`uniform vec3 color;
3547
+ }`,Nf=`uniform vec3 color;
3548
3548
  uniform float opacity;
3549
3549
  #include <common>
3550
3550
  #include <fog_pars_fragment>
@@ -3560,7 +3560,7 @@ void main() {
3560
3560
  #include <colorspace_fragment>
3561
3561
  #include <fog_fragment>
3562
3562
  #include <premultiplied_alpha_fragment>
3563
- }`,Nf=`uniform float rotation;
3563
+ }`,Of=`uniform float rotation;
3564
3564
  uniform vec2 center;
3565
3565
  #include <common>
3566
3566
  #include <uv_pars_vertex>
@@ -3584,7 +3584,7 @@ void main() {
3584
3584
  #include <logdepthbuf_vertex>
3585
3585
  #include <clipping_planes_vertex>
3586
3586
  #include <fog_vertex>
3587
- }`,Of=`uniform vec3 diffuse;
3587
+ }`,Bf=`uniform vec3 diffuse;
3588
3588
  uniform float opacity;
3589
3589
  #include <common>
3590
3590
  #include <uv_pars_fragment>
@@ -3609,7 +3609,7 @@ void main() {
3609
3609
  #include <tonemapping_fragment>
3610
3610
  #include <colorspace_fragment>
3611
3611
  #include <fog_fragment>
3612
- }`,Be={alphahash_fragment:rh,alphahash_pars_fragment:sh,alphamap_fragment:ah,alphamap_pars_fragment:oh,alphatest_fragment:lh,alphatest_pars_fragment:ch,aomap_fragment:hh,aomap_pars_fragment:uh,batching_pars_vertex:fh,batching_vertex:dh,begin_vertex:ph,beginnormal_vertex:mh,bsdfs:gh,iridescence_fragment:_h,bumpmap_pars_fragment:xh,clipping_planes_fragment:vh,clipping_planes_pars_fragment:Mh,clipping_planes_pars_vertex:Sh,clipping_planes_vertex:Eh,color_fragment:yh,color_pars_fragment:bh,color_pars_vertex:Th,color_vertex:Ah,common:wh,cube_uv_reflection_fragment:Rh,defaultnormal_vertex:Ch,displacementmap_pars_vertex:Ph,displacementmap_vertex:Dh,emissivemap_fragment:Lh,emissivemap_pars_fragment:Ih,colorspace_fragment:Fh,colorspace_pars_fragment:Uh,envmap_fragment:Nh,envmap_common_pars_fragment:Oh,envmap_pars_fragment:Bh,envmap_pars_vertex:zh,envmap_physical_pars_fragment:Zh,envmap_vertex:Gh,fog_vertex:Vh,fog_pars_vertex:Hh,fog_fragment:kh,fog_pars_fragment:Wh,gradientmap_pars_fragment:Xh,lightmap_pars_fragment:qh,lights_lambert_fragment:Yh,lights_lambert_pars_fragment:jh,lights_pars_begin:$h,lights_toon_fragment:Kh,lights_toon_pars_fragment:Jh,lights_phong_fragment:Qh,lights_phong_pars_fragment:eu,lights_physical_fragment:tu,lights_physical_pars_fragment:nu,lights_fragment_begin:iu,lights_fragment_maps:ru,lights_fragment_end:su,logdepthbuf_fragment:au,logdepthbuf_pars_fragment:ou,logdepthbuf_pars_vertex:lu,logdepthbuf_vertex:cu,map_fragment:hu,map_pars_fragment:uu,map_particle_fragment:fu,map_particle_pars_fragment:du,metalnessmap_fragment:pu,metalnessmap_pars_fragment:mu,morphinstance_vertex:gu,morphcolor_vertex:_u,morphnormal_vertex:xu,morphtarget_pars_vertex:vu,morphtarget_vertex:Mu,normal_fragment_begin:Su,normal_fragment_maps:Eu,normal_pars_fragment:yu,normal_pars_vertex:bu,normal_vertex:Tu,normalmap_pars_fragment:Au,clearcoat_normal_fragment_begin:wu,clearcoat_normal_fragment_maps:Ru,clearcoat_pars_fragment:Cu,iridescence_pars_fragment:Pu,opaque_fragment:Du,packing:Lu,premultiplied_alpha_fragment:Iu,project_vertex:Fu,dithering_fragment:Uu,dithering_pars_fragment:Nu,roughnessmap_fragment:Ou,roughnessmap_pars_fragment:Bu,shadowmap_pars_fragment:zu,shadowmap_pars_vertex:Gu,shadowmap_vertex:Vu,shadowmask_pars_fragment:Hu,skinbase_vertex:ku,skinning_pars_vertex:Wu,skinning_vertex:Xu,skinnormal_vertex:qu,specularmap_fragment:Yu,specularmap_pars_fragment:ju,tonemapping_fragment:$u,tonemapping_pars_fragment:Zu,transmission_fragment:Ku,transmission_pars_fragment:Ju,uv_pars_fragment:Qu,uv_pars_vertex:ef,uv_vertex:tf,worldpos_vertex:nf,background_vert:rf,background_frag:sf,backgroundCube_vert:af,backgroundCube_frag:of,cube_vert:lf,cube_frag:cf,depth_vert:hf,depth_frag:uf,distance_vert:ff,distance_frag:df,equirect_vert:pf,equirect_frag:mf,linedashed_vert:gf,linedashed_frag:_f,meshbasic_vert:xf,meshbasic_frag:vf,meshlambert_vert:Mf,meshlambert_frag:Sf,meshmatcap_vert:Ef,meshmatcap_frag:yf,meshnormal_vert:bf,meshnormal_frag:Tf,meshphong_vert:Af,meshphong_frag:wf,meshphysical_vert:Rf,meshphysical_frag:Cf,meshtoon_vert:Pf,meshtoon_frag:Df,points_vert:Lf,points_frag:If,shadow_vert:Ff,shadow_frag:Uf,sprite_vert:Nf,sprite_frag:Of},oe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},qt={basic:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.fog]),vertexShader:Be.meshbasic_vert,fragmentShader:Be.meshbasic_frag},lambert:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},envMapIntensity:{value:1}}]),vertexShader:Be.meshlambert_vert,fragmentShader:Be.meshlambert_frag},phong:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Be.meshphong_vert,fragmentShader:Be.meshphong_frag},standard:{uniforms:yt([oe.common,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.roughnessmap,oe.metalnessmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag},toon:{uniforms:yt([oe.common,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.gradientmap,oe.fog,oe.lights,{emissive:{value:new tt(0)}}]),vertexShader:Be.meshtoon_vert,fragmentShader:Be.meshtoon_frag},matcap:{uniforms:yt([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,{matcap:{value:null}}]),vertexShader:Be.meshmatcap_vert,fragmentShader:Be.meshmatcap_frag},points:{uniforms:yt([oe.points,oe.fog]),vertexShader:Be.points_vert,fragmentShader:Be.points_frag},dashed:{uniforms:yt([oe.common,oe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Be.linedashed_vert,fragmentShader:Be.linedashed_frag},depth:{uniforms:yt([oe.common,oe.displacementmap]),vertexShader:Be.depth_vert,fragmentShader:Be.depth_frag},normal:{uniforms:yt([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,{opacity:{value:1}}]),vertexShader:Be.meshnormal_vert,fragmentShader:Be.meshnormal_frag},sprite:{uniforms:yt([oe.sprite,oe.fog]),vertexShader:Be.sprite_vert,fragmentShader:Be.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Be.background_vert,fragmentShader:Be.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Oe}},vertexShader:Be.backgroundCube_vert,fragmentShader:Be.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Be.cube_vert,fragmentShader:Be.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Be.equirect_vert,fragmentShader:Be.equirect_frag},distance:{uniforms:yt([oe.common,oe.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Be.distance_vert,fragmentShader:Be.distance_frag},shadow:{uniforms:yt([oe.lights,oe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:Be.shadow_vert,fragmentShader:Be.shadow_frag}};qt.physical={uniforms:yt([qt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag};const tr={r:0,b:0,g:0},In=new kn,Bf=new ft;function zf(n,e,t,i,r,s){const a=new tt(0);let o=r===!0?0:1,l,c,u=null,p=0,h=null;function d(S){let b=S.isScene===!0?S.background:null;if(b&&b.isTexture){const E=S.backgroundBlurriness>0;b=e.get(b,E)}return b}function g(S){let b=!1;const E=d(S);E===null?m(a,o):E&&E.isColor&&(m(E,1),b=!0);const R=n.xr.getEnvironmentBlendMode();R==="additive"?t.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(n.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function v(S,b){const E=d(b);E&&(E.isCubeTexture||E.mapping===pr)?(c===void 0&&(c=new Jt(new Di(1,1,1),new Qt({name:"BackgroundCubeMaterial",uniforms:ui(qt.backgroundCube.uniforms),vertexShader:qt.backgroundCube.vertexShader,fragmentShader:qt.backgroundCube.fragmentShader,side:At,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(R,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),In.copy(b.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),c.material.uniforms.envMap.value=E,c.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Bf.makeRotationFromEuler(In)),c.material.toneMapped=We.getTransfer(E.colorSpace)!==Ke,(u!==E||p!==E.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=E,p=E.version,h=n.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):E&&E.isTexture&&(l===void 0&&(l=new Jt(new gr(2,2),new Qt({name:"BackgroundMaterial",uniforms:ui(qt.background.uniforms),vertexShader:qt.background.vertexShader,fragmentShader:qt.background.fragmentShader,side:An,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=E,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=We.getTransfer(E.colorSpace)!==Ke,E.matrixAutoUpdate===!0&&E.updateMatrix(),l.material.uniforms.uvTransform.value.copy(E.matrix),(u!==E||p!==E.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=E,p=E.version,h=n.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function m(S,b){S.getRGB(tr,hl(n)),t.buffers.color.setClear(tr.r,tr.g,tr.b,b,s)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,b=1){a.set(S),o=b,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:g,addToRenderList:v,dispose:f}}function Gf(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null);let s=r,a=!1;function o(w,F,N,L,B){let H=!1;const O=p(w,L,N,F);s!==O&&(s=O,c(s.object)),H=d(w,L,N,B),H&&g(w,L,N,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(H||a)&&(a=!1,E(w,F,N,L),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(w){return n.bindVertexArray(w)}function u(w){return n.deleteVertexArray(w)}function p(w,F,N,L){const B=L.wireframe===!0;let H=i[F.id];H===void 0&&(H={},i[F.id]=H);const O=w.isInstancedMesh===!0?w.id:0;let J=H[O];J===void 0&&(J={},H[O]=J);let Z=J[N.id];Z===void 0&&(Z={},J[N.id]=Z);let le=Z[B];return le===void 0&&(le=h(l()),Z[B]=le),le}function h(w){const F=[],N=[],L=[];for(let B=0;B<t;B++)F[B]=0,N[B]=0,L[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:N,attributeDivisors:L,object:w,attributes:{},index:null}}function d(w,F,N,L){const B=s.attributes,H=F.attributes;let O=0;const J=N.getAttributes();for(const Z in J)if(J[Z].location>=0){const de=B[Z];let ue=H[Z];if(ue===void 0&&(Z==="instanceMatrix"&&w.instanceMatrix&&(ue=w.instanceMatrix),Z==="instanceColor"&&w.instanceColor&&(ue=w.instanceColor)),de===void 0||de.attribute!==ue||ue&&de.data!==ue.data)return!0;O++}return s.attributesNum!==O||s.index!==L}function g(w,F,N,L){const B={},H=F.attributes;let O=0;const J=N.getAttributes();for(const Z in J)if(J[Z].location>=0){let de=H[Z];de===void 0&&(Z==="instanceMatrix"&&w.instanceMatrix&&(de=w.instanceMatrix),Z==="instanceColor"&&w.instanceColor&&(de=w.instanceColor));const ue={};ue.attribute=de,de&&de.data&&(ue.data=de.data),B[Z]=ue,O++}s.attributes=B,s.attributesNum=O,s.index=L}function v(){const w=s.newAttributes;for(let F=0,N=w.length;F<N;F++)w[F]=0}function m(w){f(w,0)}function f(w,F){const N=s.newAttributes,L=s.enabledAttributes,B=s.attributeDivisors;N[w]=1,L[w]===0&&(n.enableVertexAttribArray(w),L[w]=1),B[w]!==F&&(n.vertexAttribDivisor(w,F),B[w]=F)}function S(){const w=s.newAttributes,F=s.enabledAttributes;for(let N=0,L=F.length;N<L;N++)F[N]!==w[N]&&(n.disableVertexAttribArray(N),F[N]=0)}function b(w,F,N,L,B,H,O){O===!0?n.vertexAttribIPointer(w,F,N,B,H):n.vertexAttribPointer(w,F,N,L,B,H)}function E(w,F,N,L){v();const B=L.attributes,H=N.getAttributes(),O=F.defaultAttributeValues;for(const J in H){const Z=H[J];if(Z.location>=0){let le=B[J];if(le===void 0&&(J==="instanceMatrix"&&w.instanceMatrix&&(le=w.instanceMatrix),J==="instanceColor"&&w.instanceColor&&(le=w.instanceColor)),le!==void 0){const de=le.normalized,ue=le.itemSize,Pe=e.get(le);if(Pe===void 0)continue;const nt=Pe.buffer,Je=Pe.type,j=Pe.bytesPerElement,te=Je===n.INT||Je===n.UNSIGNED_INT||le.gpuType===na;if(le.isInterleavedBufferAttribute){const re=le.data,De=re.stride,Ae=le.offset;if(re.isInstancedInterleavedBuffer){for(let we=0;we<Z.locationSize;we++)f(Z.location+we,re.meshPerAttribute);w.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let we=0;we<Z.locationSize;we++)m(Z.location+we);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let we=0;we<Z.locationSize;we++)b(Z.location+we,ue/Z.locationSize,Je,de,De*j,(Ae+ue/Z.locationSize*we)*j,te)}else{if(le.isInstancedBufferAttribute){for(let re=0;re<Z.locationSize;re++)f(Z.location+re,le.meshPerAttribute);w.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let re=0;re<Z.locationSize;re++)m(Z.location+re);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let re=0;re<Z.locationSize;re++)b(Z.location+re,ue/Z.locationSize,Je,de,ue*j,ue/Z.locationSize*re*j,te)}}else if(O!==void 0){const de=O[J];if(de!==void 0)switch(de.length){case 2:n.vertexAttrib2fv(Z.location,de);break;case 3:n.vertexAttrib3fv(Z.location,de);break;case 4:n.vertexAttrib4fv(Z.location,de);break;default:n.vertexAttrib1fv(Z.location,de)}}}}S()}function R(){y();for(const w in i){const F=i[w];for(const N in F){const L=F[N];for(const B in L){const H=L[B];for(const O in H)u(H[O].object),delete H[O];delete L[B]}}delete i[w]}}function A(w){if(i[w.id]===void 0)return;const F=i[w.id];for(const N in F){const L=F[N];for(const B in L){const H=L[B];for(const O in H)u(H[O].object),delete H[O];delete L[B]}}delete i[w.id]}function C(w){for(const F in i){const N=i[F];for(const L in N){const B=N[L];if(B[w.id]===void 0)continue;const H=B[w.id];for(const O in H)u(H[O].object),delete H[O];delete B[w.id]}}}function x(w){for(const F in i){const N=i[F],L=w.isInstancedMesh===!0?w.id:0,B=N[L];if(B!==void 0){for(const H in B){const O=B[H];for(const J in O)u(O[J].object),delete O[J];delete B[H]}delete N[L],Object.keys(N).length===0&&delete i[F]}}}function y(){G(),a=!0,s!==r&&(s=r,c(s.object))}function G(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:y,resetDefaultState:G,dispose:R,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:m,disableUnusedAttributes:S}}function Vf(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,p){p!==0&&(n.drawArraysInstanced(i,c,u,p),t.update(u,i,p))}function o(c,u,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,p);let d=0;for(let g=0;g<p;g++)d+=u[g];t.update(d,i,1)}function l(c,u,p,h){if(p===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let g=0;g<c.length;g++)a(c[g],u[g],h[g]);else{d.multiDrawArraysInstancedWEBGL(i,c,0,u,0,h,0,p);let g=0;for(let v=0;v<p;v++)g+=u[v]*h[v];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Hf(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){return!(C!==zt&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const x=C===pn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==It&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Yt&&!x)}function l(C){if(C==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Le("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const p=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),S=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),R=n.getParameter(n.MAX_SAMPLES),A=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:p,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:S,maxVaryings:b,maxFragmentUniforms:E,maxSamples:R,samples:A}}function kf(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new Un,o=new Oe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(p,h){const d=p.length!==0||h||i!==0||r;return r=h,i=p.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(p,h){t=u(p,h,0)},this.setState=function(p,h,d){const g=p.clippingPlanes,v=p.clipIntersection,m=p.clipShadows,f=n.get(p);if(!r||g===null||g.length===0||s&&!m)s?u(null):c();else{const S=s?0:i,b=S*4;let E=f.clippingState||null;l.value=E,E=u(g,h,b,d);for(let R=0;R!==b;++R)E[R]=t[R];f.clippingState=E,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(p,h,d,g){const v=p!==null?p.length:0;let m=null;if(v!==0){if(m=l.value,g!==!0||m===null){const f=d+v*4,S=h.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<f)&&(m=new Float32Array(f));for(let b=0,E=d;b!==v;++b,E+=4)a.copy(p[b]).applyMatrix4(S,o),a.normal.toArray(m,E),m[E+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const Tn=4,ja=[.125,.215,.35,.446,.526,.582],On=20,Wf=256,Si=new fa,$a=new tt;let Zr=null,Kr=0,Jr=0,Qr=!1;const Xf=new k;class Za{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,s={}){const{size:a=256,position:o=Xf}=s;Zr=this._renderer.getRenderTarget(),Kr=this._renderer.getActiveCubeFace(),Jr=this._renderer.getActiveMipmapLevel(),Qr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Qa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ja(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Zr,Kr,Jr),this._renderer.xr.enabled=Qr,e.scissorTest=!1,si(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Vn||e.mapping===ci?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Zr=this._renderer.getRenderTarget(),Kr=this._renderer.getActiveCubeFace(),Jr=this._renderer.getActiveMipmapLevel(),Qr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Et,minFilter:Et,generateMipmaps:!1,type:pn,format:zt,colorSpace:Hn,depthBuffer:!1},r=Ka(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ka(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=qf(s)),this._blurMaterial=jf(s,e,t),this._ggxMaterial=Yf(s,e,t)}return r}_compileMaterial(e){const t=new Jt(new en,e);this._renderer.compile(t,Si)}_sceneToCubeUV(e,t,i,r,s){const l=new Bt(90,1,t,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],p=this._renderer,h=p.autoClear,d=p.toneMapping;p.getClearColor($a),p.toneMapping=$t,p.autoClear=!1,p.state.buffers.depth.getReversed()&&(p.setRenderTarget(r),p.clearDepth(),p.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Jt(new Di,new al({name:"PMREM.Background",side:At,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let f=!1;const S=e.background;S?S.isColor&&(m.color.copy(S),e.background=null,f=!0):(m.color.copy($a),f=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[b],s.y,s.z)):E===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[b]));const R=this._cubeSize;si(r,E*R,b>2?R:0,R,R),p.setRenderTarget(r),f&&p.render(v,l),p.render(e,l)}p.toneMapping=d,p.autoClear=h,e.background=S}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Vn||e.mapping===ci;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qa()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ja());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;si(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Si)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),p=Math.sqrt(c*c-u*u),h=0+c*1.25,d=p*h,{_lodMax:g}=this,v=this._sizeLods[i],m=3*v*(i>g-Tn?i-g+Tn:0),f=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=d,l.mipInt.value=g-t,si(s,m,f,3*v,2*v),r.setRenderTarget(s),r.render(o,Si),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-i,si(e,m,f,3*v,2*v),r.setRenderTarget(e),r.render(o,Si)}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&qe("blur direction must be either latitudinal or longitudinal!");const u=3,p=this._lodMeshes[r];p.material=c;const h=c.uniforms,d=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*On-1),v=s/g,m=isFinite(s)?1+Math.floor(u*v):On;m>On&&Le(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${On}`);const f=[];let S=0;for(let C=0;C<On;++C){const x=C/v,y=Math.exp(-x*x/2);f.push(y),C===0?S+=y:C<m&&(S+=2*y)}for(let C=0;C<f.length;C++)f[C]=f[C]/S;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);const{_lodMax:b}=this;h.dTheta.value=g,h.mipInt.value=b-i;const E=this._sizeLods[r],R=3*E*(r>b-Tn?r-b+Tn:0),A=4*(this._cubeSize-E);si(t,R,A,3*E,2*E),l.setRenderTarget(t),l.render(p,Si)}}function qf(n){const e=[],t=[],i=[];let r=n;const s=n-Tn+1+ja.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>n-Tn?l=ja[a-n+Tn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,p=1+c,h=[u,u,p,u,p,p,u,u,p,p,u,p],d=6,g=6,v=3,m=2,f=1,S=new Float32Array(v*g*d),b=new Float32Array(m*g*d),E=new Float32Array(f*g*d);for(let A=0;A<d;A++){const C=A%3*2/3-1,x=A>2?0:-1,y=[C,x,0,C+2/3,x,0,C+2/3,x+1,0,C,x,0,C+2/3,x+1,0,C,x+1,0];S.set(y,v*g*A),b.set(h,m*g*A);const G=[A,A,A,A,A,A];E.set(G,f*g*A)}const R=new en;R.setAttribute("position",new Vt(S,v)),R.setAttribute("uv",new Vt(b,m)),R.setAttribute("faceIndex",new Vt(E,f)),i.push(new Jt(R,null)),r>Tn&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Ka(n,e,t){const i=new Zt(n,e,t);return i.texture.mapping=pr,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function si(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function Yf(n,e,t){return new Qt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Wf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:_r(),fragmentShader:`
3612
+ }`,Be={alphahash_fragment:sh,alphahash_pars_fragment:ah,alphamap_fragment:oh,alphamap_pars_fragment:lh,alphatest_fragment:ch,alphatest_pars_fragment:hh,aomap_fragment:uh,aomap_pars_fragment:fh,batching_pars_vertex:dh,batching_vertex:ph,begin_vertex:mh,beginnormal_vertex:gh,bsdfs:_h,iridescence_fragment:xh,bumpmap_pars_fragment:vh,clipping_planes_fragment:Mh,clipping_planes_pars_fragment:Sh,clipping_planes_pars_vertex:Eh,clipping_planes_vertex:yh,color_fragment:bh,color_pars_fragment:Th,color_pars_vertex:Ah,color_vertex:wh,common:Rh,cube_uv_reflection_fragment:Ch,defaultnormal_vertex:Ph,displacementmap_pars_vertex:Dh,displacementmap_vertex:Lh,emissivemap_fragment:Ih,emissivemap_pars_fragment:Fh,colorspace_fragment:Uh,colorspace_pars_fragment:Nh,envmap_fragment:Oh,envmap_common_pars_fragment:Bh,envmap_pars_fragment:zh,envmap_pars_vertex:Gh,envmap_physical_pars_fragment:Kh,envmap_vertex:Vh,fog_vertex:Hh,fog_pars_vertex:kh,fog_fragment:Wh,fog_pars_fragment:Xh,gradientmap_pars_fragment:qh,lightmap_pars_fragment:Yh,lights_lambert_fragment:jh,lights_lambert_pars_fragment:$h,lights_pars_begin:Zh,lights_toon_fragment:Jh,lights_toon_pars_fragment:Qh,lights_phong_fragment:eu,lights_phong_pars_fragment:tu,lights_physical_fragment:nu,lights_physical_pars_fragment:iu,lights_fragment_begin:ru,lights_fragment_maps:su,lights_fragment_end:au,logdepthbuf_fragment:ou,logdepthbuf_pars_fragment:lu,logdepthbuf_pars_vertex:cu,logdepthbuf_vertex:hu,map_fragment:uu,map_pars_fragment:fu,map_particle_fragment:du,map_particle_pars_fragment:pu,metalnessmap_fragment:mu,metalnessmap_pars_fragment:gu,morphinstance_vertex:_u,morphcolor_vertex:xu,morphnormal_vertex:vu,morphtarget_pars_vertex:Mu,morphtarget_vertex:Su,normal_fragment_begin:Eu,normal_fragment_maps:yu,normal_pars_fragment:bu,normal_pars_vertex:Tu,normal_vertex:Au,normalmap_pars_fragment:wu,clearcoat_normal_fragment_begin:Ru,clearcoat_normal_fragment_maps:Cu,clearcoat_pars_fragment:Pu,iridescence_pars_fragment:Du,opaque_fragment:Lu,packing:Iu,premultiplied_alpha_fragment:Fu,project_vertex:Uu,dithering_fragment:Nu,dithering_pars_fragment:Ou,roughnessmap_fragment:Bu,roughnessmap_pars_fragment:zu,shadowmap_pars_fragment:Gu,shadowmap_pars_vertex:Vu,shadowmap_vertex:Hu,shadowmask_pars_fragment:ku,skinbase_vertex:Wu,skinning_pars_vertex:Xu,skinning_vertex:qu,skinnormal_vertex:Yu,specularmap_fragment:ju,specularmap_pars_fragment:$u,tonemapping_fragment:Zu,tonemapping_pars_fragment:Ku,transmission_fragment:Ju,transmission_pars_fragment:Qu,uv_pars_fragment:ef,uv_pars_vertex:tf,uv_vertex:nf,worldpos_vertex:rf,background_vert:sf,background_frag:af,backgroundCube_vert:of,backgroundCube_frag:lf,cube_vert:cf,cube_frag:hf,depth_vert:uf,depth_frag:ff,distance_vert:df,distance_frag:pf,equirect_vert:mf,equirect_frag:gf,linedashed_vert:_f,linedashed_frag:xf,meshbasic_vert:vf,meshbasic_frag:Mf,meshlambert_vert:Sf,meshlambert_frag:Ef,meshmatcap_vert:yf,meshmatcap_frag:bf,meshnormal_vert:Tf,meshnormal_frag:Af,meshphong_vert:wf,meshphong_frag:Rf,meshphysical_vert:Cf,meshphysical_frag:Pf,meshtoon_vert:Df,meshtoon_frag:Lf,points_vert:If,points_frag:Ff,shadow_vert:Uf,shadow_frag:Nf,sprite_vert:Of,sprite_frag:Bf},oe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new $e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},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 tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new $e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},qt={basic:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.fog]),vertexShader:Be.meshbasic_vert,fragmentShader:Be.meshbasic_frag},lambert:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},envMapIntensity:{value:1}}]),vertexShader:Be.meshlambert_vert,fragmentShader:Be.meshlambert_frag},phong:{uniforms:yt([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Be.meshphong_vert,fragmentShader:Be.meshphong_frag},standard:{uniforms:yt([oe.common,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.roughnessmap,oe.metalnessmap,oe.fog,oe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag},toon:{uniforms:yt([oe.common,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.gradientmap,oe.fog,oe.lights,{emissive:{value:new tt(0)}}]),vertexShader:Be.meshtoon_vert,fragmentShader:Be.meshtoon_frag},matcap:{uniforms:yt([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,{matcap:{value:null}}]),vertexShader:Be.meshmatcap_vert,fragmentShader:Be.meshmatcap_frag},points:{uniforms:yt([oe.points,oe.fog]),vertexShader:Be.points_vert,fragmentShader:Be.points_frag},dashed:{uniforms:yt([oe.common,oe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Be.linedashed_vert,fragmentShader:Be.linedashed_frag},depth:{uniforms:yt([oe.common,oe.displacementmap]),vertexShader:Be.depth_vert,fragmentShader:Be.depth_frag},normal:{uniforms:yt([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,{opacity:{value:1}}]),vertexShader:Be.meshnormal_vert,fragmentShader:Be.meshnormal_frag},sprite:{uniforms:yt([oe.sprite,oe.fog]),vertexShader:Be.sprite_vert,fragmentShader:Be.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Be.background_vert,fragmentShader:Be.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Oe}},vertexShader:Be.backgroundCube_vert,fragmentShader:Be.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Be.cube_vert,fragmentShader:Be.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Be.equirect_vert,fragmentShader:Be.equirect_frag},distance:{uniforms:yt([oe.common,oe.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Be.distance_vert,fragmentShader:Be.distance_frag},shadow:{uniforms:yt([oe.lights,oe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:Be.shadow_vert,fragmentShader:Be.shadow_frag}};qt.physical={uniforms:yt([qt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new $e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new $e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new $e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag};const nr={r:0,b:0,g:0},In=new kn,zf=new ft;function Gf(n,e,t,i,r,s){const a=new tt(0);let o=r===!0?0:1,l,c,u=null,m=0,h=null;function p(S){let b=S.isScene===!0?S.background:null;if(b&&b.isTexture){const E=S.backgroundBlurriness>0;b=e.get(b,E)}return b}function g(S){let b=!1;const E=p(S);E===null?d(a,o):E&&E.isColor&&(d(E,1),b=!0);const R=n.xr.getEnvironmentBlendMode();R==="additive"?t.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(n.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function v(S,b){const E=p(b);E&&(E.isCubeTexture||E.mapping===mr)?(c===void 0&&(c=new Jt(new Li(1,1,1),new Qt({name:"BackgroundCubeMaterial",uniforms:ui(qt.backgroundCube.uniforms),vertexShader:qt.backgroundCube.vertexShader,fragmentShader:qt.backgroundCube.fragmentShader,side:At,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(R,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),In.copy(b.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),c.material.uniforms.envMap.value=E,c.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(zf.makeRotationFromEuler(In)),c.material.toneMapped=We.getTransfer(E.colorSpace)!==Ke,(u!==E||m!==E.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=E,m=E.version,h=n.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):E&&E.isTexture&&(l===void 0&&(l=new Jt(new _r(2,2),new Qt({name:"BackgroundMaterial",uniforms:ui(qt.background.uniforms),vertexShader:qt.background.vertexShader,fragmentShader:qt.background.fragmentShader,side:An,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=E,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=We.getTransfer(E.colorSpace)!==Ke,E.matrixAutoUpdate===!0&&E.updateMatrix(),l.material.uniforms.uvTransform.value.copy(E.matrix),(u!==E||m!==E.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=E,m=E.version,h=n.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function d(S,b){S.getRGB(nr,hl(n)),t.buffers.color.setClear(nr.r,nr.g,nr.b,b,s)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,b=1){a.set(S),o=b,d(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,d(a,o)},render:g,addToRenderList:v,dispose:f}}function Vf(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null);let s=r,a=!1;function o(w,F,N,L,B){let H=!1;const O=m(w,L,N,F);s!==O&&(s=O,c(s.object)),H=p(w,L,N,B),H&&g(w,L,N,B),B!==null&&e.update(B,n.ELEMENT_ARRAY_BUFFER),(H||a)&&(a=!1,E(w,F,N,L),B!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(B).buffer))}function l(){return n.createVertexArray()}function c(w){return n.bindVertexArray(w)}function u(w){return n.deleteVertexArray(w)}function m(w,F,N,L){const B=L.wireframe===!0;let H=i[F.id];H===void 0&&(H={},i[F.id]=H);const O=w.isInstancedMesh===!0?w.id:0;let J=H[O];J===void 0&&(J={},H[O]=J);let Z=J[N.id];Z===void 0&&(Z={},J[N.id]=Z);let le=Z[B];return le===void 0&&(le=h(l()),Z[B]=le),le}function h(w){const F=[],N=[],L=[];for(let B=0;B<t;B++)F[B]=0,N[B]=0,L[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:N,attributeDivisors:L,object:w,attributes:{},index:null}}function p(w,F,N,L){const B=s.attributes,H=F.attributes;let O=0;const J=N.getAttributes();for(const Z in J)if(J[Z].location>=0){const de=B[Z];let ue=H[Z];if(ue===void 0&&(Z==="instanceMatrix"&&w.instanceMatrix&&(ue=w.instanceMatrix),Z==="instanceColor"&&w.instanceColor&&(ue=w.instanceColor)),de===void 0||de.attribute!==ue||ue&&de.data!==ue.data)return!0;O++}return s.attributesNum!==O||s.index!==L}function g(w,F,N,L){const B={},H=F.attributes;let O=0;const J=N.getAttributes();for(const Z in J)if(J[Z].location>=0){let de=H[Z];de===void 0&&(Z==="instanceMatrix"&&w.instanceMatrix&&(de=w.instanceMatrix),Z==="instanceColor"&&w.instanceColor&&(de=w.instanceColor));const ue={};ue.attribute=de,de&&de.data&&(ue.data=de.data),B[Z]=ue,O++}s.attributes=B,s.attributesNum=O,s.index=L}function v(){const w=s.newAttributes;for(let F=0,N=w.length;F<N;F++)w[F]=0}function d(w){f(w,0)}function f(w,F){const N=s.newAttributes,L=s.enabledAttributes,B=s.attributeDivisors;N[w]=1,L[w]===0&&(n.enableVertexAttribArray(w),L[w]=1),B[w]!==F&&(n.vertexAttribDivisor(w,F),B[w]=F)}function S(){const w=s.newAttributes,F=s.enabledAttributes;for(let N=0,L=F.length;N<L;N++)F[N]!==w[N]&&(n.disableVertexAttribArray(N),F[N]=0)}function b(w,F,N,L,B,H,O){O===!0?n.vertexAttribIPointer(w,F,N,B,H):n.vertexAttribPointer(w,F,N,L,B,H)}function E(w,F,N,L){v();const B=L.attributes,H=N.getAttributes(),O=F.defaultAttributeValues;for(const J in H){const Z=H[J];if(Z.location>=0){let le=B[J];if(le===void 0&&(J==="instanceMatrix"&&w.instanceMatrix&&(le=w.instanceMatrix),J==="instanceColor"&&w.instanceColor&&(le=w.instanceColor)),le!==void 0){const de=le.normalized,ue=le.itemSize,Pe=e.get(le);if(Pe===void 0)continue;const nt=Pe.buffer,Je=Pe.type,j=Pe.bytesPerElement,te=Je===n.INT||Je===n.UNSIGNED_INT||le.gpuType===ta;if(le.isInterleavedBufferAttribute){const re=le.data,De=re.stride,Ae=le.offset;if(re.isInstancedInterleavedBuffer){for(let we=0;we<Z.locationSize;we++)f(Z.location+we,re.meshPerAttribute);w.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let we=0;we<Z.locationSize;we++)d(Z.location+we);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let we=0;we<Z.locationSize;we++)b(Z.location+we,ue/Z.locationSize,Je,de,De*j,(Ae+ue/Z.locationSize*we)*j,te)}else{if(le.isInstancedBufferAttribute){for(let re=0;re<Z.locationSize;re++)f(Z.location+re,le.meshPerAttribute);w.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let re=0;re<Z.locationSize;re++)d(Z.location+re);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let re=0;re<Z.locationSize;re++)b(Z.location+re,ue/Z.locationSize,Je,de,ue*j,ue/Z.locationSize*re*j,te)}}else if(O!==void 0){const de=O[J];if(de!==void 0)switch(de.length){case 2:n.vertexAttrib2fv(Z.location,de);break;case 3:n.vertexAttrib3fv(Z.location,de);break;case 4:n.vertexAttrib4fv(Z.location,de);break;default:n.vertexAttrib1fv(Z.location,de)}}}}S()}function R(){y();for(const w in i){const F=i[w];for(const N in F){const L=F[N];for(const B in L){const H=L[B];for(const O in H)u(H[O].object),delete H[O];delete L[B]}}delete i[w]}}function A(w){if(i[w.id]===void 0)return;const F=i[w.id];for(const N in F){const L=F[N];for(const B in L){const H=L[B];for(const O in H)u(H[O].object),delete H[O];delete L[B]}}delete i[w.id]}function C(w){for(const F in i){const N=i[F];for(const L in N){const B=N[L];if(B[w.id]===void 0)continue;const H=B[w.id];for(const O in H)u(H[O].object),delete H[O];delete B[w.id]}}}function x(w){for(const F in i){const N=i[F],L=w.isInstancedMesh===!0?w.id:0,B=N[L];if(B!==void 0){for(const H in B){const O=B[H];for(const J in O)u(O[J].object),delete O[J];delete B[H]}delete N[L],Object.keys(N).length===0&&delete i[F]}}}function y(){G(),a=!0,s!==r&&(s=r,c(s.object))}function G(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:y,resetDefaultState:G,dispose:R,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:d,disableUnusedAttributes:S}}function Hf(n,e,t){let i;function r(c){i=c}function s(c,u){n.drawArrays(i,c,u),t.update(u,i,1)}function a(c,u,m){m!==0&&(n.drawArraysInstanced(i,c,u,m),t.update(u,i,m))}function o(c,u,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,m);let p=0;for(let g=0;g<m;g++)p+=u[g];t.update(p,i,1)}function l(c,u,m,h){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)a(c[g],u[g],h[g]);else{p.multiDrawArraysInstancedWEBGL(i,c,0,u,0,h,0,m);let g=0;for(let v=0;v<m;v++)g+=u[v]*h[v];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function kf(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){return!(C!==zt&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const x=C===pn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==It&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Yt&&!x)}function l(C){if(C==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Le("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),d=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),f=n.getParameter(n.MAX_VERTEX_ATTRIBS),S=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),R=n.getParameter(n.MAX_SAMPLES),A=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:S,maxVaryings:b,maxFragmentUniforms:E,maxSamples:R,samples:A}}function Wf(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new Un,o=new Oe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const p=m.length!==0||h||i!==0||r;return r=h,i=m.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(m,h){t=u(m,h,0)},this.setState=function(m,h,p){const g=m.clippingPlanes,v=m.clipIntersection,d=m.clipShadows,f=n.get(m);if(!r||g===null||g.length===0||s&&!d)s?u(null):c();else{const S=s?0:i,b=S*4;let E=f.clippingState||null;l.value=E,E=u(g,h,b,p);for(let R=0;R!==b;++R)E[R]=t[R];f.clippingState=E,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(m,h,p,g){const v=m!==null?m.length:0;let d=null;if(v!==0){if(d=l.value,g!==!0||d===null){const f=p+v*4,S=h.matrixWorldInverse;o.getNormalMatrix(S),(d===null||d.length<f)&&(d=new Float32Array(f));for(let b=0,E=p;b!==v;++b,E+=4)a.copy(m[b]).applyMatrix4(S,o),a.normal.toArray(d,E),d[E+3]=a.constant}l.value=d,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,d}}const Tn=4,ja=[.125,.215,.35,.446,.526,.582],On=20,Xf=256,Ei=new ua,$a=new tt;let Zr=null,Kr=0,Jr=0,Qr=!1;const qf=new k;class Za{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,s={}){const{size:a=256,position:o=qf}=s;Zr=this._renderer.getRenderTarget(),Kr=this._renderer.getActiveCubeFace(),Jr=this._renderer.getActiveMipmapLevel(),Qr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Qa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ja(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Zr,Kr,Jr),this._renderer.xr.enabled=Qr,e.scissorTest=!1,si(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Vn||e.mapping===ci?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Zr=this._renderer.getRenderTarget(),Kr=this._renderer.getActiveCubeFace(),Jr=this._renderer.getActiveMipmapLevel(),Qr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Et,minFilter:Et,generateMipmaps:!1,type:pn,format:zt,colorSpace:Hn,depthBuffer:!1},r=Ka(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ka(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Yf(s)),this._blurMaterial=$f(s,e,t),this._ggxMaterial=jf(s,e,t)}return r}_compileMaterial(e){const t=new Jt(new en,e);this._renderer.compile(t,Ei)}_sceneToCubeUV(e,t,i,r,s){const l=new Bt(90,1,t,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],m=this._renderer,h=m.autoClear,p=m.toneMapping;m.getClearColor($a),m.toneMapping=$t,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Jt(new Li,new al({name:"PMREM.Background",side:At,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,d=v.material;let f=!1;const S=e.background;S?S.isColor&&(d.color.copy(S),e.background=null,f=!0):(d.color.copy($a),f=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[b],s.y,s.z)):E===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[b]));const R=this._cubeSize;si(r,E*R,b>2?R:0,R,R),m.setRenderTarget(r),f&&m.render(v,l),m.render(e,l)}m.toneMapping=p,m.autoClear=h,e.background=S}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Vn||e.mapping===ci;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qa()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ja());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;si(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Ei)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),m=Math.sqrt(c*c-u*u),h=0+c*1.25,p=m*h,{_lodMax:g}=this,v=this._sizeLods[i],d=3*v*(i>g-Tn?i-g+Tn:0),f=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=g-t,si(s,d,f,3*v,2*v),r.setRenderTarget(s),r.render(o,Ei),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-i,si(e,d,f,3*v,2*v),r.setRenderTarget(e),r.render(o,Ei)}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&qe("blur direction must be either latitudinal or longitudinal!");const u=3,m=this._lodMeshes[r];m.material=c;const h=c.uniforms,p=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*On-1),v=s/g,d=isFinite(s)?1+Math.floor(u*v):On;d>On&&Le(`sigmaRadians, ${s}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${On}`);const f=[];let S=0;for(let C=0;C<On;++C){const x=C/v,y=Math.exp(-x*x/2);f.push(y),C===0?S+=y:C<d&&(S+=2*y)}for(let C=0;C<f.length;C++)f[C]=f[C]/S;h.envMap.value=e.texture,h.samples.value=d,h.weights.value=f,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);const{_lodMax:b}=this;h.dTheta.value=g,h.mipInt.value=b-i;const E=this._sizeLods[r],R=3*E*(r>b-Tn?r-b+Tn:0),A=4*(this._cubeSize-E);si(t,R,A,3*E,2*E),l.setRenderTarget(t),l.render(m,Ei)}}function Yf(n){const e=[],t=[],i=[];let r=n;const s=n-Tn+1+ja.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>n-Tn?l=ja[a-n+Tn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,m=1+c,h=[u,u,m,u,m,m,u,u,m,m,u,m],p=6,g=6,v=3,d=2,f=1,S=new Float32Array(v*g*p),b=new Float32Array(d*g*p),E=new Float32Array(f*g*p);for(let A=0;A<p;A++){const C=A%3*2/3-1,x=A>2?0:-1,y=[C,x,0,C+2/3,x,0,C+2/3,x+1,0,C,x,0,C+2/3,x+1,0,C,x+1,0];S.set(y,v*g*A),b.set(h,d*g*A);const G=[A,A,A,A,A,A];E.set(G,f*g*A)}const R=new en;R.setAttribute("position",new Vt(S,v)),R.setAttribute("uv",new Vt(b,d)),R.setAttribute("faceIndex",new Vt(E,f)),i.push(new Jt(R,null)),r>Tn&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Ka(n,e,t){const i=new Zt(n,e,t);return i.texture.mapping=mr,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function si(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function jf(n,e,t){return new Qt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Xf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:xr(),fragmentShader:`
3613
3613
 
3614
3614
  precision highp float;
3615
3615
  precision highp int;
@@ -3713,7 +3713,7 @@ void main() {
3713
3713
 
3714
3714
  gl_FragColor = vec4(prefilteredColor, 1.0);
3715
3715
  }
3716
- `,blending:un,depthTest:!1,depthWrite:!1})}function jf(n,e,t){const i=new Float32Array(On),r=new k(0,1,0);return new Qt({name:"SphericalGaussianBlur",defines:{n:On,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:_r(),fragmentShader:`
3716
+ `,blending:un,depthTest:!1,depthWrite:!1})}function $f(n,e,t){const i=new Float32Array(On),r=new k(0,1,0);return new Qt({name:"SphericalGaussianBlur",defines:{n:On,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:xr(),fragmentShader:`
3717
3717
 
3718
3718
  precision mediump float;
3719
3719
  precision mediump int;
@@ -3773,7 +3773,7 @@ void main() {
3773
3773
  }
3774
3774
 
3775
3775
  }
3776
- `,blending:un,depthTest:!1,depthWrite:!1})}function Ja(){return new Qt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_r(),fragmentShader:`
3776
+ `,blending:un,depthTest:!1,depthWrite:!1})}function Ja(){return new Qt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:xr(),fragmentShader:`
3777
3777
 
3778
3778
  precision mediump float;
3779
3779
  precision mediump int;
@@ -3792,7 +3792,7 @@ void main() {
3792
3792
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3793
3793
 
3794
3794
  }
3795
- `,blending:un,depthTest:!1,depthWrite:!1})}function Qa(){return new Qt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_r(),fragmentShader:`
3795
+ `,blending:un,depthTest:!1,depthWrite:!1})}function Qa(){return new Qt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:xr(),fragmentShader:`
3796
3796
 
3797
3797
  precision mediump float;
3798
3798
  precision mediump int;
@@ -3808,7 +3808,7 @@ void main() {
3808
3808
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3809
3809
 
3810
3810
  }
3811
- `,blending:un,depthTest:!1,depthWrite:!1})}function _r(){return`
3811
+ `,blending:un,depthTest:!1,depthWrite:!1})}function xr(){return`
3812
3812
 
3813
3813
  precision mediump float;
3814
3814
  precision mediump int;
@@ -3898,7 +3898,7 @@ void main() {
3898
3898
  gl_FragColor = texture2D( tEquirect, sampleUV );
3899
3899
 
3900
3900
  }
3901
- `},r=new Di(5,5,5),s=new Qt({name:"CubemapFromEquirect",uniforms:ui(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:At,blending:un});s.uniforms.tEquirect.value=t;const a=new Jt(r,s),o=t.minFilter;return t.minFilter===Bn&&(t.minFilter=Et),new Qc(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}function $f(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,d=!1){return h==null?null:d?a(h):s(h)}function s(h){if(h&&h.isTexture){const d=h.mapping;if(d===yr||d===br)if(e.has(h)){const g=e.get(h).texture;return o(g,h.mapping)}else{const g=h.image;if(g&&g.height>0){const v=new pl(g.height);return v.fromEquirectangularTexture(n,h),e.set(h,v),h.addEventListener("dispose",c),o(v.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const d=h.mapping,g=d===yr||d===br,v=d===Vn||d===ci;if(g||v){let m=t.get(h);const f=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f)return i===null&&(i=new Za(n)),m=g?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const S=h.image;return g&&S&&S.height>0||v&&S&&l(S)?(i===null&&(i=new Za(n)),m=g?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,d){return d===yr?h.mapping=Vn:d===br&&(h.mapping=ci),h}function l(h){let d=0;const g=6;for(let v=0;v<g;v++)h[v]!==void 0&&d++;return d===g}function c(h){const d=h.target;d.removeEventListener("dispose",c);const g=e.get(d);g!==void 0&&(e.delete(d),g.dispose())}function u(h){const d=h.target;d.removeEventListener("dispose",u);const g=t.get(d);g!==void 0&&(t.delete(d),g.dispose())}function p(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:p}}function Zf(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&fr("WebGLRenderer: "+i+" extension not supported."),r}}}function Kf(n,e,t,i){const r={},s=new WeakMap;function a(p){const h=p.target;h.index!==null&&e.remove(h.index);for(const g in h.attributes)e.remove(h.attributes[g]);h.removeEventListener("dispose",a),delete r[h.id];const d=s.get(h);d&&(e.remove(d),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(p,h){return r[h.id]===!0||(h.addEventListener("dispose",a),r[h.id]=!0,t.memory.geometries++),h}function l(p){const h=p.attributes;for(const d in h)e.update(h[d],n.ARRAY_BUFFER)}function c(p){const h=[],d=p.index,g=p.attributes.position;let v=0;if(g===void 0)return;if(d!==null){const S=d.array;v=d.version;for(let b=0,E=S.length;b<E;b+=3){const R=S[b+0],A=S[b+1],C=S[b+2];h.push(R,A,A,C,C,R)}}else{const S=g.array;v=g.version;for(let b=0,E=S.length/3-1;b<E;b+=3){const R=b+0,A=b+1,C=b+2;h.push(R,A,A,C,C,R)}}const m=new(g.count>=65535?sl:rl)(h,1);m.version=v;const f=s.get(p);f&&e.remove(f),s.set(p,m)}function u(p){const h=s.get(p);if(h){const d=p.index;d!==null&&h.version<d.version&&c(p)}else c(p);return s.get(p)}return{get:o,update:l,getWireframeAttribute:u}}function Jf(n,e,t){let i;function r(h){i=h}let s,a;function o(h){s=h.type,a=h.bytesPerElement}function l(h,d){n.drawElements(i,d,s,h*a),t.update(d,i,1)}function c(h,d,g){g!==0&&(n.drawElementsInstanced(i,d,s,h*a,g),t.update(d,i,g))}function u(h,d,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,h,0,g);let m=0;for(let f=0;f<g;f++)m+=d[f];t.update(m,i,1)}function p(h,d,g,v){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<h.length;f++)c(h[f]/a,d[f],v[f]);else{m.multiDrawElementsInstancedWEBGL(i,d,0,s,h,0,v,0,g);let f=0;for(let S=0;S<g;S++)f+=d[S]*v[S];t.update(f,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=p}function Qf(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:qe("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function ed(n,e,t){const i=new WeakMap,r=new ct;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,p=u!==void 0?u.length:0;let h=i.get(o);if(h===void 0||h.count!==p){let y=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",y)};h!==void 0&&h.texture.dispose();const d=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let b=0;d===!0&&(b=1),g===!0&&(b=2),v===!0&&(b=3);let E=o.attributes.position.count*b,R=1;E>e.maxTextureSize&&(R=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*R*4*p),C=new el(A,E,R,p);C.type=Yt,C.needsUpdate=!0;const x=b*4;for(let G=0;G<p;G++){const w=m[G],F=f[G],N=S[G],L=E*R*4*G;for(let B=0;B<w.count;B++){const H=B*x;d===!0&&(r.fromBufferAttribute(w,B),A[L+H+0]=r.x,A[L+H+1]=r.y,A[L+H+2]=r.z,A[L+H+3]=0),g===!0&&(r.fromBufferAttribute(F,B),A[L+H+4]=r.x,A[L+H+5]=r.y,A[L+H+6]=r.z,A[L+H+7]=0),v===!0&&(r.fromBufferAttribute(N,B),A[L+H+8]=r.x,A[L+H+9]=r.y,A[L+H+10]=r.z,A[L+H+11]=N.itemSize===4?r.w:1)}}h={count:p,texture:C,size:new $e(E,R)},i.set(o,h),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let d=0;for(let v=0;v<c.length;v++)d+=c[v];const g=o.morphTargetsRelative?1:1-d;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function td(n,e,t,i,r){let s=new WeakMap;function a(c){const u=r.render.frame,p=c.geometry,h=e.get(c,p);if(s.get(h)!==u&&(e.update(h),s.set(h,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==u&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),s.set(c,u))),c.isSkinnedMesh){const d=c.skeleton;s.get(d)!==u&&(d.update(),s.set(d,u))}return h}function o(){s=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:a,dispose:o}}const nd={[Bo]:"LINEAR_TONE_MAPPING",[zo]:"REINHARD_TONE_MAPPING",[Go]:"CINEON_TONE_MAPPING",[Vo]:"ACES_FILMIC_TONE_MAPPING",[ko]:"AGX_TONE_MAPPING",[Wo]:"NEUTRAL_TONE_MAPPING",[Ho]:"CUSTOM_TONE_MAPPING"};function id(n,e,t,i,r){const s=new Zt(e,t,{type:n,depthBuffer:i,stencilBuffer:r}),a=new Zt(e,t,{type:pn,depthBuffer:!1,stencilBuffer:!1}),o=new en;o.setAttribute("position",new dn([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new dn([0,2,0,0,2,0],2));const l=new ul({uniforms:{tDiffuse:{value:null}},vertexShader:`
3901
+ `},r=new Li(5,5,5),s=new Qt({name:"CubemapFromEquirect",uniforms:ui(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:At,blending:un});s.uniforms.tEquirect.value=t;const a=new Jt(r,s),o=t.minFilter;return t.minFilter===Bn&&(t.minFilter=Et),new eh(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}function Zf(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,p=!1){return h==null?null:p?a(h):s(h)}function s(h){if(h&&h.isTexture){const p=h.mapping;if(p===yr||p===br)if(e.has(h)){const g=e.get(h).texture;return o(g,h.mapping)}else{const g=h.image;if(g&&g.height>0){const v=new pl(g.height);return v.fromEquirectangularTexture(n,h),e.set(h,v),h.addEventListener("dispose",c),o(v.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const p=h.mapping,g=p===yr||p===br,v=p===Vn||p===ci;if(g||v){let d=t.get(h);const f=d!==void 0?d.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f)return i===null&&(i=new Za(n)),d=g?i.fromEquirectangular(h,d):i.fromCubemap(h,d),d.texture.pmremVersion=h.pmremVersion,t.set(h,d),d.texture;if(d!==void 0)return d.texture;{const S=h.image;return g&&S&&S.height>0||v&&S&&l(S)?(i===null&&(i=new Za(n)),d=g?i.fromEquirectangular(h):i.fromCubemap(h),d.texture.pmremVersion=h.pmremVersion,t.set(h,d),h.addEventListener("dispose",u),d.texture):null}}}return h}function o(h,p){return p===yr?h.mapping=Vn:p===br&&(h.mapping=ci),h}function l(h){let p=0;const g=6;for(let v=0;v<g;v++)h[v]!==void 0&&p++;return p===g}function c(h){const p=h.target;p.removeEventListener("dispose",c);const g=e.get(p);g!==void 0&&(e.delete(p),g.dispose())}function u(h){const p=h.target;p.removeEventListener("dispose",u);const g=t.get(p);g!==void 0&&(t.delete(p),g.dispose())}function m(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:m}}function Kf(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&dr("WebGLRenderer: "+i+" extension not supported."),r}}}function Jf(n,e,t,i){const r={},s=new WeakMap;function a(m){const h=m.target;h.index!==null&&e.remove(h.index);for(const g in h.attributes)e.remove(h.attributes[g]);h.removeEventListener("dispose",a),delete r[h.id];const p=s.get(h);p&&(e.remove(p),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(m,h){return r[h.id]===!0||(h.addEventListener("dispose",a),r[h.id]=!0,t.memory.geometries++),h}function l(m){const h=m.attributes;for(const p in h)e.update(h[p],n.ARRAY_BUFFER)}function c(m){const h=[],p=m.index,g=m.attributes.position;let v=0;if(g===void 0)return;if(p!==null){const S=p.array;v=p.version;for(let b=0,E=S.length;b<E;b+=3){const R=S[b+0],A=S[b+1],C=S[b+2];h.push(R,A,A,C,C,R)}}else{const S=g.array;v=g.version;for(let b=0,E=S.length/3-1;b<E;b+=3){const R=b+0,A=b+1,C=b+2;h.push(R,A,A,C,C,R)}}const d=new(g.count>=65535?sl:rl)(h,1);d.version=v;const f=s.get(m);f&&e.remove(f),s.set(m,d)}function u(m){const h=s.get(m);if(h){const p=m.index;p!==null&&h.version<p.version&&c(m)}else c(m);return s.get(m)}return{get:o,update:l,getWireframeAttribute:u}}function Qf(n,e,t){let i;function r(h){i=h}let s,a;function o(h){s=h.type,a=h.bytesPerElement}function l(h,p){n.drawElements(i,p,s,h*a),t.update(p,i,1)}function c(h,p,g){g!==0&&(n.drawElementsInstanced(i,p,s,h*a,g),t.update(p,i,g))}function u(h,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,p,0,s,h,0,g);let d=0;for(let f=0;f<g;f++)d+=p[f];t.update(d,i,1)}function m(h,p,g,v){if(g===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let f=0;f<h.length;f++)c(h[f]/a,p[f],v[f]);else{d.multiDrawElementsInstancedWEBGL(i,p,0,s,h,0,v,0,g);let f=0;for(let S=0;S<g;S++)f+=p[S]*v[S];t.update(f,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=m}function ed(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:qe("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function td(n,e,t){const i=new WeakMap,r=new ct;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=u!==void 0?u.length:0;let h=i.get(o);if(h===void 0||h.count!==m){let y=function(){C.dispose(),i.delete(o),o.removeEventListener("dispose",y)};h!==void 0&&h.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,d=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let b=0;p===!0&&(b=1),g===!0&&(b=2),v===!0&&(b=3);let E=o.attributes.position.count*b,R=1;E>e.maxTextureSize&&(R=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*R*4*m),C=new el(A,E,R,m);C.type=Yt,C.needsUpdate=!0;const x=b*4;for(let G=0;G<m;G++){const w=d[G],F=f[G],N=S[G],L=E*R*4*G;for(let B=0;B<w.count;B++){const H=B*x;p===!0&&(r.fromBufferAttribute(w,B),A[L+H+0]=r.x,A[L+H+1]=r.y,A[L+H+2]=r.z,A[L+H+3]=0),g===!0&&(r.fromBufferAttribute(F,B),A[L+H+4]=r.x,A[L+H+5]=r.y,A[L+H+6]=r.z,A[L+H+7]=0),v===!0&&(r.fromBufferAttribute(N,B),A[L+H+8]=r.x,A[L+H+9]=r.y,A[L+H+10]=r.z,A[L+H+11]=N.itemSize===4?r.w:1)}}h={count:m,texture:C,size:new $e(E,R)},i.set(o,h),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const g=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function nd(n,e,t,i,r){let s=new WeakMap;function a(c){const u=r.render.frame,m=c.geometry,h=e.get(c,m);if(s.get(h)!==u&&(e.update(h),s.set(h,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==u&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),s.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;s.get(p)!==u&&(p.update(),s.set(p,u))}return h}function o(){s=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),i.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:a,dispose:o}}const id={[Bo]:"LINEAR_TONE_MAPPING",[zo]:"REINHARD_TONE_MAPPING",[Go]:"CINEON_TONE_MAPPING",[Vo]:"ACES_FILMIC_TONE_MAPPING",[ko]:"AGX_TONE_MAPPING",[Wo]:"NEUTRAL_TONE_MAPPING",[Ho]:"CUSTOM_TONE_MAPPING"};function rd(n,e,t,i,r){const s=new Zt(e,t,{type:n,depthBuffer:i,stencilBuffer:r}),a=new Zt(e,t,{type:pn,depthBuffer:!1,stencilBuffer:!1}),o=new en;o.setAttribute("position",new dn([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new dn([0,2,0,0,2,0],2));const l=new ul({uniforms:{tDiffuse:{value:null}},vertexShader:`
3902
3902
  precision highp float;
3903
3903
 
3904
3904
  uniform mat4 modelViewMatrix;
@@ -3944,17 +3944,17 @@ void main() {
3944
3944
  #ifdef SRGB_TRANSFER
3945
3945
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
3946
3946
  #endif
3947
- }`,depthTest:!1,depthWrite:!1}),c=new Jt(o,l),u=new fa(-1,1,1,-1,0,1);let p=null,h=null,d=!1,g,v=null,m=[],f=!1;this.setSize=function(S,b){s.setSize(S,b),a.setSize(S,b);for(let E=0;E<m.length;E++){const R=m[E];R.setSize&&R.setSize(S,b)}},this.setEffects=function(S){m=S,f=m.length>0&&m[0].isRenderPass===!0;const b=s.width,E=s.height;for(let R=0;R<m.length;R++){const A=m[R];A.setSize&&A.setSize(b,E)}},this.begin=function(S,b){if(d||S.toneMapping===$t&&m.length===0)return!1;if(v=b,b!==null){const E=b.width,R=b.height;(s.width!==E||s.height!==R)&&this.setSize(E,R)}return f===!1&&S.setRenderTarget(s),g=S.toneMapping,S.toneMapping=$t,!0},this.hasRenderPass=function(){return f},this.end=function(S,b){S.toneMapping=g,d=!0;let E=s,R=a;for(let A=0;A<m.length;A++){const C=m[A];if(C.enabled!==!1&&(C.render(S,R,E,b),C.needsSwap!==!1)){const x=E;E=R,R=x}}if(p!==S.outputColorSpace||h!==S.toneMapping){p=S.outputColorSpace,h=S.toneMapping,l.defines={},We.getTransfer(p)===Ke&&(l.defines.SRGB_TRANSFER="");const A=nd[h];A&&(l.defines[A]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=E.texture,S.setRenderTarget(v),S.render(c,u),v=null,d=!1},this.isCompositing=function(){return d},this.dispose=function(){s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const ml=new bt,Ks=new Ri(1,1),gl=new el,_l=new wc,xl=new ll,eo=[],to=[],no=new Float32Array(16),io=new Float32Array(9),ro=new Float32Array(4);function pi(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=eo[r];if(s===void 0&&(s=new Float32Array(r),eo[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function dt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function pt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function xr(n,e){let t=to[e];t===void 0&&(t=new Int32Array(e),to[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function rd(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function sd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2fv(this.addr,e),pt(t,e)}}function ad(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dt(t,e))return;n.uniform3fv(this.addr,e),pt(t,e)}}function od(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4fv(this.addr,e),pt(t,e)}}function ld(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;ro.set(i),n.uniformMatrix2fv(this.addr,!1,ro),pt(t,i)}}function cd(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;io.set(i),n.uniformMatrix3fv(this.addr,!1,io),pt(t,i)}}function hd(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;no.set(i),n.uniformMatrix4fv(this.addr,!1,no),pt(t,i)}}function ud(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function fd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2iv(this.addr,e),pt(t,e)}}function dd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;n.uniform3iv(this.addr,e),pt(t,e)}}function pd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4iv(this.addr,e),pt(t,e)}}function md(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function gd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2uiv(this.addr,e),pt(t,e)}}function _d(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;n.uniform3uiv(this.addr,e),pt(t,e)}}function xd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4uiv(this.addr,e),pt(t,e)}}function vd(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Ks.compareFunction=t.isReversedDepthBuffer()?ca:la,s=Ks):s=ml,t.setTexture2D(e||s,r)}function Md(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||_l,r)}function Sd(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||xl,r)}function Ed(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||gl,r)}function yd(n){switch(n){case 5126:return rd;case 35664:return sd;case 35665:return ad;case 35666:return od;case 35674:return ld;case 35675:return cd;case 35676:return hd;case 5124:case 35670:return ud;case 35667:case 35671:return fd;case 35668:case 35672:return dd;case 35669:case 35673:return pd;case 5125:return md;case 36294:return gd;case 36295:return _d;case 36296:return xd;case 35678:case 36198:case 36298:case 36306:case 35682:return vd;case 35679:case 36299:case 36307:return Md;case 35680:case 36300:case 36308:case 36293:return Sd;case 36289:case 36303:case 36311:case 36292:return Ed}}function bd(n,e){n.uniform1fv(this.addr,e)}function Td(n,e){const t=pi(e,this.size,2);n.uniform2fv(this.addr,t)}function Ad(n,e){const t=pi(e,this.size,3);n.uniform3fv(this.addr,t)}function wd(n,e){const t=pi(e,this.size,4);n.uniform4fv(this.addr,t)}function Rd(n,e){const t=pi(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Cd(n,e){const t=pi(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Pd(n,e){const t=pi(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Dd(n,e){n.uniform1iv(this.addr,e)}function Ld(n,e){n.uniform2iv(this.addr,e)}function Id(n,e){n.uniform3iv(this.addr,e)}function Fd(n,e){n.uniform4iv(this.addr,e)}function Ud(n,e){n.uniform1uiv(this.addr,e)}function Nd(n,e){n.uniform2uiv(this.addr,e)}function Od(n,e){n.uniform3uiv(this.addr,e)}function Bd(n,e){n.uniform4uiv(this.addr,e)}function zd(n,e,t){const i=this.cache,r=e.length,s=xr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));let a;this.type===n.SAMPLER_2D_SHADOW?a=Ks:a=ml;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function Gd(n,e,t){const i=this.cache,r=e.length,s=xr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||_l,s[a])}function Vd(n,e,t){const i=this.cache,r=e.length,s=xr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||xl,s[a])}function Hd(n,e,t){const i=this.cache,r=e.length,s=xr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||gl,s[a])}function kd(n){switch(n){case 5126:return bd;case 35664:return Td;case 35665:return Ad;case 35666:return wd;case 35674:return Rd;case 35675:return Cd;case 35676:return Pd;case 5124:case 35670:return Dd;case 35667:case 35671:return Ld;case 35668:case 35672:return Id;case 35669:case 35673:return Fd;case 5125:return Ud;case 36294:return Nd;case 36295:return Od;case 36296:return Bd;case 35678:case 36198:case 36298:case 36306:case 35682:return zd;case 35679:case 36299:case 36307:return Gd;case 35680:case 36300:case 36308:case 36293:return Vd;case 36289:case 36303:case 36311:case 36292:return Hd}}class Wd{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=yd(t.type)}}class Xd{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=kd(t.type)}}class qd{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const es=/(\w+)(\])?(\[|\.)?/g;function so(n,e){n.seq.push(e),n.map[e.id]=e}function Yd(n,e,t){const i=n.name,r=i.length;for(es.lastIndex=0;;){const s=es.exec(i),a=es.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){so(t,c===void 0?new Wd(o,n,e):new Xd(o,n,e));break}else{let p=t.map[o];p===void 0&&(p=new qd(o),so(t,p)),t=p}}}class lr{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);Yd(o,l,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function ao(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const jd=37297;let $d=0;function Zd(n,e){const t=n.split(`
3947
+ }`,depthTest:!1,depthWrite:!1}),c=new Jt(o,l),u=new ua(-1,1,1,-1,0,1);let m=null,h=null,p=!1,g,v=null,d=[],f=!1;this.setSize=function(S,b){s.setSize(S,b),a.setSize(S,b);for(let E=0;E<d.length;E++){const R=d[E];R.setSize&&R.setSize(S,b)}},this.setEffects=function(S){d=S,f=d.length>0&&d[0].isRenderPass===!0;const b=s.width,E=s.height;for(let R=0;R<d.length;R++){const A=d[R];A.setSize&&A.setSize(b,E)}},this.begin=function(S,b){if(p||S.toneMapping===$t&&d.length===0)return!1;if(v=b,b!==null){const E=b.width,R=b.height;(s.width!==E||s.height!==R)&&this.setSize(E,R)}return f===!1&&S.setRenderTarget(s),g=S.toneMapping,S.toneMapping=$t,!0},this.hasRenderPass=function(){return f},this.end=function(S,b){S.toneMapping=g,p=!0;let E=s,R=a;for(let A=0;A<d.length;A++){const C=d[A];if(C.enabled!==!1&&(C.render(S,R,E,b),C.needsSwap!==!1)){const x=E;E=R,R=x}}if(m!==S.outputColorSpace||h!==S.toneMapping){m=S.outputColorSpace,h=S.toneMapping,l.defines={},We.getTransfer(m)===Ke&&(l.defines.SRGB_TRANSFER="");const A=id[h];A&&(l.defines[A]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=E.texture,S.setRenderTarget(v),S.render(c,u),v=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const ml=new bt,Zs=new Ci(1,1),gl=new el,_l=new Rc,xl=new ll,eo=[],to=[],no=new Float32Array(16),io=new Float32Array(9),ro=new Float32Array(4);function pi(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=eo[r];if(s===void 0&&(s=new Float32Array(r),eo[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function dt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function pt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function vr(n,e){let t=to[e];t===void 0&&(t=new Int32Array(e),to[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function sd(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function ad(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2fv(this.addr,e),pt(t,e)}}function od(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dt(t,e))return;n.uniform3fv(this.addr,e),pt(t,e)}}function ld(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4fv(this.addr,e),pt(t,e)}}function cd(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;ro.set(i),n.uniformMatrix2fv(this.addr,!1,ro),pt(t,i)}}function hd(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;io.set(i),n.uniformMatrix3fv(this.addr,!1,io),pt(t,i)}}function ud(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(dt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),pt(t,e)}else{if(dt(t,i))return;no.set(i),n.uniformMatrix4fv(this.addr,!1,no),pt(t,i)}}function fd(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function dd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2iv(this.addr,e),pt(t,e)}}function pd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;n.uniform3iv(this.addr,e),pt(t,e)}}function md(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4iv(this.addr,e),pt(t,e)}}function gd(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function _d(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;n.uniform2uiv(this.addr,e),pt(t,e)}}function xd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;n.uniform3uiv(this.addr,e),pt(t,e)}}function vd(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;n.uniform4uiv(this.addr,e),pt(t,e)}}function Md(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Zs.compareFunction=t.isReversedDepthBuffer()?la:oa,s=Zs):s=ml,t.setTexture2D(e||s,r)}function Sd(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||_l,r)}function Ed(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||xl,r)}function yd(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||gl,r)}function bd(n){switch(n){case 5126:return sd;case 35664:return ad;case 35665:return od;case 35666:return ld;case 35674:return cd;case 35675:return hd;case 35676:return ud;case 5124:case 35670:return fd;case 35667:case 35671:return dd;case 35668:case 35672:return pd;case 35669:case 35673:return md;case 5125:return gd;case 36294:return _d;case 36295:return xd;case 36296:return vd;case 35678:case 36198:case 36298:case 36306:case 35682:return Md;case 35679:case 36299:case 36307:return Sd;case 35680:case 36300:case 36308:case 36293:return Ed;case 36289:case 36303:case 36311:case 36292:return yd}}function Td(n,e){n.uniform1fv(this.addr,e)}function Ad(n,e){const t=pi(e,this.size,2);n.uniform2fv(this.addr,t)}function wd(n,e){const t=pi(e,this.size,3);n.uniform3fv(this.addr,t)}function Rd(n,e){const t=pi(e,this.size,4);n.uniform4fv(this.addr,t)}function Cd(n,e){const t=pi(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Pd(n,e){const t=pi(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Dd(n,e){const t=pi(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Ld(n,e){n.uniform1iv(this.addr,e)}function Id(n,e){n.uniform2iv(this.addr,e)}function Fd(n,e){n.uniform3iv(this.addr,e)}function Ud(n,e){n.uniform4iv(this.addr,e)}function Nd(n,e){n.uniform1uiv(this.addr,e)}function Od(n,e){n.uniform2uiv(this.addr,e)}function Bd(n,e){n.uniform3uiv(this.addr,e)}function zd(n,e){n.uniform4uiv(this.addr,e)}function Gd(n,e,t){const i=this.cache,r=e.length,s=vr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));let a;this.type===n.SAMPLER_2D_SHADOW?a=Zs:a=ml;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function Vd(n,e,t){const i=this.cache,r=e.length,s=vr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||_l,s[a])}function Hd(n,e,t){const i=this.cache,r=e.length,s=vr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||xl,s[a])}function kd(n,e,t){const i=this.cache,r=e.length,s=vr(t,r);dt(i,s)||(n.uniform1iv(this.addr,s),pt(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||gl,s[a])}function Wd(n){switch(n){case 5126:return Td;case 35664:return Ad;case 35665:return wd;case 35666:return Rd;case 35674:return Cd;case 35675:return Pd;case 35676:return Dd;case 5124:case 35670:return Ld;case 35667:case 35671:return Id;case 35668:case 35672:return Fd;case 35669:case 35673:return Ud;case 5125:return Nd;case 36294:return Od;case 36295:return Bd;case 36296:return zd;case 35678:case 36198:case 36298:case 36306:case 35682:return Gd;case 35679:case 36299:case 36307:return Vd;case 35680:case 36300:case 36308:case 36293:return Hd;case 36289:case 36303:case 36311:case 36292:return kd}}class Xd{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=bd(t.type)}}class qd{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Wd(t.type)}}class Yd{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const es=/(\w+)(\])?(\[|\.)?/g;function so(n,e){n.seq.push(e),n.map[e.id]=e}function jd(n,e,t){const i=n.name,r=i.length;for(es.lastIndex=0;;){const s=es.exec(i),a=es.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){so(t,c===void 0?new Xd(o,n,e):new qd(o,n,e));break}else{let m=t.map[o];m===void 0&&(m=new Yd(o),so(t,m)),t=m}}}class cr{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);jd(o,l,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function ao(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const $d=37297;let Zd=0;function Kd(n,e){const t=n.split(`
3948
3948
  `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
3949
- `)}const oo=new Oe;function Kd(n){We._getMatrix(oo,We.workingColorSpace,n);const e=`mat3( ${oo.elements.map(t=>t.toFixed(4))} )`;switch(We.getTransfer(n)){case cr:return[e,"LinearTransferOETF"];case Ke:return[e,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function lo(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
3949
+ `)}const oo=new Oe;function Jd(n){We._getMatrix(oo,We.workingColorSpace,n);const e=`mat3( ${oo.elements.map(t=>t.toFixed(4))} )`;switch(We.getTransfer(n)){case hr:return[e,"LinearTransferOETF"];case Ke:return[e,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function lo(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
3950
3950
 
3951
3951
  `+s+`
3952
3952
 
3953
- `+Zd(n.getShaderSource(e),o)}else return s}function Jd(n,e){const t=Kd(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3954
- `)}const Qd={[Bo]:"Linear",[zo]:"Reinhard",[Go]:"Cineon",[Vo]:"ACESFilmic",[ko]:"AgX",[Wo]:"Neutral",[Ho]:"Custom"};function ep(n,e){const t=Qd[e];return t===void 0?(Le("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const nr=new k;function tp(){We.getLuminanceCoefficients(nr);const n=nr.x.toFixed(4),e=nr.y.toFixed(4),t=nr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3955
- `)}function np(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(bi).join(`
3956
- `)}function ip(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
3957
- `)}function rp(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function bi(n){return n!==""}function co(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ho(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const sp=/^[ \t]*#include +<([\w\d./]+)>/gm;function Js(n){return n.replace(sp,op)}const ap=new Map;function op(n,e){let t=Be[e];if(t===void 0){const i=ap.get(e);if(i!==void 0)t=Be[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Js(t)}const lp=/#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 uo(n){return n.replace(lp,cp)}function cp(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function fo(n){let e=`precision ${n.precision} float;
3953
+ `+Kd(n.getShaderSource(e),o)}else return s}function Qd(n,e){const t=Jd(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3954
+ `)}const ep={[Bo]:"Linear",[zo]:"Reinhard",[Go]:"Cineon",[Vo]:"ACESFilmic",[ko]:"AgX",[Wo]:"Neutral",[Ho]:"Custom"};function tp(n,e){const t=ep[e];return t===void 0?(Le("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ir=new k;function np(){We.getLuminanceCoefficients(ir);const n=ir.x.toFixed(4),e=ir.y.toFixed(4),t=ir.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3955
+ `)}function ip(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ti).join(`
3956
+ `)}function rp(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
3957
+ `)}function sp(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function Ti(n){return n!==""}function co(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ho(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ap=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ks(n){return n.replace(ap,lp)}const op=new Map;function lp(n,e){let t=Be[e];if(t===void 0){const i=op.get(e);if(i!==void 0)t=Be[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Ks(t)}const cp=/#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 uo(n){return n.replace(cp,hp)}function hp(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function fo(n){let e=`precision ${n.precision} float;
3958
3958
  precision ${n.precision} int;
3959
3959
  precision ${n.precision} sampler2D;
3960
3960
  precision ${n.precision} samplerCube;
@@ -3974,30 +3974,30 @@ void main() {
3974
3974
  `;return n.precision==="highp"?e+=`
3975
3975
  #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
3976
3976
  #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
3977
- #define LOW_PRECISION`),e}const hp={[ir]:"SHADOWMAP_TYPE_PCF",[yi]:"SHADOWMAP_TYPE_VSM"};function up(n){return hp[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const fp={[Vn]:"ENVMAP_TYPE_CUBE",[ci]:"ENVMAP_TYPE_CUBE",[pr]:"ENVMAP_TYPE_CUBE_UV"};function dp(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":fp[n.envMapMode]||"ENVMAP_TYPE_CUBE"}const pp={[ci]:"ENVMAP_MODE_REFRACTION"};function mp(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":pp[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}const gp={[Oo]:"ENVMAP_BLENDING_MULTIPLY",[sc]:"ENVMAP_BLENDING_MIX",[ac]:"ENVMAP_BLENDING_ADD"};function _p(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":gp[n.combine]||"ENVMAP_BLENDING_NONE"}function xp(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function vp(n,e,t,i){const r=n.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=up(t),c=dp(t),u=mp(t),p=_p(t),h=xp(t),d=np(t),g=ip(s),v=r.createProgram();let m,f,S=t.glslVersion?"#version "+t.glslVersion+`
3978
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(bi).join(`
3979
- `),m.length>0&&(m+=`
3980
- `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(bi).join(`
3977
+ #define LOW_PRECISION`),e}const up={[rr]:"SHADOWMAP_TYPE_PCF",[bi]:"SHADOWMAP_TYPE_VSM"};function fp(n){return up[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const dp={[Vn]:"ENVMAP_TYPE_CUBE",[ci]:"ENVMAP_TYPE_CUBE",[mr]:"ENVMAP_TYPE_CUBE_UV"};function pp(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":dp[n.envMapMode]||"ENVMAP_TYPE_CUBE"}const mp={[ci]:"ENVMAP_MODE_REFRACTION"};function gp(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":mp[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}const _p={[Oo]:"ENVMAP_BLENDING_MULTIPLY",[ac]:"ENVMAP_BLENDING_MIX",[oc]:"ENVMAP_BLENDING_ADD"};function xp(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":_p[n.combine]||"ENVMAP_BLENDING_NONE"}function vp(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function Mp(n,e,t,i){const r=n.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=fp(t),c=pp(t),u=gp(t),m=xp(t),h=vp(t),p=ip(t),g=rp(s),v=r.createProgram();let d,f,S=t.glslVersion?"#version "+t.glslVersion+`
3978
+ `:"";t.isRawShaderMaterial?(d=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ti).join(`
3979
+ `),d.length>0&&(d+=`
3980
+ `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ti).join(`
3981
3981
  `),f.length>0&&(f+=`
3982
- `)):(m=[fo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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",`
3983
- `].filter(bi).join(`
3984
- `),f=[fo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+p:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==$t?"#define TONE_MAPPING":"",t.toneMapping!==$t?Be.tonemapping_pars_fragment:"",t.toneMapping!==$t?ep("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Be.colorspace_pars_fragment,Jd("linearToOutputTexel",t.outputColorSpace),tp(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3985
- `].filter(bi).join(`
3986
- `)),a=Js(a),a=co(a,t),a=ho(a,t),o=Js(o),o=co(o,t),o=ho(o,t),a=uo(a),o=uo(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
3987
- `,m=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3982
+ `)):(d=[fo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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",`
3983
+ `].filter(Ti).join(`
3984
+ `),f=[fo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+m:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==$t?"#define TONE_MAPPING":"",t.toneMapping!==$t?Be.tonemapping_pars_fragment:"",t.toneMapping!==$t?tp("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Be.colorspace_pars_fragment,Qd("linearToOutputTexel",t.outputColorSpace),np(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3985
+ `].filter(Ti).join(`
3986
+ `)),a=Ks(a),a=co(a,t),a=ho(a,t),o=Ks(o),o=co(o,t),o=ho(o,t),a=uo(a),o=uo(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
3987
+ `,d=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3988
3988
  `)+`
3989
- `+m,f=["#define varying in",t.glslVersion===Ra?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ra?"":"#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(`
3989
+ `+d,f=["#define varying in",t.glslVersion===Ra?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ra?"":"#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(`
3990
3990
  `)+`
3991
- `+f);const b=S+m+a,E=S+f+o,R=ao(r,r.VERTEX_SHADER,b),A=ao(r,r.FRAGMENT_SHADER,E);r.attachShader(v,R),r.attachShader(v,A),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function C(w){if(n.debug.checkShaderErrors){const F=r.getProgramInfoLog(v)||"",N=r.getShaderInfoLog(R)||"",L=r.getShaderInfoLog(A)||"",B=F.trim(),H=N.trim(),O=L.trim();let J=!0,Z=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(J=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,v,R,A);else{const le=lo(r,R,"vertex"),de=lo(r,A,"fragment");qe("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3991
+ `+f);const b=S+d+a,E=S+f+o,R=ao(r,r.VERTEX_SHADER,b),A=ao(r,r.FRAGMENT_SHADER,E);r.attachShader(v,R),r.attachShader(v,A),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function C(w){if(n.debug.checkShaderErrors){const F=r.getProgramInfoLog(v)||"",N=r.getShaderInfoLog(R)||"",L=r.getShaderInfoLog(A)||"",B=F.trim(),H=N.trim(),O=L.trim();let J=!0,Z=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(J=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,v,R,A);else{const le=lo(r,R,"vertex"),de=lo(r,A,"fragment");qe("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3992
3992
 
3993
3993
  Material Name: `+w.name+`
3994
3994
  Material Type: `+w.type+`
3995
3995
 
3996
3996
  Program Info Log: `+B+`
3997
3997
  `+le+`
3998
- `+de)}else B!==""?Le("WebGLProgram: Program Info Log:",B):(H===""||O==="")&&(Z=!1);Z&&(w.diagnostics={runnable:J,programLog:B,vertexShader:{log:H,prefix:m},fragmentShader:{log:O,prefix:f}})}r.deleteShader(R),r.deleteShader(A),x=new lr(r,v),y=rp(r,v)}let x;this.getUniforms=function(){return x===void 0&&C(this),x};let y;this.getAttributes=function(){return y===void 0&&C(this),y};let G=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return G===!1&&(G=r.getProgramParameter(v,jd)),G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=$d++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=R,this.fragmentShader=A,this}let Mp=0;class Sp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new Ep(e),t.set(e,i)),i}}class Ep{constructor(e){this.id=Mp++,this.code=e,this.usedTimes=0}}function yp(n,e,t,i,r,s){const a=new nl,o=new Sp,l=new Set,c=[],u=new Map,p=i.logarithmicDepthBuffer;let h=i.precision;const d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 g(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,y,G,w,F){const N=w.fog,L=F.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?w.environment:null,H=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=e.get(x.envMap||B,H),J=O&&O.mapping===pr?O.image.height:null,Z=d[x.type];x.precision!==null&&(h=i.getMaxPrecision(x.precision),h!==x.precision&&Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead."));const le=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,de=le!==void 0?le.length:0;let ue=0;L.morphAttributes.position!==void 0&&(ue=1),L.morphAttributes.normal!==void 0&&(ue=2),L.morphAttributes.color!==void 0&&(ue=3);let Pe,nt,Je,j;if(Z){const Ze=qt[Z];Pe=Ze.vertexShader,nt=Ze.fragmentShader}else Pe=x.vertexShader,nt=x.fragmentShader,o.update(x),Je=o.getVertexShaderID(x),j=o.getFragmentShaderID(x);const te=n.getRenderTarget(),re=n.state.buffers.depth.getReversed(),De=F.isInstancedMesh===!0,Ae=F.isBatchedMesh===!0,we=!!x.map,ot=!!x.matcap,Ve=!!O,Ye=!!x.aoMap,je=!!x.lightMap,Ie=!!x.bumpMap,st=!!x.normalMap,P=!!x.displacementMap,at=!!x.emissiveMap,Ce=!!x.metalnessMap,Ne=!!x.roughnessMap,ge=x.anisotropy>0,T=x.clearcoat>0,_=x.dispersion>0,I=x.iridescence>0,Y=x.sheen>0,K=x.transmission>0,q=ge&&!!x.anisotropyMap,_e=T&&!!x.clearcoatMap,se=T&&!!x.clearcoatNormalMap,Te=T&&!!x.clearcoatRoughnessMap,Re=I&&!!x.iridescenceMap,Q=I&&!!x.iridescenceThicknessMap,ne=Y&&!!x.sheenColorMap,xe=Y&&!!x.sheenRoughnessMap,Me=!!x.specularMap,fe=!!x.specularColorMap,ze=!!x.specularIntensityMap,D=K&&!!x.transmissionMap,ae=K&&!!x.thicknessMap,ie=!!x.gradientMap,me=!!x.alphaMap,ee=x.alphaTest>0,X=!!x.alphaHash,ve=!!x.extensions;let Fe=$t;x.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Fe=n.toneMapping);const rt={shaderID:Z,shaderType:x.type,shaderName:x.name,vertexShader:Pe,fragmentShader:nt,defines:x.defines,customVertexShaderID:Je,customFragmentShaderID:j,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&F._colorsTexture!==null,instancing:De,instancingColor:De&&F.instanceColor!==null,instancingMorph:De&&F.morphTexture!==null,outputColorSpace:te===null?n.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:Hn,alphaToCoverage:!!x.alphaToCoverage,map:we,matcap:ot,envMap:Ve,envMapMode:Ve&&O.mapping,envMapCubeUVHeight:J,aoMap:Ye,lightMap:je,bumpMap:Ie,normalMap:st,displacementMap:P,emissiveMap:at,normalMapObjectSpace:st&&x.normalMapType===hc,normalMapTangentSpace:st&&x.normalMapType===cc,metalnessMap:Ce,roughnessMap:Ne,anisotropy:ge,anisotropyMap:q,clearcoat:T,clearcoatMap:_e,clearcoatNormalMap:se,clearcoatRoughnessMap:Te,dispersion:_,iridescence:I,iridescenceMap:Re,iridescenceThicknessMap:Q,sheen:Y,sheenColorMap:ne,sheenRoughnessMap:xe,specularMap:Me,specularColorMap:fe,specularIntensityMap:ze,transmission:K,transmissionMap:D,thicknessMap:ae,gradientMap:ie,opaque:x.transparent===!1&&x.blending===Gn&&x.alphaToCoverage===!1,alphaMap:me,alphaTest:ee,alphaHash:X,combine:x.combine,mapUv:we&&g(x.map.channel),aoMapUv:Ye&&g(x.aoMap.channel),lightMapUv:je&&g(x.lightMap.channel),bumpMapUv:Ie&&g(x.bumpMap.channel),normalMapUv:st&&g(x.normalMap.channel),displacementMapUv:P&&g(x.displacementMap.channel),emissiveMapUv:at&&g(x.emissiveMap.channel),metalnessMapUv:Ce&&g(x.metalnessMap.channel),roughnessMapUv:Ne&&g(x.roughnessMap.channel),anisotropyMapUv:q&&g(x.anisotropyMap.channel),clearcoatMapUv:_e&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Re&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:ne&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:xe&&g(x.sheenRoughnessMap.channel),specularMapUv:Me&&g(x.specularMap.channel),specularColorMapUv:fe&&g(x.specularColorMap.channel),specularIntensityMapUv:ze&&g(x.specularIntensityMap.channel),transmissionMapUv:D&&g(x.transmissionMap.channel),thicknessMapUv:ae&&g(x.thicknessMap.channel),alphaMapUv:me&&g(x.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(st||ge),vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!L.attributes.uv&&(we||me),fog:!!N,useFog:x.fog===!0,fogExp2:!!N&&N.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||L.attributes.normal===void 0&&st===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:p,reversedDepthBuffer:re,skinning:F.isSkinnedMesh===!0,morphTargets:L.morphAttributes.position!==void 0,morphNormals:L.morphAttributes.normal!==void 0,morphColors:L.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:ue,numDirLights:y.directional.length,numPointLights:y.point.length,numSpotLights:y.spot.length,numSpotLightMaps:y.spotLightMap.length,numRectAreaLights:y.rectArea.length,numHemiLights:y.hemi.length,numDirLightShadows:y.directionalShadowMap.length,numPointLightShadows:y.pointShadowMap.length,numSpotLightShadows:y.spotShadowMap.length,numSpotLightShadowsWithMaps:y.numSpotLightShadowsWithMaps,numLightProbes:y.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:n.shadowMap.enabled&&G.length>0,shadowMapType:n.shadowMap.type,toneMapping:Fe,decodeVideoTexture:we&&x.map.isVideoTexture===!0&&We.getTransfer(x.map.colorSpace)===Ke,decodeVideoTextureEmissive:at&&x.emissiveMap.isVideoTexture===!0&&We.getTransfer(x.emissiveMap.colorSpace)===Ke,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===cn,flipSided:x.side===At,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ve&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&x.extensions.multiDraw===!0||Ae)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return rt.vertexUv1s=l.has(1),rt.vertexUv2s=l.has(2),rt.vertexUv3s=l.has(3),l.clear(),rt}function m(x){const y=[];if(x.shaderID?y.push(x.shaderID):(y.push(x.customVertexShaderID),y.push(x.customFragmentShaderID)),x.defines!==void 0)for(const G in x.defines)y.push(G),y.push(x.defines[G]);return x.isRawShaderMaterial===!1&&(f(y,x),S(y,x),y.push(n.outputColorSpace)),y.push(x.customProgramCacheKey),y.join()}function f(x,y){x.push(y.precision),x.push(y.outputColorSpace),x.push(y.envMapMode),x.push(y.envMapCubeUVHeight),x.push(y.mapUv),x.push(y.alphaMapUv),x.push(y.lightMapUv),x.push(y.aoMapUv),x.push(y.bumpMapUv),x.push(y.normalMapUv),x.push(y.displacementMapUv),x.push(y.emissiveMapUv),x.push(y.metalnessMapUv),x.push(y.roughnessMapUv),x.push(y.anisotropyMapUv),x.push(y.clearcoatMapUv),x.push(y.clearcoatNormalMapUv),x.push(y.clearcoatRoughnessMapUv),x.push(y.iridescenceMapUv),x.push(y.iridescenceThicknessMapUv),x.push(y.sheenColorMapUv),x.push(y.sheenRoughnessMapUv),x.push(y.specularMapUv),x.push(y.specularColorMapUv),x.push(y.specularIntensityMapUv),x.push(y.transmissionMapUv),x.push(y.thicknessMapUv),x.push(y.combine),x.push(y.fogExp2),x.push(y.sizeAttenuation),x.push(y.morphTargetsCount),x.push(y.morphAttributeCount),x.push(y.numDirLights),x.push(y.numPointLights),x.push(y.numSpotLights),x.push(y.numSpotLightMaps),x.push(y.numHemiLights),x.push(y.numRectAreaLights),x.push(y.numDirLightShadows),x.push(y.numPointLightShadows),x.push(y.numSpotLightShadows),x.push(y.numSpotLightShadowsWithMaps),x.push(y.numLightProbes),x.push(y.shadowMapType),x.push(y.toneMapping),x.push(y.numClippingPlanes),x.push(y.numClipIntersection),x.push(y.depthPacking)}function S(x,y){a.disableAll(),y.instancing&&a.enable(0),y.instancingColor&&a.enable(1),y.instancingMorph&&a.enable(2),y.matcap&&a.enable(3),y.envMap&&a.enable(4),y.normalMapObjectSpace&&a.enable(5),y.normalMapTangentSpace&&a.enable(6),y.clearcoat&&a.enable(7),y.iridescence&&a.enable(8),y.alphaTest&&a.enable(9),y.vertexColors&&a.enable(10),y.vertexAlphas&&a.enable(11),y.vertexUv1s&&a.enable(12),y.vertexUv2s&&a.enable(13),y.vertexUv3s&&a.enable(14),y.vertexTangents&&a.enable(15),y.anisotropy&&a.enable(16),y.alphaHash&&a.enable(17),y.batching&&a.enable(18),y.dispersion&&a.enable(19),y.batchingColor&&a.enable(20),y.gradientMap&&a.enable(21),x.push(a.mask),a.disableAll(),y.fog&&a.enable(0),y.useFog&&a.enable(1),y.flatShading&&a.enable(2),y.logarithmicDepthBuffer&&a.enable(3),y.reversedDepthBuffer&&a.enable(4),y.skinning&&a.enable(5),y.morphTargets&&a.enable(6),y.morphNormals&&a.enable(7),y.morphColors&&a.enable(8),y.premultipliedAlpha&&a.enable(9),y.shadowMapEnabled&&a.enable(10),y.doubleSided&&a.enable(11),y.flipSided&&a.enable(12),y.useDepthPacking&&a.enable(13),y.dithering&&a.enable(14),y.transmission&&a.enable(15),y.sheen&&a.enable(16),y.opaque&&a.enable(17),y.pointsUvs&&a.enable(18),y.decodeVideoTexture&&a.enable(19),y.decodeVideoTextureEmissive&&a.enable(20),y.alphaToCoverage&&a.enable(21),x.push(a.mask)}function b(x){const y=d[x.type];let G;if(y){const w=qt[y];G=jc.clone(w.uniforms)}else G=x.uniforms;return G}function E(x,y){let G=u.get(y);return G!==void 0?++G.usedTimes:(G=new vp(n,y,x,r),c.push(G),u.set(y,G)),G}function R(x){if(--x.usedTimes===0){const y=c.indexOf(x);c[y]=c[c.length-1],c.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){o.remove(x)}function C(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:b,acquireProgram:E,releaseProgram:R,releaseShaderCache:A,programs:c,dispose:C}}function bp(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function Tp(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function po(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function mo(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h){let d=0;return h.isInstancedMesh&&(d+=2),h.isSkinnedMesh&&(d+=1),d}function o(h,d,g,v,m,f){let S=n[e];return S===void 0?(S={id:h.id,object:h,geometry:d,material:g,materialVariant:a(h),groupOrder:v,renderOrder:h.renderOrder,z:m,group:f},n[e]=S):(S.id=h.id,S.object=h,S.geometry=d,S.material=g,S.materialVariant=a(h),S.groupOrder=v,S.renderOrder=h.renderOrder,S.z=m,S.group=f),e++,S}function l(h,d,g,v,m,f){const S=o(h,d,g,v,m,f);g.transmission>0?i.push(S):g.transparent===!0?r.push(S):t.push(S)}function c(h,d,g,v,m,f){const S=o(h,d,g,v,m,f);g.transmission>0?i.unshift(S):g.transparent===!0?r.unshift(S):t.unshift(S)}function u(h,d){t.length>1&&t.sort(h||Tp),i.length>1&&i.sort(d||po),r.length>1&&r.sort(d||po)}function p(){for(let h=e,d=n.length;h<d;h++){const g=n[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:l,unshift:c,finish:p,sort:u}}function Ap(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new mo,n.set(i,[a])):r>=s.length?(a=new mo,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function wp(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new k,color:new tt};break;case"SpotLight":t={position:new k,direction:new k,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new k,halfWidth:new k,halfHeight:new k};break}return n[e.id]=t,t}}}function Rp(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Cp=0;function Pp(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Dp(n){const e=new wp,t=Rp(),i={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++)i.probe.push(new k);const r=new k,s=new ft,a=new ft;function o(c){let u=0,p=0,h=0;for(let y=0;y<9;y++)i.probe[y].set(0,0,0);let d=0,g=0,v=0,m=0,f=0,S=0,b=0,E=0,R=0,A=0,C=0;c.sort(Pp);for(let y=0,G=c.length;y<G;y++){const w=c[y],F=w.color,N=w.intensity,L=w.distance;let B=null;if(w.shadow&&w.shadow.map&&(w.shadow.map.texture.format===hi?B=w.shadow.map.texture:B=w.shadow.map.depthTexture||w.shadow.map.texture),w.isAmbientLight)u+=F.r*N,p+=F.g*N,h+=F.b*N;else if(w.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(w.sh.coefficients[H],N);C++}else if(w.isDirectionalLight){const H=e.get(w);if(H.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const O=w.shadow,J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,i.directionalShadow[d]=J,i.directionalShadowMap[d]=B,i.directionalShadowMatrix[d]=w.shadow.matrix,S++}i.directional[d]=H,d++}else if(w.isSpotLight){const H=e.get(w);H.position.setFromMatrixPosition(w.matrixWorld),H.color.copy(F).multiplyScalar(N),H.distance=L,H.coneCos=Math.cos(w.angle),H.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),H.decay=w.decay,i.spot[v]=H;const O=w.shadow;if(w.map&&(i.spotLightMap[R]=w.map,R++,O.updateMatrices(w),w.castShadow&&A++),i.spotLightMatrix[v]=O.matrix,w.castShadow){const J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,i.spotShadow[v]=J,i.spotShadowMap[v]=B,E++}v++}else if(w.isRectAreaLight){const H=e.get(w);H.color.copy(F).multiplyScalar(N),H.halfWidth.set(w.width*.5,0,0),H.halfHeight.set(0,w.height*.5,0),i.rectArea[m]=H,m++}else if(w.isPointLight){const H=e.get(w);if(H.color.copy(w.color).multiplyScalar(w.intensity),H.distance=w.distance,H.decay=w.decay,w.castShadow){const O=w.shadow,J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,J.shadowCameraNear=O.camera.near,J.shadowCameraFar=O.camera.far,i.pointShadow[g]=J,i.pointShadowMap[g]=B,i.pointShadowMatrix[g]=w.shadow.matrix,b++}i.point[g]=H,g++}else if(w.isHemisphereLight){const H=e.get(w);H.skyColor.copy(w.color).multiplyScalar(N),H.groundColor.copy(w.groundColor).multiplyScalar(N),i.hemi[f]=H,f++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=oe.LTC_FLOAT_1,i.rectAreaLTC2=oe.LTC_FLOAT_2):(i.rectAreaLTC1=oe.LTC_HALF_1,i.rectAreaLTC2=oe.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=p,i.ambient[2]=h;const x=i.hash;(x.directionalLength!==d||x.pointLength!==g||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==f||x.numDirectionalShadows!==S||x.numPointShadows!==b||x.numSpotShadows!==E||x.numSpotMaps!==R||x.numLightProbes!==C)&&(i.directional.length=d,i.spot.length=v,i.rectArea.length=m,i.point.length=g,i.hemi.length=f,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=E+R-A,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=C,x.directionalLength=d,x.pointLength=g,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=f,x.numDirectionalShadows=S,x.numPointShadows=b,x.numSpotShadows=E,x.numSpotMaps=R,x.numLightProbes=C,i.version=Cp++)}function l(c,u){let p=0,h=0,d=0,g=0,v=0;const m=u.matrixWorldInverse;for(let f=0,S=c.length;f<S;f++){const b=c[f];if(b.isDirectionalLight){const E=i.directional[p];E.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(m),p++}else if(b.isSpotLight){const E=i.spot[d];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(m),E.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(m),d++}else if(b.isRectAreaLight){const E=i.rectArea[g];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(m),a.identity(),s.copy(b.matrixWorld),s.premultiply(m),a.extractRotation(s),E.halfWidth.set(b.width*.5,0,0),E.halfHeight.set(0,b.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),g++}else if(b.isPointLight){const E=i.point[h];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(m),h++}else if(b.isHemisphereLight){const E=i.hemi[v];E.direction.setFromMatrixPosition(b.matrixWorld),E.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:i}}function go(n){const e=new Dp(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Lp(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new go(n),e.set(r,[o])):s>=a.length?(o=new go(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ip=`void main() {
3998
+ `+de)}else B!==""?Le("WebGLProgram: Program Info Log:",B):(H===""||O==="")&&(Z=!1);Z&&(w.diagnostics={runnable:J,programLog:B,vertexShader:{log:H,prefix:d},fragmentShader:{log:O,prefix:f}})}r.deleteShader(R),r.deleteShader(A),x=new cr(r,v),y=sp(r,v)}let x;this.getUniforms=function(){return x===void 0&&C(this),x};let y;this.getAttributes=function(){return y===void 0&&C(this),y};let G=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return G===!1&&(G=r.getProgramParameter(v,$d)),G},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Zd++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=R,this.fragmentShader=A,this}let Sp=0;class Ep{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new yp(e),t.set(e,i)),i}}class yp{constructor(e){this.id=Sp++,this.code=e,this.usedTimes=0}}function bp(n,e,t,i,r,s){const a=new nl,o=new Ep,l=new Set,c=[],u=new Map,m=i.logarithmicDepthBuffer;let h=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 g(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,y,G,w,F){const N=w.fog,L=F.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?w.environment:null,H=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,O=e.get(x.envMap||B,H),J=O&&O.mapping===mr?O.image.height:null,Z=p[x.type];x.precision!==null&&(h=i.getMaxPrecision(x.precision),h!==x.precision&&Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead."));const le=L.morphAttributes.position||L.morphAttributes.normal||L.morphAttributes.color,de=le!==void 0?le.length:0;let ue=0;L.morphAttributes.position!==void 0&&(ue=1),L.morphAttributes.normal!==void 0&&(ue=2),L.morphAttributes.color!==void 0&&(ue=3);let Pe,nt,Je,j;if(Z){const Ze=qt[Z];Pe=Ze.vertexShader,nt=Ze.fragmentShader}else Pe=x.vertexShader,nt=x.fragmentShader,o.update(x),Je=o.getVertexShaderID(x),j=o.getFragmentShaderID(x);const te=n.getRenderTarget(),re=n.state.buffers.depth.getReversed(),De=F.isInstancedMesh===!0,Ae=F.isBatchedMesh===!0,we=!!x.map,ot=!!x.matcap,Ve=!!O,Ye=!!x.aoMap,je=!!x.lightMap,Ie=!!x.bumpMap,st=!!x.normalMap,P=!!x.displacementMap,at=!!x.emissiveMap,Ce=!!x.metalnessMap,Ne=!!x.roughnessMap,ge=x.anisotropy>0,T=x.clearcoat>0,_=x.dispersion>0,I=x.iridescence>0,Y=x.sheen>0,K=x.transmission>0,q=ge&&!!x.anisotropyMap,_e=T&&!!x.clearcoatMap,se=T&&!!x.clearcoatNormalMap,Te=T&&!!x.clearcoatRoughnessMap,Re=I&&!!x.iridescenceMap,Q=I&&!!x.iridescenceThicknessMap,ne=Y&&!!x.sheenColorMap,xe=Y&&!!x.sheenRoughnessMap,Me=!!x.specularMap,fe=!!x.specularColorMap,ze=!!x.specularIntensityMap,D=K&&!!x.transmissionMap,ae=K&&!!x.thicknessMap,ie=!!x.gradientMap,me=!!x.alphaMap,ee=x.alphaTest>0,X=!!x.alphaHash,ve=!!x.extensions;let Fe=$t;x.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Fe=n.toneMapping);const rt={shaderID:Z,shaderType:x.type,shaderName:x.name,vertexShader:Pe,fragmentShader:nt,defines:x.defines,customVertexShaderID:Je,customFragmentShaderID:j,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&F._colorsTexture!==null,instancing:De,instancingColor:De&&F.instanceColor!==null,instancingMorph:De&&F.morphTexture!==null,outputColorSpace:te===null?n.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:Hn,alphaToCoverage:!!x.alphaToCoverage,map:we,matcap:ot,envMap:Ve,envMapMode:Ve&&O.mapping,envMapCubeUVHeight:J,aoMap:Ye,lightMap:je,bumpMap:Ie,normalMap:st,displacementMap:P,emissiveMap:at,normalMapObjectSpace:st&&x.normalMapType===uc,normalMapTangentSpace:st&&x.normalMapType===hc,metalnessMap:Ce,roughnessMap:Ne,anisotropy:ge,anisotropyMap:q,clearcoat:T,clearcoatMap:_e,clearcoatNormalMap:se,clearcoatRoughnessMap:Te,dispersion:_,iridescence:I,iridescenceMap:Re,iridescenceThicknessMap:Q,sheen:Y,sheenColorMap:ne,sheenRoughnessMap:xe,specularMap:Me,specularColorMap:fe,specularIntensityMap:ze,transmission:K,transmissionMap:D,thicknessMap:ae,gradientMap:ie,opaque:x.transparent===!1&&x.blending===Gn&&x.alphaToCoverage===!1,alphaMap:me,alphaTest:ee,alphaHash:X,combine:x.combine,mapUv:we&&g(x.map.channel),aoMapUv:Ye&&g(x.aoMap.channel),lightMapUv:je&&g(x.lightMap.channel),bumpMapUv:Ie&&g(x.bumpMap.channel),normalMapUv:st&&g(x.normalMap.channel),displacementMapUv:P&&g(x.displacementMap.channel),emissiveMapUv:at&&g(x.emissiveMap.channel),metalnessMapUv:Ce&&g(x.metalnessMap.channel),roughnessMapUv:Ne&&g(x.roughnessMap.channel),anisotropyMapUv:q&&g(x.anisotropyMap.channel),clearcoatMapUv:_e&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Te&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Re&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:ne&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:xe&&g(x.sheenRoughnessMap.channel),specularMapUv:Me&&g(x.specularMap.channel),specularColorMapUv:fe&&g(x.specularColorMap.channel),specularIntensityMapUv:ze&&g(x.specularIntensityMap.channel),transmissionMapUv:D&&g(x.transmissionMap.channel),thicknessMapUv:ae&&g(x.thicknessMap.channel),alphaMapUv:me&&g(x.alphaMap.channel),vertexTangents:!!L.attributes.tangent&&(st||ge),vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!L.attributes.color&&L.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!L.attributes.uv&&(we||me),fog:!!N,useFog:x.fog===!0,fogExp2:!!N&&N.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||L.attributes.normal===void 0&&st===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:re,skinning:F.isSkinnedMesh===!0,morphTargets:L.morphAttributes.position!==void 0,morphNormals:L.morphAttributes.normal!==void 0,morphColors:L.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:ue,numDirLights:y.directional.length,numPointLights:y.point.length,numSpotLights:y.spot.length,numSpotLightMaps:y.spotLightMap.length,numRectAreaLights:y.rectArea.length,numHemiLights:y.hemi.length,numDirLightShadows:y.directionalShadowMap.length,numPointLightShadows:y.pointShadowMap.length,numSpotLightShadows:y.spotShadowMap.length,numSpotLightShadowsWithMaps:y.numSpotLightShadowsWithMaps,numLightProbes:y.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:n.shadowMap.enabled&&G.length>0,shadowMapType:n.shadowMap.type,toneMapping:Fe,decodeVideoTexture:we&&x.map.isVideoTexture===!0&&We.getTransfer(x.map.colorSpace)===Ke,decodeVideoTextureEmissive:at&&x.emissiveMap.isVideoTexture===!0&&We.getTransfer(x.emissiveMap.colorSpace)===Ke,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===cn,flipSided:x.side===At,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ve&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&x.extensions.multiDraw===!0||Ae)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return rt.vertexUv1s=l.has(1),rt.vertexUv2s=l.has(2),rt.vertexUv3s=l.has(3),l.clear(),rt}function d(x){const y=[];if(x.shaderID?y.push(x.shaderID):(y.push(x.customVertexShaderID),y.push(x.customFragmentShaderID)),x.defines!==void 0)for(const G in x.defines)y.push(G),y.push(x.defines[G]);return x.isRawShaderMaterial===!1&&(f(y,x),S(y,x),y.push(n.outputColorSpace)),y.push(x.customProgramCacheKey),y.join()}function f(x,y){x.push(y.precision),x.push(y.outputColorSpace),x.push(y.envMapMode),x.push(y.envMapCubeUVHeight),x.push(y.mapUv),x.push(y.alphaMapUv),x.push(y.lightMapUv),x.push(y.aoMapUv),x.push(y.bumpMapUv),x.push(y.normalMapUv),x.push(y.displacementMapUv),x.push(y.emissiveMapUv),x.push(y.metalnessMapUv),x.push(y.roughnessMapUv),x.push(y.anisotropyMapUv),x.push(y.clearcoatMapUv),x.push(y.clearcoatNormalMapUv),x.push(y.clearcoatRoughnessMapUv),x.push(y.iridescenceMapUv),x.push(y.iridescenceThicknessMapUv),x.push(y.sheenColorMapUv),x.push(y.sheenRoughnessMapUv),x.push(y.specularMapUv),x.push(y.specularColorMapUv),x.push(y.specularIntensityMapUv),x.push(y.transmissionMapUv),x.push(y.thicknessMapUv),x.push(y.combine),x.push(y.fogExp2),x.push(y.sizeAttenuation),x.push(y.morphTargetsCount),x.push(y.morphAttributeCount),x.push(y.numDirLights),x.push(y.numPointLights),x.push(y.numSpotLights),x.push(y.numSpotLightMaps),x.push(y.numHemiLights),x.push(y.numRectAreaLights),x.push(y.numDirLightShadows),x.push(y.numPointLightShadows),x.push(y.numSpotLightShadows),x.push(y.numSpotLightShadowsWithMaps),x.push(y.numLightProbes),x.push(y.shadowMapType),x.push(y.toneMapping),x.push(y.numClippingPlanes),x.push(y.numClipIntersection),x.push(y.depthPacking)}function S(x,y){a.disableAll(),y.instancing&&a.enable(0),y.instancingColor&&a.enable(1),y.instancingMorph&&a.enable(2),y.matcap&&a.enable(3),y.envMap&&a.enable(4),y.normalMapObjectSpace&&a.enable(5),y.normalMapTangentSpace&&a.enable(6),y.clearcoat&&a.enable(7),y.iridescence&&a.enable(8),y.alphaTest&&a.enable(9),y.vertexColors&&a.enable(10),y.vertexAlphas&&a.enable(11),y.vertexUv1s&&a.enable(12),y.vertexUv2s&&a.enable(13),y.vertexUv3s&&a.enable(14),y.vertexTangents&&a.enable(15),y.anisotropy&&a.enable(16),y.alphaHash&&a.enable(17),y.batching&&a.enable(18),y.dispersion&&a.enable(19),y.batchingColor&&a.enable(20),y.gradientMap&&a.enable(21),x.push(a.mask),a.disableAll(),y.fog&&a.enable(0),y.useFog&&a.enable(1),y.flatShading&&a.enable(2),y.logarithmicDepthBuffer&&a.enable(3),y.reversedDepthBuffer&&a.enable(4),y.skinning&&a.enable(5),y.morphTargets&&a.enable(6),y.morphNormals&&a.enable(7),y.morphColors&&a.enable(8),y.premultipliedAlpha&&a.enable(9),y.shadowMapEnabled&&a.enable(10),y.doubleSided&&a.enable(11),y.flipSided&&a.enable(12),y.useDepthPacking&&a.enable(13),y.dithering&&a.enable(14),y.transmission&&a.enable(15),y.sheen&&a.enable(16),y.opaque&&a.enable(17),y.pointsUvs&&a.enable(18),y.decodeVideoTexture&&a.enable(19),y.decodeVideoTextureEmissive&&a.enable(20),y.alphaToCoverage&&a.enable(21),x.push(a.mask)}function b(x){const y=p[x.type];let G;if(y){const w=qt[y];G=$c.clone(w.uniforms)}else G=x.uniforms;return G}function E(x,y){let G=u.get(y);return G!==void 0?++G.usedTimes:(G=new Mp(n,y,x,r),c.push(G),u.set(y,G)),G}function R(x){if(--x.usedTimes===0){const y=c.indexOf(x);c[y]=c[c.length-1],c.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){o.remove(x)}function C(){o.dispose()}return{getParameters:v,getProgramCacheKey:d,getUniforms:b,acquireProgram:E,releaseProgram:R,releaseShaderCache:A,programs:c,dispose:C}}function Tp(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function Ap(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function po(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function mo(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(h){let p=0;return h.isInstancedMesh&&(p+=2),h.isSkinnedMesh&&(p+=1),p}function o(h,p,g,v,d,f){let S=n[e];return S===void 0?(S={id:h.id,object:h,geometry:p,material:g,materialVariant:a(h),groupOrder:v,renderOrder:h.renderOrder,z:d,group:f},n[e]=S):(S.id=h.id,S.object=h,S.geometry=p,S.material=g,S.materialVariant=a(h),S.groupOrder=v,S.renderOrder=h.renderOrder,S.z=d,S.group=f),e++,S}function l(h,p,g,v,d,f){const S=o(h,p,g,v,d,f);g.transmission>0?i.push(S):g.transparent===!0?r.push(S):t.push(S)}function c(h,p,g,v,d,f){const S=o(h,p,g,v,d,f);g.transmission>0?i.unshift(S):g.transparent===!0?r.unshift(S):t.unshift(S)}function u(h,p){t.length>1&&t.sort(h||Ap),i.length>1&&i.sort(p||po),r.length>1&&r.sort(p||po)}function m(){for(let h=e,p=n.length;h<p;h++){const g=n[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:l,unshift:c,finish:m,sort:u}}function wp(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new mo,n.set(i,[a])):r>=s.length?(a=new mo,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function Rp(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new k,color:new tt};break;case"SpotLight":t={position:new k,direction:new k,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new k,halfWidth:new k,halfHeight:new k};break}return n[e.id]=t,t}}}function Cp(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $e,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Pp=0;function Dp(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Lp(n){const e=new Rp,t=Cp(),i={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++)i.probe.push(new k);const r=new k,s=new ft,a=new ft;function o(c){let u=0,m=0,h=0;for(let y=0;y<9;y++)i.probe[y].set(0,0,0);let p=0,g=0,v=0,d=0,f=0,S=0,b=0,E=0,R=0,A=0,C=0;c.sort(Dp);for(let y=0,G=c.length;y<G;y++){const w=c[y],F=w.color,N=w.intensity,L=w.distance;let B=null;if(w.shadow&&w.shadow.map&&(w.shadow.map.texture.format===hi?B=w.shadow.map.texture:B=w.shadow.map.depthTexture||w.shadow.map.texture),w.isAmbientLight)u+=F.r*N,m+=F.g*N,h+=F.b*N;else if(w.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(w.sh.coefficients[H],N);C++}else if(w.isDirectionalLight){const H=e.get(w);if(H.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const O=w.shadow,J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,i.directionalShadow[p]=J,i.directionalShadowMap[p]=B,i.directionalShadowMatrix[p]=w.shadow.matrix,S++}i.directional[p]=H,p++}else if(w.isSpotLight){const H=e.get(w);H.position.setFromMatrixPosition(w.matrixWorld),H.color.copy(F).multiplyScalar(N),H.distance=L,H.coneCos=Math.cos(w.angle),H.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),H.decay=w.decay,i.spot[v]=H;const O=w.shadow;if(w.map&&(i.spotLightMap[R]=w.map,R++,O.updateMatrices(w),w.castShadow&&A++),i.spotLightMatrix[v]=O.matrix,w.castShadow){const J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,i.spotShadow[v]=J,i.spotShadowMap[v]=B,E++}v++}else if(w.isRectAreaLight){const H=e.get(w);H.color.copy(F).multiplyScalar(N),H.halfWidth.set(w.width*.5,0,0),H.halfHeight.set(0,w.height*.5,0),i.rectArea[d]=H,d++}else if(w.isPointLight){const H=e.get(w);if(H.color.copy(w.color).multiplyScalar(w.intensity),H.distance=w.distance,H.decay=w.decay,w.castShadow){const O=w.shadow,J=t.get(w);J.shadowIntensity=O.intensity,J.shadowBias=O.bias,J.shadowNormalBias=O.normalBias,J.shadowRadius=O.radius,J.shadowMapSize=O.mapSize,J.shadowCameraNear=O.camera.near,J.shadowCameraFar=O.camera.far,i.pointShadow[g]=J,i.pointShadowMap[g]=B,i.pointShadowMatrix[g]=w.shadow.matrix,b++}i.point[g]=H,g++}else if(w.isHemisphereLight){const H=e.get(w);H.skyColor.copy(w.color).multiplyScalar(N),H.groundColor.copy(w.groundColor).multiplyScalar(N),i.hemi[f]=H,f++}}d>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=oe.LTC_FLOAT_1,i.rectAreaLTC2=oe.LTC_FLOAT_2):(i.rectAreaLTC1=oe.LTC_HALF_1,i.rectAreaLTC2=oe.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=m,i.ambient[2]=h;const x=i.hash;(x.directionalLength!==p||x.pointLength!==g||x.spotLength!==v||x.rectAreaLength!==d||x.hemiLength!==f||x.numDirectionalShadows!==S||x.numPointShadows!==b||x.numSpotShadows!==E||x.numSpotMaps!==R||x.numLightProbes!==C)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=d,i.point.length=g,i.hemi.length=f,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=E+R-A,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=C,x.directionalLength=p,x.pointLength=g,x.spotLength=v,x.rectAreaLength=d,x.hemiLength=f,x.numDirectionalShadows=S,x.numPointShadows=b,x.numSpotShadows=E,x.numSpotMaps=R,x.numLightProbes=C,i.version=Pp++)}function l(c,u){let m=0,h=0,p=0,g=0,v=0;const d=u.matrixWorldInverse;for(let f=0,S=c.length;f<S;f++){const b=c[f];if(b.isDirectionalLight){const E=i.directional[m];E.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(d),m++}else if(b.isSpotLight){const E=i.spot[p];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(d),E.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(d),p++}else if(b.isRectAreaLight){const E=i.rectArea[g];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(d),a.identity(),s.copy(b.matrixWorld),s.premultiply(d),a.extractRotation(s),E.halfWidth.set(b.width*.5,0,0),E.halfHeight.set(0,b.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),g++}else if(b.isPointLight){const E=i.point[h];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(d),h++}else if(b.isHemisphereLight){const E=i.hemi[v];E.direction.setFromMatrixPosition(b.matrixWorld),E.direction.transformDirection(d),v++}}}return{setup:o,setupView:l,state:i}}function go(n){const e=new Lp(n),t=[],i=[];function r(u){c.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function a(u){i.push(u)}function o(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Ip(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new go(n),e.set(r,[o])):s>=a.length?(o=new go(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Fp=`void main() {
3999
3999
  gl_Position = vec4( position, 1.0 );
4000
- }`,Fp=`uniform sampler2D shadow_pass;
4000
+ }`,Up=`uniform sampler2D shadow_pass;
4001
4001
  uniform vec2 resolution;
4002
4002
  uniform float radius;
4003
4003
  void main() {
@@ -4022,12 +4022,12 @@ void main() {
4022
4022
  squared_mean = squared_mean / samples;
4023
4023
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4024
4024
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4025
- }`,Up=[new k(1,0,0),new k(-1,0,0),new k(0,1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1)],Np=[new k(0,-1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1),new k(0,-1,0),new k(0,-1,0)],_o=new ft,Ei=new k,ts=new k;function Op(n,e,t){let i=new ol;const r=new $e,s=new $e,a=new ct,o=new Kc,l=new Jc,c={},u=t.maxTextureSize,p={[An]:At,[At]:An,[cn]:cn},h=new Qt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},radius:{value:4}},vertexShader:Ip,fragmentShader:Fp}),d=h.clone();d.defines.HORIZONTAL_PASS=1;const g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Jt(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ir;let f=this.type;this.render=function(A,C,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||A.length===0)return;this.type===Gl&&(Le("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ir);const y=n.getRenderTarget(),G=n.getActiveCubeFace(),w=n.getActiveMipmapLevel(),F=n.state;F.setBlending(un),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const N=f!==this.type;N&&C.traverse(function(L){L.material&&(Array.isArray(L.material)?L.material.forEach(B=>B.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,B=A.length;L<B;L++){const H=A[L],O=H.shadow;if(O===void 0){Le("WebGLShadowMap:",H,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);const J=O.getFrameExtents();r.multiply(J),s.copy(O.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/J.x),r.x=s.x*J.x,O.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/J.y),r.y=s.y*J.y,O.mapSize.y=s.y));const Z=n.state.buffers.depth.getReversed();if(O.camera._reversedDepth=Z,O.map===null||N===!0){if(O.map!==null&&(O.map.depthTexture!==null&&(O.map.depthTexture.dispose(),O.map.depthTexture=null),O.map.dispose()),this.type===yi){if(H.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new Zt(r.x,r.y,{format:hi,type:pn,minFilter:Et,magFilter:Et,generateMipmaps:!1}),O.map.texture.name=H.name+".shadowMap",O.map.depthTexture=new Ri(r.x,r.y,Yt),O.map.depthTexture.name=H.name+".shadowMapDepth",O.map.depthTexture.format=mn,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=xt,O.map.depthTexture.magFilter=xt}else H.isPointLight?(O.map=new pl(r.x),O.map.depthTexture=new qc(r.x,Kt)):(O.map=new Zt(r.x,r.y),O.map.depthTexture=new Ri(r.x,r.y,Kt)),O.map.depthTexture.name=H.name+".shadowMap",O.map.depthTexture.format=mn,this.type===ir?(O.map.depthTexture.compareFunction=Z?ca:la,O.map.depthTexture.minFilter=Et,O.map.depthTexture.magFilter=Et):(O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=xt,O.map.depthTexture.magFilter=xt);O.camera.updateProjectionMatrix()}const le=O.map.isWebGLCubeRenderTarget?6:1;for(let de=0;de<le;de++){if(O.map.isWebGLCubeRenderTarget)n.setRenderTarget(O.map,de),n.clear();else{de===0&&(n.setRenderTarget(O.map),n.clear());const ue=O.getViewport(de);a.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),F.viewport(a)}if(H.isPointLight){const ue=O.camera,Pe=O.matrix,nt=H.distance||ue.far;nt!==ue.far&&(ue.far=nt,ue.updateProjectionMatrix()),Ei.setFromMatrixPosition(H.matrixWorld),ue.position.copy(Ei),ts.copy(ue.position),ts.add(Up[de]),ue.up.copy(Np[de]),ue.lookAt(ts),ue.updateMatrixWorld(),Pe.makeTranslation(-Ei.x,-Ei.y,-Ei.z),_o.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),O._frustum.setFromProjectionMatrix(_o,ue.coordinateSystem,ue.reversedDepth)}else O.updateMatrices(H);i=O.getFrustum(),E(C,x,O.camera,H,this.type)}O.isPointLightShadow!==!0&&this.type===yi&&S(O,x),O.needsUpdate=!1}f=this.type,m.needsUpdate=!1,n.setRenderTarget(y,G,w)};function S(A,C){const x=e.update(v);h.defines.VSM_SAMPLES!==A.blurSamples&&(h.defines.VSM_SAMPLES=A.blurSamples,d.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Zt(r.x,r.y,{format:hi,type:pn})),h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value=A.mapSize,h.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(C,null,x,h,v,null),d.uniforms.shadow_pass.value=A.mapPass.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(C,null,x,d,v,null)}function b(A,C,x,y){let G=null;const w=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(w!==void 0)G=w;else if(G=x.isPointLight===!0?l:o,n.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const F=G.uuid,N=C.uuid;let L=c[F];L===void 0&&(L={},c[F]=L);let B=L[N];B===void 0&&(B=G.clone(),L[N]=B,C.addEventListener("dispose",R)),G=B}if(G.visible=C.visible,G.wireframe=C.wireframe,y===yi?G.side=C.shadowSide!==null?C.shadowSide:C.side:G.side=C.shadowSide!==null?C.shadowSide:p[C.side],G.alphaMap=C.alphaMap,G.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,G.map=C.map,G.clipShadows=C.clipShadows,G.clippingPlanes=C.clippingPlanes,G.clipIntersection=C.clipIntersection,G.displacementMap=C.displacementMap,G.displacementScale=C.displacementScale,G.displacementBias=C.displacementBias,G.wireframeLinewidth=C.wireframeLinewidth,G.linewidth=C.linewidth,x.isPointLight===!0&&G.isMeshDistanceMaterial===!0){const F=n.properties.get(G);F.light=x}return G}function E(A,C,x,y,G){if(A.visible===!1)return;if(A.layers.test(C.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&G===yi)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);const N=e.update(A),L=A.material;if(Array.isArray(L)){const B=N.groups;for(let H=0,O=B.length;H<O;H++){const J=B[H],Z=L[J.materialIndex];if(Z&&Z.visible){const le=b(A,Z,y,G);A.onBeforeShadow(n,A,C,x,N,le,J),n.renderBufferDirect(x,null,N,le,A,J),A.onAfterShadow(n,A,C,x,N,le,J)}}}else if(L.visible){const B=b(A,L,y,G);A.onBeforeShadow(n,A,C,x,N,B,null),n.renderBufferDirect(x,null,N,B,A,null),A.onAfterShadow(n,A,C,x,N,B,null)}}const F=A.children;for(let N=0,L=F.length;N<L;N++)E(F[N],C,x,y,G)}function R(A){A.target.removeEventListener("dispose",R);for(const x in c){const y=c[x],G=A.target.uuid;G in y&&(y[G].dispose(),delete y[G])}}}function Bp(n,e){function t(){let D=!1;const ae=new ct;let ie=null;const me=new ct(0,0,0,0);return{setMask:function(ee){ie!==ee&&!D&&(n.colorMask(ee,ee,ee,ee),ie=ee)},setLocked:function(ee){D=ee},setClear:function(ee,X,ve,Fe,rt){rt===!0&&(ee*=Fe,X*=Fe,ve*=Fe),ae.set(ee,X,ve,Fe),me.equals(ae)===!1&&(n.clearColor(ee,X,ve,Fe),me.copy(ae))},reset:function(){D=!1,ie=null,me.set(-1,0,0,0)}}}function i(){let D=!1,ae=!1,ie=null,me=null,ee=null;return{setReversed:function(X){if(ae!==X){const ve=e.get("EXT_clip_control");X?ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.ZERO_TO_ONE_EXT):ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.NEGATIVE_ONE_TO_ONE_EXT),ae=X;const Fe=ee;ee=null,this.setClear(Fe)}},getReversed:function(){return ae},setTest:function(X){X?te(n.DEPTH_TEST):re(n.DEPTH_TEST)},setMask:function(X){ie!==X&&!D&&(n.depthMask(X),ie=X)},setFunc:function(X){if(ae&&(X=Mc[X]),me!==X){switch(X){case cs:n.depthFunc(n.NEVER);break;case hs:n.depthFunc(n.ALWAYS);break;case us:n.depthFunc(n.LESS);break;case li:n.depthFunc(n.LEQUAL);break;case fs:n.depthFunc(n.EQUAL);break;case ds:n.depthFunc(n.GEQUAL);break;case ps:n.depthFunc(n.GREATER);break;case ms:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}me=X}},setLocked:function(X){D=X},setClear:function(X){ee!==X&&(ee=X,ae&&(X=1-X),n.clearDepth(X))},reset:function(){D=!1,ie=null,me=null,ee=null,ae=!1}}}function r(){let D=!1,ae=null,ie=null,me=null,ee=null,X=null,ve=null,Fe=null,rt=null;return{setTest:function(Ze){D||(Ze?te(n.STENCIL_TEST):re(n.STENCIL_TEST))},setMask:function(Ze){ae!==Ze&&!D&&(n.stencilMask(Ze),ae=Ze)},setFunc:function(Ze,tn,nn){(ie!==Ze||me!==tn||ee!==nn)&&(n.stencilFunc(Ze,tn,nn),ie=Ze,me=tn,ee=nn)},setOp:function(Ze,tn,nn){(X!==Ze||ve!==tn||Fe!==nn)&&(n.stencilOp(Ze,tn,nn),X=Ze,ve=tn,Fe=nn)},setLocked:function(Ze){D=Ze},setClear:function(Ze){rt!==Ze&&(n.clearStencil(Ze),rt=Ze)},reset:function(){D=!1,ae=null,ie=null,me=null,ee=null,X=null,ve=null,Fe=null,rt=null}}}const s=new t,a=new i,o=new r,l=new WeakMap,c=new WeakMap;let u={},p={},h=new WeakMap,d=[],g=null,v=!1,m=null,f=null,S=null,b=null,E=null,R=null,A=null,C=new tt(0,0,0),x=0,y=!1,G=null,w=null,F=null,N=null,L=null;const B=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,O=0;const J=n.getParameter(n.VERSION);J.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(J)[1]),H=O>=1):J.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),H=O>=2);let Z=null,le={};const de=n.getParameter(n.SCISSOR_BOX),ue=n.getParameter(n.VIEWPORT),Pe=new ct().fromArray(de),nt=new ct().fromArray(ue);function Je(D,ae,ie,me){const ee=new Uint8Array(4),X=n.createTexture();n.bindTexture(D,X),n.texParameteri(D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(D,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let ve=0;ve<ie;ve++)D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY?n.texImage3D(ae,0,n.RGBA,1,1,me,0,n.RGBA,n.UNSIGNED_BYTE,ee):n.texImage2D(ae+ve,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ee);return X}const j={};j[n.TEXTURE_2D]=Je(n.TEXTURE_2D,n.TEXTURE_2D,1),j[n.TEXTURE_CUBE_MAP]=Je(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[n.TEXTURE_2D_ARRAY]=Je(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),j[n.TEXTURE_3D]=Je(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),te(n.DEPTH_TEST),a.setFunc(li),Ie(!1),st(Ea),te(n.CULL_FACE),Ye(un);function te(D){u[D]!==!0&&(n.enable(D),u[D]=!0)}function re(D){u[D]!==!1&&(n.disable(D),u[D]=!1)}function De(D,ae){return p[D]!==ae?(n.bindFramebuffer(D,ae),p[D]=ae,D===n.DRAW_FRAMEBUFFER&&(p[n.FRAMEBUFFER]=ae),D===n.FRAMEBUFFER&&(p[n.DRAW_FRAMEBUFFER]=ae),!0):!1}function Ae(D,ae){let ie=d,me=!1;if(D){ie=h.get(ae),ie===void 0&&(ie=[],h.set(ae,ie));const ee=D.textures;if(ie.length!==ee.length||ie[0]!==n.COLOR_ATTACHMENT0){for(let X=0,ve=ee.length;X<ve;X++)ie[X]=n.COLOR_ATTACHMENT0+X;ie.length=ee.length,me=!0}}else ie[0]!==n.BACK&&(ie[0]=n.BACK,me=!0);me&&n.drawBuffers(ie)}function we(D){return g!==D?(n.useProgram(D),g=D,!0):!1}const ot={[Nn]:n.FUNC_ADD,[Hl]:n.FUNC_SUBTRACT,[kl]:n.FUNC_REVERSE_SUBTRACT};ot[Wl]=n.MIN,ot[Xl]=n.MAX;const Ve={[ql]:n.ZERO,[Yl]:n.ONE,[jl]:n.SRC_COLOR,[os]:n.SRC_ALPHA,[ec]:n.SRC_ALPHA_SATURATE,[Jl]:n.DST_COLOR,[Zl]:n.DST_ALPHA,[$l]:n.ONE_MINUS_SRC_COLOR,[ls]:n.ONE_MINUS_SRC_ALPHA,[Ql]:n.ONE_MINUS_DST_COLOR,[Kl]:n.ONE_MINUS_DST_ALPHA,[tc]:n.CONSTANT_COLOR,[nc]:n.ONE_MINUS_CONSTANT_COLOR,[ic]:n.CONSTANT_ALPHA,[rc]:n.ONE_MINUS_CONSTANT_ALPHA};function Ye(D,ae,ie,me,ee,X,ve,Fe,rt,Ze){if(D===un){v===!0&&(re(n.BLEND),v=!1);return}if(v===!1&&(te(n.BLEND),v=!0),D!==Vl){if(D!==m||Ze!==y){if((f!==Nn||E!==Nn)&&(n.blendEquation(n.FUNC_ADD),f=Nn,E=Nn),Ze)switch(D){case Gn:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ya:n.blendFunc(n.ONE,n.ONE);break;case ba:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ta:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:qe("WebGLState: Invalid blending: ",D);break}else switch(D){case Gn:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ya:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case ba:qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ta:qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:qe("WebGLState: Invalid blending: ",D);break}S=null,b=null,R=null,A=null,C.set(0,0,0),x=0,m=D,y=Ze}return}ee=ee||ae,X=X||ie,ve=ve||me,(ae!==f||ee!==E)&&(n.blendEquationSeparate(ot[ae],ot[ee]),f=ae,E=ee),(ie!==S||me!==b||X!==R||ve!==A)&&(n.blendFuncSeparate(Ve[ie],Ve[me],Ve[X],Ve[ve]),S=ie,b=me,R=X,A=ve),(Fe.equals(C)===!1||rt!==x)&&(n.blendColor(Fe.r,Fe.g,Fe.b,rt),C.copy(Fe),x=rt),m=D,y=!1}function je(D,ae){D.side===cn?re(n.CULL_FACE):te(n.CULL_FACE);let ie=D.side===At;ae&&(ie=!ie),Ie(ie),D.blending===Gn&&D.transparent===!1?Ye(un):Ye(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const me=D.stencilWrite;o.setTest(me),me&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),at(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?te(n.SAMPLE_ALPHA_TO_COVERAGE):re(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ie(D){G!==D&&(D?n.frontFace(n.CW):n.frontFace(n.CCW),G=D)}function st(D){D!==Bl?(te(n.CULL_FACE),D!==w&&(D===Ea?n.cullFace(n.BACK):D===zl?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):re(n.CULL_FACE),w=D}function P(D){D!==F&&(H&&n.lineWidth(D),F=D)}function at(D,ae,ie){D?(te(n.POLYGON_OFFSET_FILL),(N!==ae||L!==ie)&&(N=ae,L=ie,a.getReversed()&&(ae=-ae),n.polygonOffset(ae,ie))):re(n.POLYGON_OFFSET_FILL)}function Ce(D){D?te(n.SCISSOR_TEST):re(n.SCISSOR_TEST)}function Ne(D){D===void 0&&(D=n.TEXTURE0+B-1),Z!==D&&(n.activeTexture(D),Z=D)}function ge(D,ae,ie){ie===void 0&&(Z===null?ie=n.TEXTURE0+B-1:ie=Z);let me=le[ie];me===void 0&&(me={type:void 0,texture:void 0},le[ie]=me),(me.type!==D||me.texture!==ae)&&(Z!==ie&&(n.activeTexture(ie),Z=ie),n.bindTexture(D,ae||j[D]),me.type=D,me.texture=ae)}function T(){const D=le[Z];D!==void 0&&D.type!==void 0&&(n.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function _(){try{n.compressedTexImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function I(){try{n.compressedTexImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function Y(){try{n.texSubImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function K(){try{n.texSubImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function q(){try{n.compressedTexSubImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function _e(){try{n.compressedTexSubImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function se(){try{n.texStorage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function Te(){try{n.texStorage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function Re(){try{n.texImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function Q(){try{n.texImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function ne(D){Pe.equals(D)===!1&&(n.scissor(D.x,D.y,D.z,D.w),Pe.copy(D))}function xe(D){nt.equals(D)===!1&&(n.viewport(D.x,D.y,D.z,D.w),nt.copy(D))}function Me(D,ae){let ie=c.get(ae);ie===void 0&&(ie=new WeakMap,c.set(ae,ie));let me=ie.get(D);me===void 0&&(me=n.getUniformBlockIndex(ae,D.name),ie.set(D,me))}function fe(D,ae){const me=c.get(ae).get(D);l.get(ae)!==me&&(n.uniformBlockBinding(ae,me,D.__bindingPointIndex),l.set(ae,me))}function ze(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),u={},Z=null,le={},p={},h=new WeakMap,d=[],g=null,v=!1,m=null,f=null,S=null,b=null,E=null,R=null,A=null,C=new tt(0,0,0),x=0,y=!1,G=null,w=null,F=null,N=null,L=null,Pe.set(0,0,n.canvas.width,n.canvas.height),nt.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:te,disable:re,bindFramebuffer:De,drawBuffers:Ae,useProgram:we,setBlending:Ye,setMaterial:je,setFlipSided:Ie,setCullFace:st,setLineWidth:P,setPolygonOffset:at,setScissorTest:Ce,activeTexture:Ne,bindTexture:ge,unbindTexture:T,compressedTexImage2D:_,compressedTexImage3D:I,texImage2D:Re,texImage3D:Q,updateUBOMapping:Me,uniformBlockBinding:fe,texStorage2D:se,texStorage3D:Te,texSubImage2D:Y,texSubImage3D:K,compressedTexSubImage2D:q,compressedTexSubImage3D:_e,scissor:ne,viewport:xe,reset:ze}}function zp(n,e,t,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new $e,u=new WeakMap;let p;const h=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(T,_){return d?new OffscreenCanvas(T,_):ur("canvas")}function v(T,_,I){let Y=1;const K=ge(T);if((K.width>I||K.height>I)&&(Y=I/Math.max(K.width,K.height)),Y<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){const q=Math.floor(Y*K.width),_e=Math.floor(Y*K.height);p===void 0&&(p=g(q,_e));const se=_?g(q,_e):p;return se.width=q,se.height=_e,se.getContext("2d").drawImage(T,0,0,q,_e),Le("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+q+"x"+_e+")."),se}else return"data"in T&&Le("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function m(T){return T.generateMipmaps}function f(T){n.generateMipmap(T)}function S(T){return T.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?n.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function b(T,_,I,Y,K=!1){if(T!==null){if(n[T]!==void 0)return n[T];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let q=_;if(_===n.RED&&(I===n.FLOAT&&(q=n.R32F),I===n.HALF_FLOAT&&(q=n.R16F),I===n.UNSIGNED_BYTE&&(q=n.R8)),_===n.RED_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.R8UI),I===n.UNSIGNED_SHORT&&(q=n.R16UI),I===n.UNSIGNED_INT&&(q=n.R32UI),I===n.BYTE&&(q=n.R8I),I===n.SHORT&&(q=n.R16I),I===n.INT&&(q=n.R32I)),_===n.RG&&(I===n.FLOAT&&(q=n.RG32F),I===n.HALF_FLOAT&&(q=n.RG16F),I===n.UNSIGNED_BYTE&&(q=n.RG8)),_===n.RG_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RG8UI),I===n.UNSIGNED_SHORT&&(q=n.RG16UI),I===n.UNSIGNED_INT&&(q=n.RG32UI),I===n.BYTE&&(q=n.RG8I),I===n.SHORT&&(q=n.RG16I),I===n.INT&&(q=n.RG32I)),_===n.RGB_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RGB8UI),I===n.UNSIGNED_SHORT&&(q=n.RGB16UI),I===n.UNSIGNED_INT&&(q=n.RGB32UI),I===n.BYTE&&(q=n.RGB8I),I===n.SHORT&&(q=n.RGB16I),I===n.INT&&(q=n.RGB32I)),_===n.RGBA_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RGBA8UI),I===n.UNSIGNED_SHORT&&(q=n.RGBA16UI),I===n.UNSIGNED_INT&&(q=n.RGBA32UI),I===n.BYTE&&(q=n.RGBA8I),I===n.SHORT&&(q=n.RGBA16I),I===n.INT&&(q=n.RGBA32I)),_===n.RGB&&(I===n.UNSIGNED_INT_5_9_9_9_REV&&(q=n.RGB9_E5),I===n.UNSIGNED_INT_10F_11F_11F_REV&&(q=n.R11F_G11F_B10F)),_===n.RGBA){const _e=K?cr:We.getTransfer(Y);I===n.FLOAT&&(q=n.RGBA32F),I===n.HALF_FLOAT&&(q=n.RGBA16F),I===n.UNSIGNED_BYTE&&(q=_e===Ke?n.SRGB8_ALPHA8:n.RGBA8),I===n.UNSIGNED_SHORT_4_4_4_4&&(q=n.RGBA4),I===n.UNSIGNED_SHORT_5_5_5_1&&(q=n.RGB5_A1)}return(q===n.R16F||q===n.R32F||q===n.RG16F||q===n.RG32F||q===n.RGBA16F||q===n.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function E(T,_){let I;return T?_===null||_===Kt||_===wi?I=n.DEPTH24_STENCIL8:_===Yt?I=n.DEPTH32F_STENCIL8:_===Ai&&(I=n.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Kt||_===wi?I=n.DEPTH_COMPONENT24:_===Yt?I=n.DEPTH_COMPONENT32F:_===Ai&&(I=n.DEPTH_COMPONENT16),I}function R(T,_){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==xt&&T.minFilter!==Et?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 A(T){const _=T.target;_.removeEventListener("dispose",A),x(_),_.isVideoTexture&&u.delete(_)}function C(T){const _=T.target;_.removeEventListener("dispose",C),G(_)}function x(T){const _=i.get(T);if(_.__webglInit===void 0)return;const I=T.source,Y=h.get(I);if(Y){const K=Y[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&y(T),Object.keys(Y).length===0&&h.delete(I)}i.remove(T)}function y(T){const _=i.get(T);n.deleteTexture(_.__webglTexture);const I=T.source,Y=h.get(I);delete Y[_.__cacheKey],a.memory.textures--}function G(T){const _=i.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),i.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(_.__webglFramebuffer[Y]))for(let K=0;K<_.__webglFramebuffer[Y].length;K++)n.deleteFramebuffer(_.__webglFramebuffer[Y][K]);else n.deleteFramebuffer(_.__webglFramebuffer[Y]);_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer[Y])}else{if(Array.isArray(_.__webglFramebuffer))for(let Y=0;Y<_.__webglFramebuffer.length;Y++)n.deleteFramebuffer(_.__webglFramebuffer[Y]);else n.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&n.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Y=0;Y<_.__webglColorRenderbuffer.length;Y++)_.__webglColorRenderbuffer[Y]&&n.deleteRenderbuffer(_.__webglColorRenderbuffer[Y]);_.__webglDepthRenderbuffer&&n.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const I=T.textures;for(let Y=0,K=I.length;Y<K;Y++){const q=i.get(I[Y]);q.__webglTexture&&(n.deleteTexture(q.__webglTexture),a.memory.textures--),i.remove(I[Y])}i.remove(T)}let w=0;function F(){w=0}function N(){const T=w;return T>=r.maxTextures&&Le("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),w+=1,T}function L(T){const _=[];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 B(T,_){const I=i.get(T);if(T.isVideoTexture&&Ce(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&I.__version!==T.version){const Y=T.image;if(Y===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{j(I,T,_);return}}else T.isExternalTexture&&(I.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,I.__webglTexture,n.TEXTURE0+_)}function H(T,_){const I=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&I.__version!==T.version){j(I,T,_);return}else T.isExternalTexture&&(I.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,I.__webglTexture,n.TEXTURE0+_)}function O(T,_){const I=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&I.__version!==T.version){j(I,T,_);return}t.bindTexture(n.TEXTURE_3D,I.__webglTexture,n.TEXTURE0+_)}function J(T,_){const I=i.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&I.__version!==T.version){te(I,T,_);return}t.bindTexture(n.TEXTURE_CUBE_MAP,I.__webglTexture,n.TEXTURE0+_)}const Z={[gs]:n.REPEAT,[hn]:n.CLAMP_TO_EDGE,[_s]:n.MIRRORED_REPEAT},le={[xt]:n.NEAREST,[oc]:n.NEAREST_MIPMAP_NEAREST,[Fi]:n.NEAREST_MIPMAP_LINEAR,[Et]:n.LINEAR,[Tr]:n.LINEAR_MIPMAP_NEAREST,[Bn]:n.LINEAR_MIPMAP_LINEAR},de={[uc]:n.NEVER,[gc]:n.ALWAYS,[fc]:n.LESS,[la]:n.LEQUAL,[dc]:n.EQUAL,[ca]:n.GEQUAL,[pc]:n.GREATER,[mc]:n.NOTEQUAL};function ue(T,_){if(_.type===Yt&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Et||_.magFilter===Tr||_.magFilter===Fi||_.magFilter===Bn||_.minFilter===Et||_.minFilter===Tr||_.minFilter===Fi||_.minFilter===Bn)&&Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(T,n.TEXTURE_WRAP_S,Z[_.wrapS]),n.texParameteri(T,n.TEXTURE_WRAP_T,Z[_.wrapT]),(T===n.TEXTURE_3D||T===n.TEXTURE_2D_ARRAY)&&n.texParameteri(T,n.TEXTURE_WRAP_R,Z[_.wrapR]),n.texParameteri(T,n.TEXTURE_MAG_FILTER,le[_.magFilter]),n.texParameteri(T,n.TEXTURE_MIN_FILTER,le[_.minFilter]),_.compareFunction&&(n.texParameteri(T,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(T,n.TEXTURE_COMPARE_FUNC,de[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===xt||_.minFilter!==Fi&&_.minFilter!==Bn||_.type===Yt&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){const I=e.get("EXT_texture_filter_anisotropic");n.texParameterf(T,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function Pe(T,_){let I=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",A));const Y=_.source;let K=h.get(Y);K===void 0&&(K={},h.set(Y,K));const q=L(_);if(q!==T.__cacheKey){K[q]===void 0&&(K[q]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,I=!0),K[q].usedTimes++;const _e=K[T.__cacheKey];_e!==void 0&&(K[T.__cacheKey].usedTimes--,_e.usedTimes===0&&y(_)),T.__cacheKey=q,T.__webglTexture=K[q].texture}return I}function nt(T,_,I){return Math.floor(Math.floor(T/I)/_)}function Je(T,_,I,Y){const q=T.updateRanges;if(q.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,_.width,_.height,I,Y,_.data);else{q.sort((Q,ne)=>Q.start-ne.start);let _e=0;for(let Q=1;Q<q.length;Q++){const ne=q[_e],xe=q[Q],Me=ne.start+ne.count,fe=nt(xe.start,_.width,4),ze=nt(ne.start,_.width,4);xe.start<=Me+1&&fe===ze&&nt(xe.start+xe.count-1,_.width,4)===fe?ne.count=Math.max(ne.count,xe.start+xe.count-ne.start):(++_e,q[_e]=xe)}q.length=_e+1;const se=n.getParameter(n.UNPACK_ROW_LENGTH),Te=n.getParameter(n.UNPACK_SKIP_PIXELS),Re=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,_.width);for(let Q=0,ne=q.length;Q<ne;Q++){const xe=q[Q],Me=Math.floor(xe.start/4),fe=Math.ceil(xe.count/4),ze=Me%_.width,D=Math.floor(Me/_.width),ae=fe,ie=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,ze),n.pixelStorei(n.UNPACK_SKIP_ROWS,D),t.texSubImage2D(n.TEXTURE_2D,0,ze,D,ae,ie,I,Y,_.data)}T.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,se),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Te),n.pixelStorei(n.UNPACK_SKIP_ROWS,Re)}}function j(T,_,I){let Y=n.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Y=n.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Y=n.TEXTURE_3D);const K=Pe(T,_),q=_.source;t.bindTexture(Y,T.__webglTexture,n.TEXTURE0+I);const _e=i.get(q);if(q.version!==_e.__version||K===!0){t.activeTexture(n.TEXTURE0+I);const se=We.getPrimaries(We.workingColorSpace),Te=_.colorSpace===bn?null:We.getPrimaries(_.colorSpace),Re=_.colorSpace===bn||se===Te?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);let Q=v(_.image,!1,r.maxTextureSize);Q=Ne(_,Q);const ne=s.convert(_.format,_.colorSpace),xe=s.convert(_.type);let Me=b(_.internalFormat,ne,xe,_.colorSpace,_.isVideoTexture);ue(Y,_);let fe;const ze=_.mipmaps,D=_.isVideoTexture!==!0,ae=_e.__version===void 0||K===!0,ie=q.dataReady,me=R(_,Q);if(_.isDepthTexture)Me=E(_.format===zn,_.type),ae&&(D?t.texStorage2D(n.TEXTURE_2D,1,Me,Q.width,Q.height):t.texImage2D(n.TEXTURE_2D,0,Me,Q.width,Q.height,0,ne,xe,null));else if(_.isDataTexture)if(ze.length>0){D&&ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,ze[0].width,ze[0].height);for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,xe,fe.data):t.texImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,ne,xe,fe.data);_.generateMipmaps=!1}else D?(ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,Q.width,Q.height),ie&&Je(_,Q,ne,xe)):t.texImage2D(n.TEXTURE_2D,0,Me,Q.width,Q.height,0,ne,xe,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){D&&ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Me,ze[0].width,ze[0].height,Q.depth);for(let ee=0,X=ze.length;ee<X;ee++)if(fe=ze[ee],_.format!==zt)if(ne!==null)if(D){if(ie)if(_.layerUpdates.size>0){const ve=Ya(fe.width,fe.height,_.format,_.type);for(const Fe of _.layerUpdates){const rt=fe.data.subarray(Fe*ve/fe.data.BYTES_PER_ELEMENT,(Fe+1)*ve/fe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Fe,fe.width,fe.height,1,ne,rt)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,fe.width,fe.height,Q.depth,ne,fe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,Me,fe.width,fe.height,Q.depth,0,fe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,fe.width,fe.height,Q.depth,ne,xe,fe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,Me,fe.width,fe.height,Q.depth,0,ne,xe,fe.data)}else{D&&ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,ze[0].width,ze[0].height);for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],_.format!==zt?ne!==null?D?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,fe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,fe.data):Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,xe,fe.data):t.texImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,ne,xe,fe.data)}else if(_.isDataArrayTexture)if(D){if(ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Me,Q.width,Q.height,Q.depth),ie)if(_.layerUpdates.size>0){const ee=Ya(Q.width,Q.height,_.format,_.type);for(const X of _.layerUpdates){const ve=Q.data.subarray(X*ee/Q.data.BYTES_PER_ELEMENT,(X+1)*ee/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,X,Q.width,Q.height,1,ne,xe,ve)}_.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ne,xe,Q.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Me,Q.width,Q.height,Q.depth,0,ne,xe,Q.data);else if(_.isData3DTexture)D?(ae&&t.texStorage3D(n.TEXTURE_3D,me,Me,Q.width,Q.height,Q.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ne,xe,Q.data)):t.texImage3D(n.TEXTURE_3D,0,Me,Q.width,Q.height,Q.depth,0,ne,xe,Q.data);else if(_.isFramebufferTexture){if(ae)if(D)t.texStorage2D(n.TEXTURE_2D,me,Me,Q.width,Q.height);else{let ee=Q.width,X=Q.height;for(let ve=0;ve<me;ve++)t.texImage2D(n.TEXTURE_2D,ve,Me,ee,X,0,ne,xe,null),ee>>=1,X>>=1}}else if(ze.length>0){if(D&&ae){const ee=ge(ze[0]);t.texStorage2D(n.TEXTURE_2D,me,Me,ee.width,ee.height)}for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ne,xe,fe):t.texImage2D(n.TEXTURE_2D,ee,Me,ne,xe,fe);_.generateMipmaps=!1}else if(D){if(ae){const ee=ge(Q);t.texStorage2D(n.TEXTURE_2D,me,Me,ee.width,ee.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ne,xe,Q)}else t.texImage2D(n.TEXTURE_2D,0,Me,ne,xe,Q);m(_)&&f(Y),_e.__version=q.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function te(T,_,I){if(_.image.length!==6)return;const Y=Pe(T,_),K=_.source;t.bindTexture(n.TEXTURE_CUBE_MAP,T.__webglTexture,n.TEXTURE0+I);const q=i.get(K);if(K.version!==q.__version||Y===!0){t.activeTexture(n.TEXTURE0+I);const _e=We.getPrimaries(We.workingColorSpace),se=_.colorSpace===bn?null:We.getPrimaries(_.colorSpace),Te=_.colorSpace===bn||_e===se?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const Re=_.isCompressedTexture||_.image[0].isCompressedTexture,Q=_.image[0]&&_.image[0].isDataTexture,ne=[];for(let X=0;X<6;X++)!Re&&!Q?ne[X]=v(_.image[X],!0,r.maxCubemapSize):ne[X]=Q?_.image[X].image:_.image[X],ne[X]=Ne(_,ne[X]);const xe=ne[0],Me=s.convert(_.format,_.colorSpace),fe=s.convert(_.type),ze=b(_.internalFormat,Me,fe,_.colorSpace),D=_.isVideoTexture!==!0,ae=q.__version===void 0||Y===!0,ie=K.dataReady;let me=R(_,xe);ue(n.TEXTURE_CUBE_MAP,_);let ee;if(Re){D&&ae&&t.texStorage2D(n.TEXTURE_CUBE_MAP,me,ze,xe.width,xe.height);for(let X=0;X<6;X++){ee=ne[X].mipmaps;for(let ve=0;ve<ee.length;ve++){const Fe=ee[ve];_.format!==zt?Me!==null?D?ie&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,0,0,Fe.width,Fe.height,Me,Fe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,ze,Fe.width,Fe.height,0,Fe.data):Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,0,0,Fe.width,Fe.height,Me,fe,Fe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,ze,Fe.width,Fe.height,0,Me,fe,Fe.data)}}}else{if(ee=_.mipmaps,D&&ae){ee.length>0&&me++;const X=ge(ne[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,me,ze,X.width,X.height)}for(let X=0;X<6;X++)if(Q){D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,ne[X].width,ne[X].height,Me,fe,ne[X].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ze,ne[X].width,ne[X].height,0,Me,fe,ne[X].data);for(let ve=0;ve<ee.length;ve++){const rt=ee[ve].image[X].image;D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,0,0,rt.width,rt.height,Me,fe,rt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,ze,rt.width,rt.height,0,Me,fe,rt.data)}}else{D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Me,fe,ne[X]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ze,Me,fe,ne[X]);for(let ve=0;ve<ee.length;ve++){const Fe=ee[ve];D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,0,0,Me,fe,Fe.image[X]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,ze,Me,fe,Fe.image[X])}}}m(_)&&f(n.TEXTURE_CUBE_MAP),q.__version=K.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function re(T,_,I,Y,K,q){const _e=s.convert(I.format,I.colorSpace),se=s.convert(I.type),Te=b(I.internalFormat,_e,se,I.colorSpace),Re=i.get(_),Q=i.get(I);if(Q.__renderTarget=_,!Re.__hasExternalTextures){const ne=Math.max(1,_.width>>q),xe=Math.max(1,_.height>>q);K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY?t.texImage3D(K,q,Te,ne,xe,_.depth,0,_e,se,null):t.texImage2D(K,q,Te,ne,xe,0,_e,se,null)}t.bindFramebuffer(n.FRAMEBUFFER,T),at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Y,K,Q.__webglTexture,0,P(_)):(K===n.TEXTURE_2D||K>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Y,K,Q.__webglTexture,q),t.bindFramebuffer(n.FRAMEBUFFER,null)}function De(T,_,I){if(n.bindRenderbuffer(n.RENDERBUFFER,T),_.depthBuffer){const Y=_.depthTexture,K=Y&&Y.isDepthTexture?Y.type:null,q=E(_.stencilBuffer,K),_e=_.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;at(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,P(_),q,_.width,_.height):I?n.renderbufferStorageMultisample(n.RENDERBUFFER,P(_),q,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,q,_.width,_.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,_e,n.RENDERBUFFER,T)}else{const Y=_.textures;for(let K=0;K<Y.length;K++){const q=Y[K],_e=s.convert(q.format,q.colorSpace),se=s.convert(q.type),Te=b(q.internalFormat,_e,se,q.colorSpace);at(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,P(_),Te,_.width,_.height):I?n.renderbufferStorageMultisample(n.RENDERBUFFER,P(_),Te,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,Te,_.width,_.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ae(T,_,I){const Y=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,T),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=i.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),Y){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",A)),K.__webglTexture===void 0){K.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,K.__webglTexture),ue(n.TEXTURE_CUBE_MAP,_.depthTexture);const Re=s.convert(_.depthTexture.format),Q=s.convert(_.depthTexture.type);let ne;_.depthTexture.format===mn?ne=n.DEPTH_COMPONENT24:_.depthTexture.format===zn&&(ne=n.DEPTH24_STENCIL8);for(let xe=0;xe<6;xe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,ne,_.width,_.height,0,Re,Q,null)}}else B(_.depthTexture,0);const q=K.__webglTexture,_e=P(_),se=Y?n.TEXTURE_CUBE_MAP_POSITIVE_X+I:n.TEXTURE_2D,Te=_.depthTexture.format===zn?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(_.depthTexture.format===mn)at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Te,se,q,0,_e):n.framebufferTexture2D(n.FRAMEBUFFER,Te,se,q,0);else if(_.depthTexture.format===zn)at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Te,se,q,0,_e):n.framebufferTexture2D(n.FRAMEBUFFER,Te,se,q,0);else throw new Error("Unknown depthTexture format")}function we(T){const _=i.get(T),I=T.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==T.depthTexture){const Y=T.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Y){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Y.removeEventListener("dispose",K)};Y.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=Y}if(T.depthTexture&&!_.__autoAllocateDepthBuffer)if(I)for(let Y=0;Y<6;Y++)Ae(_.__webglFramebuffer[Y],T,Y);else{const Y=T.texture.mipmaps;Y&&Y.length>0?Ae(_.__webglFramebuffer[0],T,0):Ae(_.__webglFramebuffer,T,0)}else if(I){_.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[Y]),_.__webglDepthbuffer[Y]===void 0)_.__webglDepthbuffer[Y]=n.createRenderbuffer(),De(_.__webglDepthbuffer[Y],T,!1);else{const K=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer[Y];n.bindRenderbuffer(n.RENDERBUFFER,q),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,q)}}else{const Y=T.texture.mipmaps;if(Y&&Y.length>0?t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=n.createRenderbuffer(),De(_.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,q),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,q)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ot(T,_,I){const Y=i.get(T);_!==void 0&&re(Y.__webglFramebuffer,T,T.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),I!==void 0&&we(T)}function Ve(T){const _=T.texture,I=i.get(T),Y=i.get(_);T.addEventListener("dispose",C);const K=T.textures,q=T.isWebGLCubeRenderTarget===!0,_e=K.length>1;if(_e||(Y.__webglTexture===void 0&&(Y.__webglTexture=n.createTexture()),Y.__version=_.version,a.memory.textures++),q){I.__webglFramebuffer=[];for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer[se]=[];for(let Te=0;Te<_.mipmaps.length;Te++)I.__webglFramebuffer[se][Te]=n.createFramebuffer()}else I.__webglFramebuffer[se]=n.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer=[];for(let se=0;se<_.mipmaps.length;se++)I.__webglFramebuffer[se]=n.createFramebuffer()}else I.__webglFramebuffer=n.createFramebuffer();if(_e)for(let se=0,Te=K.length;se<Te;se++){const Re=i.get(K[se]);Re.__webglTexture===void 0&&(Re.__webglTexture=n.createTexture(),a.memory.textures++)}if(T.samples>0&&at(T)===!1){I.__webglMultisampledFramebuffer=n.createFramebuffer(),I.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let se=0;se<K.length;se++){const Te=K[se];I.__webglColorRenderbuffer[se]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,I.__webglColorRenderbuffer[se]);const Re=s.convert(Te.format,Te.colorSpace),Q=s.convert(Te.type),ne=b(Te.internalFormat,Re,Q,Te.colorSpace,T.isXRRenderTarget===!0),xe=P(T);n.renderbufferStorageMultisample(n.RENDERBUFFER,xe,ne,T.width,T.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+se,n.RENDERBUFFER,I.__webglColorRenderbuffer[se])}n.bindRenderbuffer(n.RENDERBUFFER,null),T.depthBuffer&&(I.__webglDepthRenderbuffer=n.createRenderbuffer(),De(I.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(q){t.bindTexture(n.TEXTURE_CUBE_MAP,Y.__webglTexture),ue(n.TEXTURE_CUBE_MAP,_);for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(I.__webglFramebuffer[se][Te],T,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+se,Te);else re(I.__webglFramebuffer[se],T,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+se,0);m(_)&&f(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let se=0,Te=K.length;se<Te;se++){const Re=K[se],Q=i.get(Re);let ne=n.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ne=T.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ne,Q.__webglTexture),ue(ne,Re),re(I.__webglFramebuffer,T,Re,n.COLOR_ATTACHMENT0+se,ne,0),m(Re)&&f(ne)}t.unbindTexture()}else{let se=n.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(se=T.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(se,Y.__webglTexture),ue(se,_),_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(I.__webglFramebuffer[Te],T,_,n.COLOR_ATTACHMENT0,se,Te);else re(I.__webglFramebuffer,T,_,n.COLOR_ATTACHMENT0,se,0);m(_)&&f(se),t.unbindTexture()}T.depthBuffer&&we(T)}function Ye(T){const _=T.textures;for(let I=0,Y=_.length;I<Y;I++){const K=_[I];if(m(K)){const q=S(T),_e=i.get(K).__webglTexture;t.bindTexture(q,_e),f(q),t.unbindTexture()}}}const je=[],Ie=[];function st(T){if(T.samples>0){if(at(T)===!1){const _=T.textures,I=T.width,Y=T.height;let K=n.COLOR_BUFFER_BIT;const q=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=i.get(T),se=_.length>1;if(se)for(let Re=0;Re<_.length;Re++)t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer);const Te=T.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let Re=0;Re<_.length;Re++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=n.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=n.STENCIL_BUFFER_BIT)),se){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Re]);const Q=i.get(_[Re]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Q,0)}n.blitFramebuffer(0,0,I,Y,0,0,I,Y,K,n.NEAREST),l===!0&&(je.length=0,Ie.length=0,je.push(n.COLOR_ATTACHMENT0+Re),T.depthBuffer&&T.resolveDepthBuffer===!1&&(je.push(q),Ie.push(q),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ie)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,je))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),se)for(let Re=0;Re<_.length;Re++){t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Re]);const Q=i.get(_[Re]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,Q,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const _=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[_])}}}function P(T){return Math.min(r.maxSamples,T.samples)}function at(T){const _=i.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ce(T){const _=a.render.frame;u.get(T)!==_&&(u.set(T,_),T.update())}function Ne(T,_){const I=T.colorSpace,Y=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||I!==Hn&&I!==bn&&(We.getTransfer(I)===Ke?(Y!==zt||K!==It)&&Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):qe("WebGLTextures: Unsupported texture color space:",I)),_}function ge(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=N,this.resetTextureUnits=F,this.setTexture2D=B,this.setTexture2DArray=H,this.setTexture3D=O,this.setTextureCube=J,this.rebindTextures=ot,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=Ye,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=re,this.useMultisampledRTT=at,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Gp(n,e){function t(i,r=bn){let s;const a=We.getTransfer(r);if(i===It)return n.UNSIGNED_BYTE;if(i===ia)return n.UNSIGNED_SHORT_4_4_4_4;if(i===ra)return n.UNSIGNED_SHORT_5_5_5_1;if(i===jo)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===$o)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===qo)return n.BYTE;if(i===Yo)return n.SHORT;if(i===Ai)return n.UNSIGNED_SHORT;if(i===na)return n.INT;if(i===Kt)return n.UNSIGNED_INT;if(i===Yt)return n.FLOAT;if(i===pn)return n.HALF_FLOAT;if(i===Zo)return n.ALPHA;if(i===Ko)return n.RGB;if(i===zt)return n.RGBA;if(i===mn)return n.DEPTH_COMPONENT;if(i===zn)return n.DEPTH_STENCIL;if(i===Jo)return n.RED;if(i===sa)return n.RED_INTEGER;if(i===hi)return n.RG;if(i===aa)return n.RG_INTEGER;if(i===oa)return n.RGBA_INTEGER;if(i===rr||i===sr||i===ar||i===or)if(a===Ke)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===rr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===sr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ar)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===rr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===sr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ar)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===or)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===xs||i===vs||i===Ms||i===Ss)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===xs)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===vs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ms)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ss)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Es||i===ys||i===bs||i===Ts||i===As||i===ws||i===Rs)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Es||i===ys)return a===Ke?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===bs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ts)return s.COMPRESSED_R11_EAC;if(i===As)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ws)return s.COMPRESSED_RG11_EAC;if(i===Rs)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Cs||i===Ps||i===Ds||i===Ls||i===Is||i===Fs||i===Us||i===Ns||i===Os||i===Bs||i===zs||i===Gs||i===Vs||i===Hs)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Cs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ps)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ds)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ls)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Is)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Fs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Us)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ns)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Os)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Bs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===zs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Gs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Vs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Hs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ks||i===Ws||i===Xs)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===ks)return a===Ke?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ws)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Xs)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===qs||i===Ys||i===js||i===$s)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===qs)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ys)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===js)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===$s)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===wi?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Vp=`
4025
+ }`,Np=[new k(1,0,0),new k(-1,0,0),new k(0,1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1)],Op=[new k(0,-1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1),new k(0,-1,0),new k(0,-1,0)],_o=new ft,yi=new k,ts=new k;function Bp(n,e,t){let i=new ol;const r=new $e,s=new $e,a=new ct,o=new Jc,l=new Qc,c={},u=t.maxTextureSize,m={[An]:At,[At]:An,[cn]:cn},h=new Qt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $e},radius:{value:4}},vertexShader:Fp,fragmentShader:Up}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const g=new en;g.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Jt(g,h),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rr;let f=this.type;this.render=function(A,C,x){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||A.length===0)return;this.type===Vl&&(Le("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=rr);const y=n.getRenderTarget(),G=n.getActiveCubeFace(),w=n.getActiveMipmapLevel(),F=n.state;F.setBlending(un),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const N=f!==this.type;N&&C.traverse(function(L){L.material&&(Array.isArray(L.material)?L.material.forEach(B=>B.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,B=A.length;L<B;L++){const H=A[L],O=H.shadow;if(O===void 0){Le("WebGLShadowMap:",H,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);const J=O.getFrameExtents();r.multiply(J),s.copy(O.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/J.x),r.x=s.x*J.x,O.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/J.y),r.y=s.y*J.y,O.mapSize.y=s.y));const Z=n.state.buffers.depth.getReversed();if(O.camera._reversedDepth=Z,O.map===null||N===!0){if(O.map!==null&&(O.map.depthTexture!==null&&(O.map.depthTexture.dispose(),O.map.depthTexture=null),O.map.dispose()),this.type===bi){if(H.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new Zt(r.x,r.y,{format:hi,type:pn,minFilter:Et,magFilter:Et,generateMipmaps:!1}),O.map.texture.name=H.name+".shadowMap",O.map.depthTexture=new Ci(r.x,r.y,Yt),O.map.depthTexture.name=H.name+".shadowMapDepth",O.map.depthTexture.format=mn,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=xt,O.map.depthTexture.magFilter=xt}else H.isPointLight?(O.map=new pl(r.x),O.map.depthTexture=new Yc(r.x,Kt)):(O.map=new Zt(r.x,r.y),O.map.depthTexture=new Ci(r.x,r.y,Kt)),O.map.depthTexture.name=H.name+".shadowMap",O.map.depthTexture.format=mn,this.type===rr?(O.map.depthTexture.compareFunction=Z?la:oa,O.map.depthTexture.minFilter=Et,O.map.depthTexture.magFilter=Et):(O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=xt,O.map.depthTexture.magFilter=xt);O.camera.updateProjectionMatrix()}const le=O.map.isWebGLCubeRenderTarget?6:1;for(let de=0;de<le;de++){if(O.map.isWebGLCubeRenderTarget)n.setRenderTarget(O.map,de),n.clear();else{de===0&&(n.setRenderTarget(O.map),n.clear());const ue=O.getViewport(de);a.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),F.viewport(a)}if(H.isPointLight){const ue=O.camera,Pe=O.matrix,nt=H.distance||ue.far;nt!==ue.far&&(ue.far=nt,ue.updateProjectionMatrix()),yi.setFromMatrixPosition(H.matrixWorld),ue.position.copy(yi),ts.copy(ue.position),ts.add(Np[de]),ue.up.copy(Op[de]),ue.lookAt(ts),ue.updateMatrixWorld(),Pe.makeTranslation(-yi.x,-yi.y,-yi.z),_o.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),O._frustum.setFromProjectionMatrix(_o,ue.coordinateSystem,ue.reversedDepth)}else O.updateMatrices(H);i=O.getFrustum(),E(C,x,O.camera,H,this.type)}O.isPointLightShadow!==!0&&this.type===bi&&S(O,x),O.needsUpdate=!1}f=this.type,d.needsUpdate=!1,n.setRenderTarget(y,G,w)};function S(A,C){const x=e.update(v);h.defines.VSM_SAMPLES!==A.blurSamples&&(h.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Zt(r.x,r.y,{format:hi,type:pn})),h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value=A.mapSize,h.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(C,null,x,h,v,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(C,null,x,p,v,null)}function b(A,C,x,y){let G=null;const w=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(w!==void 0)G=w;else if(G=x.isPointLight===!0?l:o,n.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const F=G.uuid,N=C.uuid;let L=c[F];L===void 0&&(L={},c[F]=L);let B=L[N];B===void 0&&(B=G.clone(),L[N]=B,C.addEventListener("dispose",R)),G=B}if(G.visible=C.visible,G.wireframe=C.wireframe,y===bi?G.side=C.shadowSide!==null?C.shadowSide:C.side:G.side=C.shadowSide!==null?C.shadowSide:m[C.side],G.alphaMap=C.alphaMap,G.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,G.map=C.map,G.clipShadows=C.clipShadows,G.clippingPlanes=C.clippingPlanes,G.clipIntersection=C.clipIntersection,G.displacementMap=C.displacementMap,G.displacementScale=C.displacementScale,G.displacementBias=C.displacementBias,G.wireframeLinewidth=C.wireframeLinewidth,G.linewidth=C.linewidth,x.isPointLight===!0&&G.isMeshDistanceMaterial===!0){const F=n.properties.get(G);F.light=x}return G}function E(A,C,x,y,G){if(A.visible===!1)return;if(A.layers.test(C.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&G===bi)&&(!A.frustumCulled||i.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);const N=e.update(A),L=A.material;if(Array.isArray(L)){const B=N.groups;for(let H=0,O=B.length;H<O;H++){const J=B[H],Z=L[J.materialIndex];if(Z&&Z.visible){const le=b(A,Z,y,G);A.onBeforeShadow(n,A,C,x,N,le,J),n.renderBufferDirect(x,null,N,le,A,J),A.onAfterShadow(n,A,C,x,N,le,J)}}}else if(L.visible){const B=b(A,L,y,G);A.onBeforeShadow(n,A,C,x,N,B,null),n.renderBufferDirect(x,null,N,B,A,null),A.onAfterShadow(n,A,C,x,N,B,null)}}const F=A.children;for(let N=0,L=F.length;N<L;N++)E(F[N],C,x,y,G)}function R(A){A.target.removeEventListener("dispose",R);for(const x in c){const y=c[x],G=A.target.uuid;G in y&&(y[G].dispose(),delete y[G])}}}function zp(n,e){function t(){let D=!1;const ae=new ct;let ie=null;const me=new ct(0,0,0,0);return{setMask:function(ee){ie!==ee&&!D&&(n.colorMask(ee,ee,ee,ee),ie=ee)},setLocked:function(ee){D=ee},setClear:function(ee,X,ve,Fe,rt){rt===!0&&(ee*=Fe,X*=Fe,ve*=Fe),ae.set(ee,X,ve,Fe),me.equals(ae)===!1&&(n.clearColor(ee,X,ve,Fe),me.copy(ae))},reset:function(){D=!1,ie=null,me.set(-1,0,0,0)}}}function i(){let D=!1,ae=!1,ie=null,me=null,ee=null;return{setReversed:function(X){if(ae!==X){const ve=e.get("EXT_clip_control");X?ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.ZERO_TO_ONE_EXT):ve.clipControlEXT(ve.LOWER_LEFT_EXT,ve.NEGATIVE_ONE_TO_ONE_EXT),ae=X;const Fe=ee;ee=null,this.setClear(Fe)}},getReversed:function(){return ae},setTest:function(X){X?te(n.DEPTH_TEST):re(n.DEPTH_TEST)},setMask:function(X){ie!==X&&!D&&(n.depthMask(X),ie=X)},setFunc:function(X){if(ae&&(X=Sc[X]),me!==X){switch(X){case ls:n.depthFunc(n.NEVER);break;case cs:n.depthFunc(n.ALWAYS);break;case hs:n.depthFunc(n.LESS);break;case li:n.depthFunc(n.LEQUAL);break;case us:n.depthFunc(n.EQUAL);break;case fs:n.depthFunc(n.GEQUAL);break;case ds:n.depthFunc(n.GREATER);break;case ps:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}me=X}},setLocked:function(X){D=X},setClear:function(X){ee!==X&&(ee=X,ae&&(X=1-X),n.clearDepth(X))},reset:function(){D=!1,ie=null,me=null,ee=null,ae=!1}}}function r(){let D=!1,ae=null,ie=null,me=null,ee=null,X=null,ve=null,Fe=null,rt=null;return{setTest:function(Ze){D||(Ze?te(n.STENCIL_TEST):re(n.STENCIL_TEST))},setMask:function(Ze){ae!==Ze&&!D&&(n.stencilMask(Ze),ae=Ze)},setFunc:function(Ze,tn,nn){(ie!==Ze||me!==tn||ee!==nn)&&(n.stencilFunc(Ze,tn,nn),ie=Ze,me=tn,ee=nn)},setOp:function(Ze,tn,nn){(X!==Ze||ve!==tn||Fe!==nn)&&(n.stencilOp(Ze,tn,nn),X=Ze,ve=tn,Fe=nn)},setLocked:function(Ze){D=Ze},setClear:function(Ze){rt!==Ze&&(n.clearStencil(Ze),rt=Ze)},reset:function(){D=!1,ae=null,ie=null,me=null,ee=null,X=null,ve=null,Fe=null,rt=null}}}const s=new t,a=new i,o=new r,l=new WeakMap,c=new WeakMap;let u={},m={},h=new WeakMap,p=[],g=null,v=!1,d=null,f=null,S=null,b=null,E=null,R=null,A=null,C=new tt(0,0,0),x=0,y=!1,G=null,w=null,F=null,N=null,L=null;const B=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,O=0;const J=n.getParameter(n.VERSION);J.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(J)[1]),H=O>=1):J.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),H=O>=2);let Z=null,le={};const de=n.getParameter(n.SCISSOR_BOX),ue=n.getParameter(n.VIEWPORT),Pe=new ct().fromArray(de),nt=new ct().fromArray(ue);function Je(D,ae,ie,me){const ee=new Uint8Array(4),X=n.createTexture();n.bindTexture(D,X),n.texParameteri(D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(D,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let ve=0;ve<ie;ve++)D===n.TEXTURE_3D||D===n.TEXTURE_2D_ARRAY?n.texImage3D(ae,0,n.RGBA,1,1,me,0,n.RGBA,n.UNSIGNED_BYTE,ee):n.texImage2D(ae+ve,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ee);return X}const j={};j[n.TEXTURE_2D]=Je(n.TEXTURE_2D,n.TEXTURE_2D,1),j[n.TEXTURE_CUBE_MAP]=Je(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[n.TEXTURE_2D_ARRAY]=Je(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),j[n.TEXTURE_3D]=Je(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),te(n.DEPTH_TEST),a.setFunc(li),Ie(!1),st(Ea),te(n.CULL_FACE),Ye(un);function te(D){u[D]!==!0&&(n.enable(D),u[D]=!0)}function re(D){u[D]!==!1&&(n.disable(D),u[D]=!1)}function De(D,ae){return m[D]!==ae?(n.bindFramebuffer(D,ae),m[D]=ae,D===n.DRAW_FRAMEBUFFER&&(m[n.FRAMEBUFFER]=ae),D===n.FRAMEBUFFER&&(m[n.DRAW_FRAMEBUFFER]=ae),!0):!1}function Ae(D,ae){let ie=p,me=!1;if(D){ie=h.get(ae),ie===void 0&&(ie=[],h.set(ae,ie));const ee=D.textures;if(ie.length!==ee.length||ie[0]!==n.COLOR_ATTACHMENT0){for(let X=0,ve=ee.length;X<ve;X++)ie[X]=n.COLOR_ATTACHMENT0+X;ie.length=ee.length,me=!0}}else ie[0]!==n.BACK&&(ie[0]=n.BACK,me=!0);me&&n.drawBuffers(ie)}function we(D){return g!==D?(n.useProgram(D),g=D,!0):!1}const ot={[Nn]:n.FUNC_ADD,[kl]:n.FUNC_SUBTRACT,[Wl]:n.FUNC_REVERSE_SUBTRACT};ot[Xl]=n.MIN,ot[ql]=n.MAX;const Ve={[Yl]:n.ZERO,[jl]:n.ONE,[$l]:n.SRC_COLOR,[as]:n.SRC_ALPHA,[tc]:n.SRC_ALPHA_SATURATE,[Ql]:n.DST_COLOR,[Kl]:n.DST_ALPHA,[Zl]:n.ONE_MINUS_SRC_COLOR,[os]:n.ONE_MINUS_SRC_ALPHA,[ec]:n.ONE_MINUS_DST_COLOR,[Jl]:n.ONE_MINUS_DST_ALPHA,[nc]:n.CONSTANT_COLOR,[ic]:n.ONE_MINUS_CONSTANT_COLOR,[rc]:n.CONSTANT_ALPHA,[sc]:n.ONE_MINUS_CONSTANT_ALPHA};function Ye(D,ae,ie,me,ee,X,ve,Fe,rt,Ze){if(D===un){v===!0&&(re(n.BLEND),v=!1);return}if(v===!1&&(te(n.BLEND),v=!0),D!==Hl){if(D!==d||Ze!==y){if((f!==Nn||E!==Nn)&&(n.blendEquation(n.FUNC_ADD),f=Nn,E=Nn),Ze)switch(D){case Gn:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ya:n.blendFunc(n.ONE,n.ONE);break;case ba:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Ta:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:qe("WebGLState: Invalid blending: ",D);break}else switch(D){case Gn:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ya:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case ba:qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ta:qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:qe("WebGLState: Invalid blending: ",D);break}S=null,b=null,R=null,A=null,C.set(0,0,0),x=0,d=D,y=Ze}return}ee=ee||ae,X=X||ie,ve=ve||me,(ae!==f||ee!==E)&&(n.blendEquationSeparate(ot[ae],ot[ee]),f=ae,E=ee),(ie!==S||me!==b||X!==R||ve!==A)&&(n.blendFuncSeparate(Ve[ie],Ve[me],Ve[X],Ve[ve]),S=ie,b=me,R=X,A=ve),(Fe.equals(C)===!1||rt!==x)&&(n.blendColor(Fe.r,Fe.g,Fe.b,rt),C.copy(Fe),x=rt),d=D,y=!1}function je(D,ae){D.side===cn?re(n.CULL_FACE):te(n.CULL_FACE);let ie=D.side===At;ae&&(ie=!ie),Ie(ie),D.blending===Gn&&D.transparent===!1?Ye(un):Ye(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const me=D.stencilWrite;o.setTest(me),me&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),at(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?te(n.SAMPLE_ALPHA_TO_COVERAGE):re(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ie(D){G!==D&&(D?n.frontFace(n.CW):n.frontFace(n.CCW),G=D)}function st(D){D!==zl?(te(n.CULL_FACE),D!==w&&(D===Ea?n.cullFace(n.BACK):D===Gl?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):re(n.CULL_FACE),w=D}function P(D){D!==F&&(H&&n.lineWidth(D),F=D)}function at(D,ae,ie){D?(te(n.POLYGON_OFFSET_FILL),(N!==ae||L!==ie)&&(N=ae,L=ie,a.getReversed()&&(ae=-ae),n.polygonOffset(ae,ie))):re(n.POLYGON_OFFSET_FILL)}function Ce(D){D?te(n.SCISSOR_TEST):re(n.SCISSOR_TEST)}function Ne(D){D===void 0&&(D=n.TEXTURE0+B-1),Z!==D&&(n.activeTexture(D),Z=D)}function ge(D,ae,ie){ie===void 0&&(Z===null?ie=n.TEXTURE0+B-1:ie=Z);let me=le[ie];me===void 0&&(me={type:void 0,texture:void 0},le[ie]=me),(me.type!==D||me.texture!==ae)&&(Z!==ie&&(n.activeTexture(ie),Z=ie),n.bindTexture(D,ae||j[D]),me.type=D,me.texture=ae)}function T(){const D=le[Z];D!==void 0&&D.type!==void 0&&(n.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function _(){try{n.compressedTexImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function I(){try{n.compressedTexImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function Y(){try{n.texSubImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function K(){try{n.texSubImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function q(){try{n.compressedTexSubImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function _e(){try{n.compressedTexSubImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function se(){try{n.texStorage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function Te(){try{n.texStorage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function Re(){try{n.texImage2D(...arguments)}catch(D){qe("WebGLState:",D)}}function Q(){try{n.texImage3D(...arguments)}catch(D){qe("WebGLState:",D)}}function ne(D){Pe.equals(D)===!1&&(n.scissor(D.x,D.y,D.z,D.w),Pe.copy(D))}function xe(D){nt.equals(D)===!1&&(n.viewport(D.x,D.y,D.z,D.w),nt.copy(D))}function Me(D,ae){let ie=c.get(ae);ie===void 0&&(ie=new WeakMap,c.set(ae,ie));let me=ie.get(D);me===void 0&&(me=n.getUniformBlockIndex(ae,D.name),ie.set(D,me))}function fe(D,ae){const me=c.get(ae).get(D);l.get(ae)!==me&&(n.uniformBlockBinding(ae,me,D.__bindingPointIndex),l.set(ae,me))}function ze(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),u={},Z=null,le={},m={},h=new WeakMap,p=[],g=null,v=!1,d=null,f=null,S=null,b=null,E=null,R=null,A=null,C=new tt(0,0,0),x=0,y=!1,G=null,w=null,F=null,N=null,L=null,Pe.set(0,0,n.canvas.width,n.canvas.height),nt.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:te,disable:re,bindFramebuffer:De,drawBuffers:Ae,useProgram:we,setBlending:Ye,setMaterial:je,setFlipSided:Ie,setCullFace:st,setLineWidth:P,setPolygonOffset:at,setScissorTest:Ce,activeTexture:Ne,bindTexture:ge,unbindTexture:T,compressedTexImage2D:_,compressedTexImage3D:I,texImage2D:Re,texImage3D:Q,updateUBOMapping:Me,uniformBlockBinding:fe,texStorage2D:se,texStorage3D:Te,texSubImage2D:Y,texSubImage3D:K,compressedTexSubImage2D:q,compressedTexSubImage3D:_e,scissor:ne,viewport:xe,reset:ze}}function Gp(n,e,t,i,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new $e,u=new WeakMap;let m;const h=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(T,_){return p?new OffscreenCanvas(T,_):fr("canvas")}function v(T,_,I){let Y=1;const K=ge(T);if((K.width>I||K.height>I)&&(Y=I/Math.max(K.width,K.height)),Y<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){const q=Math.floor(Y*K.width),_e=Math.floor(Y*K.height);m===void 0&&(m=g(q,_e));const se=_?g(q,_e):m;return se.width=q,se.height=_e,se.getContext("2d").drawImage(T,0,0,q,_e),Le("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+q+"x"+_e+")."),se}else return"data"in T&&Le("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function d(T){return T.generateMipmaps}function f(T){n.generateMipmap(T)}function S(T){return T.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?n.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function b(T,_,I,Y,K=!1){if(T!==null){if(n[T]!==void 0)return n[T];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let q=_;if(_===n.RED&&(I===n.FLOAT&&(q=n.R32F),I===n.HALF_FLOAT&&(q=n.R16F),I===n.UNSIGNED_BYTE&&(q=n.R8)),_===n.RED_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.R8UI),I===n.UNSIGNED_SHORT&&(q=n.R16UI),I===n.UNSIGNED_INT&&(q=n.R32UI),I===n.BYTE&&(q=n.R8I),I===n.SHORT&&(q=n.R16I),I===n.INT&&(q=n.R32I)),_===n.RG&&(I===n.FLOAT&&(q=n.RG32F),I===n.HALF_FLOAT&&(q=n.RG16F),I===n.UNSIGNED_BYTE&&(q=n.RG8)),_===n.RG_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RG8UI),I===n.UNSIGNED_SHORT&&(q=n.RG16UI),I===n.UNSIGNED_INT&&(q=n.RG32UI),I===n.BYTE&&(q=n.RG8I),I===n.SHORT&&(q=n.RG16I),I===n.INT&&(q=n.RG32I)),_===n.RGB_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RGB8UI),I===n.UNSIGNED_SHORT&&(q=n.RGB16UI),I===n.UNSIGNED_INT&&(q=n.RGB32UI),I===n.BYTE&&(q=n.RGB8I),I===n.SHORT&&(q=n.RGB16I),I===n.INT&&(q=n.RGB32I)),_===n.RGBA_INTEGER&&(I===n.UNSIGNED_BYTE&&(q=n.RGBA8UI),I===n.UNSIGNED_SHORT&&(q=n.RGBA16UI),I===n.UNSIGNED_INT&&(q=n.RGBA32UI),I===n.BYTE&&(q=n.RGBA8I),I===n.SHORT&&(q=n.RGBA16I),I===n.INT&&(q=n.RGBA32I)),_===n.RGB&&(I===n.UNSIGNED_INT_5_9_9_9_REV&&(q=n.RGB9_E5),I===n.UNSIGNED_INT_10F_11F_11F_REV&&(q=n.R11F_G11F_B10F)),_===n.RGBA){const _e=K?hr:We.getTransfer(Y);I===n.FLOAT&&(q=n.RGBA32F),I===n.HALF_FLOAT&&(q=n.RGBA16F),I===n.UNSIGNED_BYTE&&(q=_e===Ke?n.SRGB8_ALPHA8:n.RGBA8),I===n.UNSIGNED_SHORT_4_4_4_4&&(q=n.RGBA4),I===n.UNSIGNED_SHORT_5_5_5_1&&(q=n.RGB5_A1)}return(q===n.R16F||q===n.R32F||q===n.RG16F||q===n.RG32F||q===n.RGBA16F||q===n.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function E(T,_){let I;return T?_===null||_===Kt||_===Ri?I=n.DEPTH24_STENCIL8:_===Yt?I=n.DEPTH32F_STENCIL8:_===wi&&(I=n.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Kt||_===Ri?I=n.DEPTH_COMPONENT24:_===Yt?I=n.DEPTH_COMPONENT32F:_===wi&&(I=n.DEPTH_COMPONENT16),I}function R(T,_){return d(T)===!0||T.isFramebufferTexture&&T.minFilter!==xt&&T.minFilter!==Et?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 A(T){const _=T.target;_.removeEventListener("dispose",A),x(_),_.isVideoTexture&&u.delete(_)}function C(T){const _=T.target;_.removeEventListener("dispose",C),G(_)}function x(T){const _=i.get(T);if(_.__webglInit===void 0)return;const I=T.source,Y=h.get(I);if(Y){const K=Y[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&y(T),Object.keys(Y).length===0&&h.delete(I)}i.remove(T)}function y(T){const _=i.get(T);n.deleteTexture(_.__webglTexture);const I=T.source,Y=h.get(I);delete Y[_.__cacheKey],a.memory.textures--}function G(T){const _=i.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),i.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(_.__webglFramebuffer[Y]))for(let K=0;K<_.__webglFramebuffer[Y].length;K++)n.deleteFramebuffer(_.__webglFramebuffer[Y][K]);else n.deleteFramebuffer(_.__webglFramebuffer[Y]);_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer[Y])}else{if(Array.isArray(_.__webglFramebuffer))for(let Y=0;Y<_.__webglFramebuffer.length;Y++)n.deleteFramebuffer(_.__webglFramebuffer[Y]);else n.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&n.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Y=0;Y<_.__webglColorRenderbuffer.length;Y++)_.__webglColorRenderbuffer[Y]&&n.deleteRenderbuffer(_.__webglColorRenderbuffer[Y]);_.__webglDepthRenderbuffer&&n.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const I=T.textures;for(let Y=0,K=I.length;Y<K;Y++){const q=i.get(I[Y]);q.__webglTexture&&(n.deleteTexture(q.__webglTexture),a.memory.textures--),i.remove(I[Y])}i.remove(T)}let w=0;function F(){w=0}function N(){const T=w;return T>=r.maxTextures&&Le("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),w+=1,T}function L(T){const _=[];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 B(T,_){const I=i.get(T);if(T.isVideoTexture&&Ce(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&I.__version!==T.version){const Y=T.image;if(Y===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{j(I,T,_);return}}else T.isExternalTexture&&(I.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,I.__webglTexture,n.TEXTURE0+_)}function H(T,_){const I=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&I.__version!==T.version){j(I,T,_);return}else T.isExternalTexture&&(I.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,I.__webglTexture,n.TEXTURE0+_)}function O(T,_){const I=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&I.__version!==T.version){j(I,T,_);return}t.bindTexture(n.TEXTURE_3D,I.__webglTexture,n.TEXTURE0+_)}function J(T,_){const I=i.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&I.__version!==T.version){te(I,T,_);return}t.bindTexture(n.TEXTURE_CUBE_MAP,I.__webglTexture,n.TEXTURE0+_)}const Z={[ms]:n.REPEAT,[hn]:n.CLAMP_TO_EDGE,[gs]:n.MIRRORED_REPEAT},le={[xt]:n.NEAREST,[lc]:n.NEAREST_MIPMAP_NEAREST,[Ui]:n.NEAREST_MIPMAP_LINEAR,[Et]:n.LINEAR,[Tr]:n.LINEAR_MIPMAP_NEAREST,[Bn]:n.LINEAR_MIPMAP_LINEAR},de={[fc]:n.NEVER,[_c]:n.ALWAYS,[dc]:n.LESS,[oa]:n.LEQUAL,[pc]:n.EQUAL,[la]:n.GEQUAL,[mc]:n.GREATER,[gc]:n.NOTEQUAL};function ue(T,_){if(_.type===Yt&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Et||_.magFilter===Tr||_.magFilter===Ui||_.magFilter===Bn||_.minFilter===Et||_.minFilter===Tr||_.minFilter===Ui||_.minFilter===Bn)&&Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(T,n.TEXTURE_WRAP_S,Z[_.wrapS]),n.texParameteri(T,n.TEXTURE_WRAP_T,Z[_.wrapT]),(T===n.TEXTURE_3D||T===n.TEXTURE_2D_ARRAY)&&n.texParameteri(T,n.TEXTURE_WRAP_R,Z[_.wrapR]),n.texParameteri(T,n.TEXTURE_MAG_FILTER,le[_.magFilter]),n.texParameteri(T,n.TEXTURE_MIN_FILTER,le[_.minFilter]),_.compareFunction&&(n.texParameteri(T,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(T,n.TEXTURE_COMPARE_FUNC,de[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===xt||_.minFilter!==Ui&&_.minFilter!==Bn||_.type===Yt&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){const I=e.get("EXT_texture_filter_anisotropic");n.texParameterf(T,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function Pe(T,_){let I=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",A));const Y=_.source;let K=h.get(Y);K===void 0&&(K={},h.set(Y,K));const q=L(_);if(q!==T.__cacheKey){K[q]===void 0&&(K[q]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,I=!0),K[q].usedTimes++;const _e=K[T.__cacheKey];_e!==void 0&&(K[T.__cacheKey].usedTimes--,_e.usedTimes===0&&y(_)),T.__cacheKey=q,T.__webglTexture=K[q].texture}return I}function nt(T,_,I){return Math.floor(Math.floor(T/I)/_)}function Je(T,_,I,Y){const q=T.updateRanges;if(q.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,_.width,_.height,I,Y,_.data);else{q.sort((Q,ne)=>Q.start-ne.start);let _e=0;for(let Q=1;Q<q.length;Q++){const ne=q[_e],xe=q[Q],Me=ne.start+ne.count,fe=nt(xe.start,_.width,4),ze=nt(ne.start,_.width,4);xe.start<=Me+1&&fe===ze&&nt(xe.start+xe.count-1,_.width,4)===fe?ne.count=Math.max(ne.count,xe.start+xe.count-ne.start):(++_e,q[_e]=xe)}q.length=_e+1;const se=n.getParameter(n.UNPACK_ROW_LENGTH),Te=n.getParameter(n.UNPACK_SKIP_PIXELS),Re=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,_.width);for(let Q=0,ne=q.length;Q<ne;Q++){const xe=q[Q],Me=Math.floor(xe.start/4),fe=Math.ceil(xe.count/4),ze=Me%_.width,D=Math.floor(Me/_.width),ae=fe,ie=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,ze),n.pixelStorei(n.UNPACK_SKIP_ROWS,D),t.texSubImage2D(n.TEXTURE_2D,0,ze,D,ae,ie,I,Y,_.data)}T.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,se),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Te),n.pixelStorei(n.UNPACK_SKIP_ROWS,Re)}}function j(T,_,I){let Y=n.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Y=n.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Y=n.TEXTURE_3D);const K=Pe(T,_),q=_.source;t.bindTexture(Y,T.__webglTexture,n.TEXTURE0+I);const _e=i.get(q);if(q.version!==_e.__version||K===!0){t.activeTexture(n.TEXTURE0+I);const se=We.getPrimaries(We.workingColorSpace),Te=_.colorSpace===bn?null:We.getPrimaries(_.colorSpace),Re=_.colorSpace===bn||se===Te?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);let Q=v(_.image,!1,r.maxTextureSize);Q=Ne(_,Q);const ne=s.convert(_.format,_.colorSpace),xe=s.convert(_.type);let Me=b(_.internalFormat,ne,xe,_.colorSpace,_.isVideoTexture);ue(Y,_);let fe;const ze=_.mipmaps,D=_.isVideoTexture!==!0,ae=_e.__version===void 0||K===!0,ie=q.dataReady,me=R(_,Q);if(_.isDepthTexture)Me=E(_.format===zn,_.type),ae&&(D?t.texStorage2D(n.TEXTURE_2D,1,Me,Q.width,Q.height):t.texImage2D(n.TEXTURE_2D,0,Me,Q.width,Q.height,0,ne,xe,null));else if(_.isDataTexture)if(ze.length>0){D&&ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,ze[0].width,ze[0].height);for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,xe,fe.data):t.texImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,ne,xe,fe.data);_.generateMipmaps=!1}else D?(ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,Q.width,Q.height),ie&&Je(_,Q,ne,xe)):t.texImage2D(n.TEXTURE_2D,0,Me,Q.width,Q.height,0,ne,xe,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){D&&ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Me,ze[0].width,ze[0].height,Q.depth);for(let ee=0,X=ze.length;ee<X;ee++)if(fe=ze[ee],_.format!==zt)if(ne!==null)if(D){if(ie)if(_.layerUpdates.size>0){const ve=Ya(fe.width,fe.height,_.format,_.type);for(const Fe of _.layerUpdates){const rt=fe.data.subarray(Fe*ve/fe.data.BYTES_PER_ELEMENT,(Fe+1)*ve/fe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,Fe,fe.width,fe.height,1,ne,rt)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,fe.width,fe.height,Q.depth,ne,fe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ee,Me,fe.width,fe.height,Q.depth,0,fe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ee,0,0,0,fe.width,fe.height,Q.depth,ne,xe,fe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ee,Me,fe.width,fe.height,Q.depth,0,ne,xe,fe.data)}else{D&&ae&&t.texStorage2D(n.TEXTURE_2D,me,Me,ze[0].width,ze[0].height);for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],_.format!==zt?ne!==null?D?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,fe.data):t.compressedTexImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,fe.data):Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,fe.width,fe.height,ne,xe,fe.data):t.texImage2D(n.TEXTURE_2D,ee,Me,fe.width,fe.height,0,ne,xe,fe.data)}else if(_.isDataArrayTexture)if(D){if(ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,me,Me,Q.width,Q.height,Q.depth),ie)if(_.layerUpdates.size>0){const ee=Ya(Q.width,Q.height,_.format,_.type);for(const X of _.layerUpdates){const ve=Q.data.subarray(X*ee/Q.data.BYTES_PER_ELEMENT,(X+1)*ee/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,X,Q.width,Q.height,1,ne,xe,ve)}_.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ne,xe,Q.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Me,Q.width,Q.height,Q.depth,0,ne,xe,Q.data);else if(_.isData3DTexture)D?(ae&&t.texStorage3D(n.TEXTURE_3D,me,Me,Q.width,Q.height,Q.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ne,xe,Q.data)):t.texImage3D(n.TEXTURE_3D,0,Me,Q.width,Q.height,Q.depth,0,ne,xe,Q.data);else if(_.isFramebufferTexture){if(ae)if(D)t.texStorage2D(n.TEXTURE_2D,me,Me,Q.width,Q.height);else{let ee=Q.width,X=Q.height;for(let ve=0;ve<me;ve++)t.texImage2D(n.TEXTURE_2D,ve,Me,ee,X,0,ne,xe,null),ee>>=1,X>>=1}}else if(ze.length>0){if(D&&ae){const ee=ge(ze[0]);t.texStorage2D(n.TEXTURE_2D,me,Me,ee.width,ee.height)}for(let ee=0,X=ze.length;ee<X;ee++)fe=ze[ee],D?ie&&t.texSubImage2D(n.TEXTURE_2D,ee,0,0,ne,xe,fe):t.texImage2D(n.TEXTURE_2D,ee,Me,ne,xe,fe);_.generateMipmaps=!1}else if(D){if(ae){const ee=ge(Q);t.texStorage2D(n.TEXTURE_2D,me,Me,ee.width,ee.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ne,xe,Q)}else t.texImage2D(n.TEXTURE_2D,0,Me,ne,xe,Q);d(_)&&f(Y),_e.__version=q.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function te(T,_,I){if(_.image.length!==6)return;const Y=Pe(T,_),K=_.source;t.bindTexture(n.TEXTURE_CUBE_MAP,T.__webglTexture,n.TEXTURE0+I);const q=i.get(K);if(K.version!==q.__version||Y===!0){t.activeTexture(n.TEXTURE0+I);const _e=We.getPrimaries(We.workingColorSpace),se=_.colorSpace===bn?null:We.getPrimaries(_.colorSpace),Te=_.colorSpace===bn||_e===se?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Te);const Re=_.isCompressedTexture||_.image[0].isCompressedTexture,Q=_.image[0]&&_.image[0].isDataTexture,ne=[];for(let X=0;X<6;X++)!Re&&!Q?ne[X]=v(_.image[X],!0,r.maxCubemapSize):ne[X]=Q?_.image[X].image:_.image[X],ne[X]=Ne(_,ne[X]);const xe=ne[0],Me=s.convert(_.format,_.colorSpace),fe=s.convert(_.type),ze=b(_.internalFormat,Me,fe,_.colorSpace),D=_.isVideoTexture!==!0,ae=q.__version===void 0||Y===!0,ie=K.dataReady;let me=R(_,xe);ue(n.TEXTURE_CUBE_MAP,_);let ee;if(Re){D&&ae&&t.texStorage2D(n.TEXTURE_CUBE_MAP,me,ze,xe.width,xe.height);for(let X=0;X<6;X++){ee=ne[X].mipmaps;for(let ve=0;ve<ee.length;ve++){const Fe=ee[ve];_.format!==zt?Me!==null?D?ie&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,0,0,Fe.width,Fe.height,Me,Fe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,ze,Fe.width,Fe.height,0,Fe.data):Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,0,0,Fe.width,Fe.height,Me,fe,Fe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve,ze,Fe.width,Fe.height,0,Me,fe,Fe.data)}}}else{if(ee=_.mipmaps,D&&ae){ee.length>0&&me++;const X=ge(ne[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,me,ze,X.width,X.height)}for(let X=0;X<6;X++)if(Q){D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,ne[X].width,ne[X].height,Me,fe,ne[X].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ze,ne[X].width,ne[X].height,0,Me,fe,ne[X].data);for(let ve=0;ve<ee.length;ve++){const rt=ee[ve].image[X].image;D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,0,0,rt.width,rt.height,Me,fe,rt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,ze,rt.width,rt.height,0,Me,fe,rt.data)}}else{D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Me,fe,ne[X]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ze,Me,fe,ne[X]);for(let ve=0;ve<ee.length;ve++){const Fe=ee[ve];D?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,0,0,Me,fe,Fe.image[X]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+X,ve+1,ze,Me,fe,Fe.image[X])}}}d(_)&&f(n.TEXTURE_CUBE_MAP),q.__version=K.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function re(T,_,I,Y,K,q){const _e=s.convert(I.format,I.colorSpace),se=s.convert(I.type),Te=b(I.internalFormat,_e,se,I.colorSpace),Re=i.get(_),Q=i.get(I);if(Q.__renderTarget=_,!Re.__hasExternalTextures){const ne=Math.max(1,_.width>>q),xe=Math.max(1,_.height>>q);K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY?t.texImage3D(K,q,Te,ne,xe,_.depth,0,_e,se,null):t.texImage2D(K,q,Te,ne,xe,0,_e,se,null)}t.bindFramebuffer(n.FRAMEBUFFER,T),at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Y,K,Q.__webglTexture,0,P(_)):(K===n.TEXTURE_2D||K>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Y,K,Q.__webglTexture,q),t.bindFramebuffer(n.FRAMEBUFFER,null)}function De(T,_,I){if(n.bindRenderbuffer(n.RENDERBUFFER,T),_.depthBuffer){const Y=_.depthTexture,K=Y&&Y.isDepthTexture?Y.type:null,q=E(_.stencilBuffer,K),_e=_.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;at(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,P(_),q,_.width,_.height):I?n.renderbufferStorageMultisample(n.RENDERBUFFER,P(_),q,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,q,_.width,_.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,_e,n.RENDERBUFFER,T)}else{const Y=_.textures;for(let K=0;K<Y.length;K++){const q=Y[K],_e=s.convert(q.format,q.colorSpace),se=s.convert(q.type),Te=b(q.internalFormat,_e,se,q.colorSpace);at(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,P(_),Te,_.width,_.height):I?n.renderbufferStorageMultisample(n.RENDERBUFFER,P(_),Te,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,Te,_.width,_.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ae(T,_,I){const Y=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,T),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const K=i.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),Y){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",A)),K.__webglTexture===void 0){K.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,K.__webglTexture),ue(n.TEXTURE_CUBE_MAP,_.depthTexture);const Re=s.convert(_.depthTexture.format),Q=s.convert(_.depthTexture.type);let ne;_.depthTexture.format===mn?ne=n.DEPTH_COMPONENT24:_.depthTexture.format===zn&&(ne=n.DEPTH24_STENCIL8);for(let xe=0;xe<6;xe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,ne,_.width,_.height,0,Re,Q,null)}}else B(_.depthTexture,0);const q=K.__webglTexture,_e=P(_),se=Y?n.TEXTURE_CUBE_MAP_POSITIVE_X+I:n.TEXTURE_2D,Te=_.depthTexture.format===zn?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(_.depthTexture.format===mn)at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Te,se,q,0,_e):n.framebufferTexture2D(n.FRAMEBUFFER,Te,se,q,0);else if(_.depthTexture.format===zn)at(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Te,se,q,0,_e):n.framebufferTexture2D(n.FRAMEBUFFER,Te,se,q,0);else throw new Error("Unknown depthTexture format")}function we(T){const _=i.get(T),I=T.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==T.depthTexture){const Y=T.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Y){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Y.removeEventListener("dispose",K)};Y.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=Y}if(T.depthTexture&&!_.__autoAllocateDepthBuffer)if(I)for(let Y=0;Y<6;Y++)Ae(_.__webglFramebuffer[Y],T,Y);else{const Y=T.texture.mipmaps;Y&&Y.length>0?Ae(_.__webglFramebuffer[0],T,0):Ae(_.__webglFramebuffer,T,0)}else if(I){_.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[Y]),_.__webglDepthbuffer[Y]===void 0)_.__webglDepthbuffer[Y]=n.createRenderbuffer(),De(_.__webglDepthbuffer[Y],T,!1);else{const K=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer[Y];n.bindRenderbuffer(n.RENDERBUFFER,q),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,q)}}else{const Y=T.texture.mipmaps;if(Y&&Y.length>0?t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=n.createRenderbuffer(),De(_.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,q=_.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,q),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,q)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ot(T,_,I){const Y=i.get(T);_!==void 0&&re(Y.__webglFramebuffer,T,T.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),I!==void 0&&we(T)}function Ve(T){const _=T.texture,I=i.get(T),Y=i.get(_);T.addEventListener("dispose",C);const K=T.textures,q=T.isWebGLCubeRenderTarget===!0,_e=K.length>1;if(_e||(Y.__webglTexture===void 0&&(Y.__webglTexture=n.createTexture()),Y.__version=_.version,a.memory.textures++),q){I.__webglFramebuffer=[];for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer[se]=[];for(let Te=0;Te<_.mipmaps.length;Te++)I.__webglFramebuffer[se][Te]=n.createFramebuffer()}else I.__webglFramebuffer[se]=n.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer=[];for(let se=0;se<_.mipmaps.length;se++)I.__webglFramebuffer[se]=n.createFramebuffer()}else I.__webglFramebuffer=n.createFramebuffer();if(_e)for(let se=0,Te=K.length;se<Te;se++){const Re=i.get(K[se]);Re.__webglTexture===void 0&&(Re.__webglTexture=n.createTexture(),a.memory.textures++)}if(T.samples>0&&at(T)===!1){I.__webglMultisampledFramebuffer=n.createFramebuffer(),I.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let se=0;se<K.length;se++){const Te=K[se];I.__webglColorRenderbuffer[se]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,I.__webglColorRenderbuffer[se]);const Re=s.convert(Te.format,Te.colorSpace),Q=s.convert(Te.type),ne=b(Te.internalFormat,Re,Q,Te.colorSpace,T.isXRRenderTarget===!0),xe=P(T);n.renderbufferStorageMultisample(n.RENDERBUFFER,xe,ne,T.width,T.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+se,n.RENDERBUFFER,I.__webglColorRenderbuffer[se])}n.bindRenderbuffer(n.RENDERBUFFER,null),T.depthBuffer&&(I.__webglDepthRenderbuffer=n.createRenderbuffer(),De(I.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(q){t.bindTexture(n.TEXTURE_CUBE_MAP,Y.__webglTexture),ue(n.TEXTURE_CUBE_MAP,_);for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(I.__webglFramebuffer[se][Te],T,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+se,Te);else re(I.__webglFramebuffer[se],T,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+se,0);d(_)&&f(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let se=0,Te=K.length;se<Te;se++){const Re=K[se],Q=i.get(Re);let ne=n.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ne=T.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ne,Q.__webglTexture),ue(ne,Re),re(I.__webglFramebuffer,T,Re,n.COLOR_ATTACHMENT0+se,ne,0),d(Re)&&f(ne)}t.unbindTexture()}else{let se=n.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(se=T.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(se,Y.__webglTexture),ue(se,_),_.mipmaps&&_.mipmaps.length>0)for(let Te=0;Te<_.mipmaps.length;Te++)re(I.__webglFramebuffer[Te],T,_,n.COLOR_ATTACHMENT0,se,Te);else re(I.__webglFramebuffer,T,_,n.COLOR_ATTACHMENT0,se,0);d(_)&&f(se),t.unbindTexture()}T.depthBuffer&&we(T)}function Ye(T){const _=T.textures;for(let I=0,Y=_.length;I<Y;I++){const K=_[I];if(d(K)){const q=S(T),_e=i.get(K).__webglTexture;t.bindTexture(q,_e),f(q),t.unbindTexture()}}}const je=[],Ie=[];function st(T){if(T.samples>0){if(at(T)===!1){const _=T.textures,I=T.width,Y=T.height;let K=n.COLOR_BUFFER_BIT;const q=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=i.get(T),se=_.length>1;if(se)for(let Re=0;Re<_.length;Re++)t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer);const Te=T.texture.mipmaps;Te&&Te.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let Re=0;Re<_.length;Re++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=n.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=n.STENCIL_BUFFER_BIT)),se){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Re]);const Q=i.get(_[Re]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Q,0)}n.blitFramebuffer(0,0,I,Y,0,0,I,Y,K,n.NEAREST),l===!0&&(je.length=0,Ie.length=0,je.push(n.COLOR_ATTACHMENT0+Re),T.depthBuffer&&T.resolveDepthBuffer===!1&&(je.push(q),Ie.push(q),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ie)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,je))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),se)for(let Re=0;Re<_.length;Re++){t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,_e.__webglColorRenderbuffer[Re]);const Q=i.get(_[Re]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,_e.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.TEXTURE_2D,Q,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const _=T.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[_])}}}function P(T){return Math.min(r.maxSamples,T.samples)}function at(T){const _=i.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ce(T){const _=a.render.frame;u.get(T)!==_&&(u.set(T,_),T.update())}function Ne(T,_){const I=T.colorSpace,Y=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||I!==Hn&&I!==bn&&(We.getTransfer(I)===Ke?(Y!==zt||K!==It)&&Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):qe("WebGLTextures: Unsupported texture color space:",I)),_}function ge(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=N,this.resetTextureUnits=F,this.setTexture2D=B,this.setTexture2DArray=H,this.setTexture3D=O,this.setTextureCube=J,this.rebindTextures=ot,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=Ye,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=re,this.useMultisampledRTT=at,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Vp(n,e){function t(i,r=bn){let s;const a=We.getTransfer(r);if(i===It)return n.UNSIGNED_BYTE;if(i===na)return n.UNSIGNED_SHORT_4_4_4_4;if(i===ia)return n.UNSIGNED_SHORT_5_5_5_1;if(i===jo)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===$o)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===qo)return n.BYTE;if(i===Yo)return n.SHORT;if(i===wi)return n.UNSIGNED_SHORT;if(i===ta)return n.INT;if(i===Kt)return n.UNSIGNED_INT;if(i===Yt)return n.FLOAT;if(i===pn)return n.HALF_FLOAT;if(i===Zo)return n.ALPHA;if(i===Ko)return n.RGB;if(i===zt)return n.RGBA;if(i===mn)return n.DEPTH_COMPONENT;if(i===zn)return n.DEPTH_STENCIL;if(i===Jo)return n.RED;if(i===ra)return n.RED_INTEGER;if(i===hi)return n.RG;if(i===sa)return n.RG_INTEGER;if(i===aa)return n.RGBA_INTEGER;if(i===sr||i===ar||i===or||i===lr)if(a===Ke)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===sr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ar)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===lr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===sr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ar)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===or)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===lr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===_s||i===xs||i===vs||i===Ms)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===_s)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===xs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===vs)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ms)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ss||i===Es||i===ys||i===bs||i===Ts||i===As||i===ws)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Ss||i===Es)return a===Ke?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===ys)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===bs)return s.COMPRESSED_R11_EAC;if(i===Ts)return s.COMPRESSED_SIGNED_R11_EAC;if(i===As)return s.COMPRESSED_RG11_EAC;if(i===ws)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Rs||i===Cs||i===Ps||i===Ds||i===Ls||i===Is||i===Fs||i===Us||i===Ns||i===Os||i===Bs||i===zs||i===Gs||i===Vs)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Rs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Cs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ps)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ds)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ls)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Is)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Fs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Us)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ns)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Os)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Bs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===zs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Gs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Vs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Hs||i===ks||i===Ws)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Hs)return a===Ke?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ks)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ws)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Xs||i===qs||i===Ys||i===js)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Xs)return s.COMPRESSED_RED_RGTC1_EXT;if(i===qs)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ys)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===js)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ri?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Hp=`
4026
4026
  void main() {
4027
4027
 
4028
4028
  gl_Position = vec4( position, 1.0 );
4029
4029
 
4030
- }`,Hp=`
4030
+ }`,kp=`
4031
4031
  uniform sampler2DArray depthColor;
4032
4032
  uniform float depthWidth;
4033
4033
  uniform float depthHeight;
@@ -4046,13 +4046,13 @@ void main() {
4046
4046
 
4047
4047
  }
4048
4048
 
4049
- }`;class kp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new cl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Qt({vertexShader:Vp,fragmentShader:Hp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jt(new gr(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Wp extends fi{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,p=null,h=null,d=null,g=null;const v=typeof XRWebGLBinding<"u",m=new kp,f={},S=t.getContextAttributes();let b=null,E=null;const R=[],A=[],C=new $e;let x=null;const y=new Bt;y.viewport=new ct;const G=new Bt;G.viewport=new ct;const w=[y,G],F=new eh;let N=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getTargetRaySpace()},this.getControllerGrip=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getGripSpace()},this.getHand=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getHandSpace()};function B(j){const te=A.indexOf(j.inputSource);if(te===-1)return;const re=R[te];re!==void 0&&(re.update(j.inputSource,j.frame,c||a),re.dispatchEvent({type:j.type,data:j.inputSource}))}function H(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",O);for(let j=0;j<R.length;j++){const te=A[j];te!==null&&(A[j]=null,R[j].disconnect(te))}N=null,L=null,m.reset();for(const j in f)delete f[j];e.setRenderTarget(b),d=null,h=null,p=null,r=null,E=null,Je.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,i.isPresenting===!0&&Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return p===null&&v&&(p=new XRWebGLBinding(r,t)),p},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(j){if(r=j,r!==null){if(b=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",H),r.addEventListener("inputsourceschange",O),S.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(C),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,De=null,Ae=null;S.depth&&(Ae=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=S.stencil?zn:mn,De=S.stencil?wi:Kt);const we={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};p=this.getBinding(),h=p.createProjectionLayer(we),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),E=new Zt(h.textureWidth,h.textureHeight,{format:zt,type:It,depthTexture:new Ri(h.textureWidth,h.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const re={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),E=new Zt(d.framebufferWidth,d.framebufferHeight,{format:zt,type:It,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Je.setContext(r),Je.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function O(j){for(let te=0;te<j.removed.length;te++){const re=j.removed[te],De=A.indexOf(re);De>=0&&(A[De]=null,R[De].disconnect(re))}for(let te=0;te<j.added.length;te++){const re=j.added[te];let De=A.indexOf(re);if(De===-1){for(let we=0;we<R.length;we++)if(we>=A.length){A.push(re),De=we;break}else if(A[we]===null){A[we]=re,De=we;break}if(De===-1)break}const Ae=R[De];Ae&&Ae.connect(re)}}const J=new k,Z=new k;function le(j,te,re){J.setFromMatrixPosition(te.matrixWorld),Z.setFromMatrixPosition(re.matrixWorld);const De=J.distanceTo(Z),Ae=te.projectionMatrix.elements,we=re.projectionMatrix.elements,ot=Ae[14]/(Ae[10]-1),Ve=Ae[14]/(Ae[10]+1),Ye=(Ae[9]+1)/Ae[5],je=(Ae[9]-1)/Ae[5],Ie=(Ae[8]-1)/Ae[0],st=(we[8]+1)/we[0],P=ot*Ie,at=ot*st,Ce=De/(-Ie+st),Ne=Ce*-Ie;if(te.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ne),j.translateZ(Ce),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Ae[10]===-1)j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{const ge=ot+Ce,T=Ve+Ce,_=P-Ne,I=at+(De-Ne),Y=Ye*Ve/T*ge,K=je*Ve/T*ge;j.projectionMatrix.makePerspective(_,I,Y,K,ge,T),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function de(j,te){te===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(te.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;let te=j.near,re=j.far;m.texture!==null&&(m.depthNear>0&&(te=m.depthNear),m.depthFar>0&&(re=m.depthFar)),F.near=G.near=y.near=te,F.far=G.far=y.far=re,(N!==F.near||L!==F.far)&&(r.updateRenderState({depthNear:F.near,depthFar:F.far}),N=F.near,L=F.far),F.layers.mask=j.layers.mask|6,y.layers.mask=F.layers.mask&-5,G.layers.mask=F.layers.mask&-3;const De=j.parent,Ae=F.cameras;de(F,De);for(let we=0;we<Ae.length;we++)de(Ae[we],De);Ae.length===2?le(F,y,G):F.projectionMatrix.copy(y.projectionMatrix),ue(j,F,De)};function ue(j,te,re){re===null?j.matrix.copy(te.matrixWorld):(j.matrix.copy(re.matrixWorld),j.matrix.invert(),j.matrix.multiply(te.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Zs*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(h===null&&d===null))return l},this.setFoveation=function(j){l=j,h!==null&&(h.fixedFoveation=j),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=j)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(F)},this.getCameraTexture=function(j){return f[j]};let Pe=null;function nt(j,te){if(u=te.getViewerPose(c||a),g=te,u!==null){const re=u.views;d!==null&&(e.setRenderTargetFramebuffer(E,d.framebuffer),e.setRenderTarget(E));let De=!1;re.length!==F.cameras.length&&(F.cameras.length=0,De=!0);for(let Ve=0;Ve<re.length;Ve++){const Ye=re[Ve];let je=null;if(d!==null)je=d.getViewport(Ye);else{const st=p.getViewSubImage(h,Ye);je=st.viewport,Ve===0&&(e.setRenderTargetTextures(E,st.colorTexture,st.depthStencilTexture),e.setRenderTarget(E))}let Ie=w[Ve];Ie===void 0&&(Ie=new Bt,Ie.layers.enable(Ve),Ie.viewport=new ct,w[Ve]=Ie),Ie.matrix.fromArray(Ye.transform.matrix),Ie.matrix.decompose(Ie.position,Ie.quaternion,Ie.scale),Ie.projectionMatrix.fromArray(Ye.projectionMatrix),Ie.projectionMatrixInverse.copy(Ie.projectionMatrix).invert(),Ie.viewport.set(je.x,je.y,je.width,je.height),Ve===0&&(F.matrix.copy(Ie.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),De===!0&&F.cameras.push(Ie)}const Ae=r.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&v){p=i.getBinding();const Ve=p.getDepthInformation(re[0]);Ve&&Ve.isValid&&Ve.texture&&m.init(Ve,r.renderState)}if(Ae&&Ae.includes("camera-access")&&v){e.state.unbindTexture(),p=i.getBinding();for(let Ve=0;Ve<re.length;Ve++){const Ye=re[Ve].camera;if(Ye){let je=f[Ye];je||(je=new cl,f[Ye]=je);const Ie=p.getCameraImage(Ye);je.sourceTexture=Ie}}}}for(let re=0;re<R.length;re++){const De=A[re],Ae=R[re];De!==null&&Ae!==void 0&&Ae.update(De,te,c||a)}Pe&&Pe(j,te),te.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:te}),g=null}const Je=new dl;Je.setAnimationLoop(nt),this.setAnimationLoop=function(j){Pe=j},this.dispose=function(){}}}const Fn=new kn,Xp=new ft;function qp(n,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function i(m,f){f.color.getRGB(m.fogColor.value,hl(n)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,S,b,E){f.isMeshBasicMaterial?s(m,f):f.isMeshLambertMaterial?(s(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(m,f),p(m,f)):f.isMeshPhongMaterial?(s(m,f),u(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(m,f),h(m,f),f.isMeshPhysicalMaterial&&d(m,f,E)):f.isMeshMatcapMaterial?(s(m,f),g(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),v(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,S,b):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(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,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===At&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===At&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const S=e.get(f),b=S.envMap,E=S.envMapRotation;b&&(m.envMap.value=b,Fn.copy(E),Fn.x*=-1,Fn.y*=-1,Fn.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Fn.y*=-1,Fn.z*=-1),m.envMapRotation.value.setFromMatrix4(Xp.makeRotationFromEuler(Fn)),m.flipEnvMap.value=b.isCubeTexture&&b.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,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(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,t(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,S,b){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*S,m.scale.value=b*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(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,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function u(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function p(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function h(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function d(m,f,S){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,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===At&&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,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(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,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function v(m,f){const S=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Yp(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,b){const E=b.program;i.uniformBlockBinding(S,E)}function c(S,b){let E=r[S.id];E===void 0&&(g(S),E=u(S),r[S.id]=E,S.addEventListener("dispose",m));const R=b.program;i.updateUBOMapping(S,R);const A=e.render.frame;s[S.id]!==A&&(h(S),s[S.id]=A)}function u(S){const b=p();S.__bindingPointIndex=b;const E=n.createBuffer(),R=S.__size,A=S.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,R,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,b,E),E}function p(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return qe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){const b=r[S.id],E=S.uniforms,R=S.__cache;n.bindBuffer(n.UNIFORM_BUFFER,b);for(let A=0,C=E.length;A<C;A++){const x=Array.isArray(E[A])?E[A]:[E[A]];for(let y=0,G=x.length;y<G;y++){const w=x[y];if(d(w,A,y,R)===!0){const F=w.__offset,N=Array.isArray(w.value)?w.value:[w.value];let L=0;for(let B=0;B<N.length;B++){const H=N[B],O=v(H);typeof H=="number"||typeof H=="boolean"?(w.__data[0]=H,n.bufferSubData(n.UNIFORM_BUFFER,F+L,w.__data)):H.isMatrix3?(w.__data[0]=H.elements[0],w.__data[1]=H.elements[1],w.__data[2]=H.elements[2],w.__data[3]=0,w.__data[4]=H.elements[3],w.__data[5]=H.elements[4],w.__data[6]=H.elements[5],w.__data[7]=0,w.__data[8]=H.elements[6],w.__data[9]=H.elements[7],w.__data[10]=H.elements[8],w.__data[11]=0):(H.toArray(w.__data,L),L+=O.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,F,w.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function d(S,b,E,R){const A=S.value,C=b+"_"+E;if(R[C]===void 0)return typeof A=="number"||typeof A=="boolean"?R[C]=A:R[C]=A.clone(),!0;{const x=R[C];if(typeof A=="number"||typeof A=="boolean"){if(x!==A)return R[C]=A,!0}else if(x.equals(A)===!1)return x.copy(A),!0}return!1}function g(S){const b=S.uniforms;let E=0;const R=16;for(let C=0,x=b.length;C<x;C++){const y=Array.isArray(b[C])?b[C]:[b[C]];for(let G=0,w=y.length;G<w;G++){const F=y[G],N=Array.isArray(F.value)?F.value:[F.value];for(let L=0,B=N.length;L<B;L++){const H=N[L],O=v(H),J=E%R,Z=J%O.boundary,le=J+Z;E+=Z,le!==0&&R-le<O.storage&&(E+=R-le),F.__data=new Float32Array(O.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=E,E+=O.storage}}}const A=E%R;return A>0&&(E+=R-A),S.__size=E,S.__cache={},this}function v(S){const b={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(b.boundary=4,b.storage=4):S.isVector2?(b.boundary=8,b.storage=8):S.isVector3||S.isColor?(b.boundary=16,b.storage=12):S.isVector4?(b.boundary=16,b.storage=16):S.isMatrix3?(b.boundary=48,b.storage=48):S.isMatrix4?(b.boundary=64,b.storage=64):S.isTexture?Le("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Le("WebGLRenderer: Unsupported uniform value type.",S),b}function m(S){const b=S.target;b.removeEventListener("dispose",m);const E=a.indexOf(b.__bindingPointIndex);a.splice(E,1),n.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function f(){for(const S in r)n.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:l,update:c,dispose:f}}const jp=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Xt=null;function $p(){return Xt===null&&(Xt=new Hc(jp,16,16,hi,pn),Xt.name="DFG_LUT",Xt.minFilter=Et,Xt.magFilter=Et,Xt.wrapS=hn,Xt.wrapT=hn,Xt.generateMipmaps=!1,Xt.needsUpdate=!0),Xt}class Zp{constructor(e={}){const{canvas:t=xc(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:p=!1,reversedDepthBuffer:h=!1,outputBufferType:d=It}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=a;const v=d,m=new Set([oa,aa,sa]),f=new Set([It,Kt,Ai,wi,ia,ra]),S=new Uint32Array(4),b=new Int32Array(4);let E=null,R=null;const A=[],C=[];let x=null;this.domElement=t,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=$t,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let G=!1;this._outputColorSpace=Lt;let w=0,F=0,N=null,L=-1,B=null;const H=new ct,O=new ct;let J=null;const Z=new tt(0);let le=0,de=t.width,ue=t.height,Pe=1,nt=null,Je=null;const j=new ct(0,0,de,ue),te=new ct(0,0,de,ue);let re=!1;const De=new ol;let Ae=!1,we=!1;const ot=new ft,Ve=new k,Ye=new ct,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function st(){return N===null?Pe:1}let P=i;function at(M,U){return t.getContext(M,U)}try{const M={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:p};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ta}`),t.addEventListener("webglcontextlost",ve,!1),t.addEventListener("webglcontextrestored",Fe,!1),t.addEventListener("webglcontextcreationerror",rt,!1),P===null){const U="webgl2";if(P=at(U,M),P===null)throw at(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw qe("WebGLRenderer: "+M.message),M}let Ce,Ne,ge,T,_,I,Y,K,q,_e,se,Te,Re,Q,ne,xe,Me,fe,ze,D,ae,ie,me;function ee(){Ce=new Zf(P),Ce.init(),ae=new Gp(P,Ce),Ne=new Hf(P,Ce,e,ae),ge=new Bp(P,Ce),Ne.reversedDepthBuffer&&h&&ge.buffers.depth.setReversed(!0),T=new Qf(P),_=new bp,I=new zp(P,Ce,ge,_,Ne,ae,T),Y=new $f(y),K=new ih(P),ie=new Gf(P,K),q=new Kf(P,K,T,ie),_e=new td(P,q,K,ie,T),fe=new ed(P,Ne,I),ne=new kf(_),se=new yp(y,Y,Ce,Ne,ie,ne),Te=new qp(y,_),Re=new Ap,Q=new Lp(Ce),Me=new zf(y,Y,ge,_e,g,l),xe=new Op(y,_e,Ne),me=new Yp(P,T,Ne,ge),ze=new Vf(P,Ce,T),D=new Jf(P,Ce,T),T.programs=se.programs,y.capabilities=Ne,y.extensions=Ce,y.properties=_,y.renderLists=Re,y.shadowMap=xe,y.state=ge,y.info=T}ee(),v!==It&&(x=new id(v,t.width,t.height,r,s));const X=new Wp(y,P);this.xr=X,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const M=Ce.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=Ce.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return Pe},this.setPixelRatio=function(M){M!==void 0&&(Pe=M,this.setSize(de,ue,!1))},this.getSize=function(M){return M.set(de,ue)},this.setSize=function(M,U,W=!0){if(X.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}de=M,ue=U,t.width=Math.floor(M*Pe),t.height=Math.floor(U*Pe),W===!0&&(t.style.width=M+"px",t.style.height=U+"px"),x!==null&&x.setSize(t.width,t.height),this.setViewport(0,0,M,U)},this.getDrawingBufferSize=function(M){return M.set(de*Pe,ue*Pe).floor()},this.setDrawingBufferSize=function(M,U,W){de=M,ue=U,Pe=W,t.width=Math.floor(M*W),t.height=Math.floor(U*W),this.setViewport(0,0,M,U)},this.setEffects=function(M){if(v===It){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(M){for(let U=0;U<M.length;U++)if(M[U].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(M||[])},this.getCurrentViewport=function(M){return M.copy(H)},this.getViewport=function(M){return M.copy(j)},this.setViewport=function(M,U,W,V){M.isVector4?j.set(M.x,M.y,M.z,M.w):j.set(M,U,W,V),ge.viewport(H.copy(j).multiplyScalar(Pe).round())},this.getScissor=function(M){return M.copy(te)},this.setScissor=function(M,U,W,V){M.isVector4?te.set(M.x,M.y,M.z,M.w):te.set(M,U,W,V),ge.scissor(O.copy(te).multiplyScalar(Pe).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(M){ge.setScissorTest(re=M)},this.setOpaqueSort=function(M){nt=M},this.setTransparentSort=function(M){Je=M},this.getClearColor=function(M){return M.copy(Me.getClearColor())},this.setClearColor=function(){Me.setClearColor(...arguments)},this.getClearAlpha=function(){return Me.getClearAlpha()},this.setClearAlpha=function(){Me.setClearAlpha(...arguments)},this.clear=function(M=!0,U=!0,W=!0){let V=0;if(M){let z=!1;if(N!==null){const ce=N.texture.format;z=m.has(ce)}if(z){const ce=N.texture.type,pe=f.has(ce),he=Me.getClearColor(),Se=Me.getClearAlpha(),ye=he.r,Ue=he.g,Ge=he.b;pe?(S[0]=ye,S[1]=Ue,S[2]=Ge,S[3]=Se,P.clearBufferuiv(P.COLOR,0,S)):(b[0]=ye,b[1]=Ue,b[2]=Ge,b[3]=Se,P.clearBufferiv(P.COLOR,0,b))}else V|=P.COLOR_BUFFER_BIT}U&&(V|=P.DEPTH_BUFFER_BIT),W&&(V|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&P.clear(V)},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(){t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Fe,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Me.dispose(),Re.dispose(),Q.dispose(),_.dispose(),Y.dispose(),_e.dispose(),ie.dispose(),me.dispose(),se.dispose(),X.dispose(),X.removeEventListener("sessionstart",pa),X.removeEventListener("sessionend",ma),wn.stop()};function ve(M){M.preventDefault(),Pa("WebGLRenderer: Context Lost."),G=!0}function Fe(){Pa("WebGLRenderer: Context Restored."),G=!1;const M=T.autoReset,U=xe.enabled,W=xe.autoUpdate,V=xe.needsUpdate,z=xe.type;ee(),T.autoReset=M,xe.enabled=U,xe.autoUpdate=W,xe.needsUpdate=V,xe.type=z}function rt(M){qe("WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function Ze(M){const U=M.target;U.removeEventListener("dispose",Ze),tn(U)}function tn(M){nn(M),_.remove(M)}function nn(M){const U=_.get(M).programs;U!==void 0&&(U.forEach(function(W){se.releaseProgram(W)}),M.isShaderMaterial&&se.releaseShaderCache(M))}this.renderBufferDirect=function(M,U,W,V,z,ce){U===null&&(U=je);const pe=z.isMesh&&z.matrixWorld.determinant()<0,he=bl(M,U,W,V,z);ge.setMaterial(V,pe);let Se=W.index,ye=1;if(V.wireframe===!0){if(Se=q.getWireframeAttribute(W),Se===void 0)return;ye=2}const Ue=W.drawRange,Ge=W.attributes.position;let be=Ue.start*ye,Qe=(Ue.start+Ue.count)*ye;ce!==null&&(be=Math.max(be,ce.start*ye),Qe=Math.min(Qe,(ce.start+ce.count)*ye)),Se!==null?(be=Math.max(be,0),Qe=Math.min(Qe,Se.count)):Ge!=null&&(be=Math.max(be,0),Qe=Math.min(Qe,Ge.count));const ht=Qe-be;if(ht<0||ht===1/0)return;ie.setup(z,V,he,W,Se);let lt,et=ze;if(Se!==null&&(lt=K.get(Se),et=D,et.setIndex(lt)),z.isMesh)V.wireframe===!0?(ge.setLineWidth(V.wireframeLinewidth*st()),et.setMode(P.LINES)):et.setMode(P.TRIANGLES);else if(z.isLine){let vt=V.linewidth;vt===void 0&&(vt=1),ge.setLineWidth(vt*st()),z.isLineSegments?et.setMode(P.LINES):z.isLineLoop?et.setMode(P.LINE_LOOP):et.setMode(P.LINE_STRIP)}else z.isPoints?et.setMode(P.POINTS):z.isSprite&&et.setMode(P.TRIANGLES);if(z.isBatchedMesh)if(z._multiDrawInstances!==null)fr("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),et.renderMultiDrawInstances(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount,z._multiDrawInstances);else if(Ce.get("WEBGL_multi_draw"))et.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const vt=z._multiDrawStarts,Ee=z._multiDrawCounts,wt=z._multiDrawCount,Xe=Se?K.get(Se).bytesPerElement:1,Ft=_.get(V).currentProgram.getUniforms();for(let Ht=0;Ht<wt;Ht++)Ft.setValue(P,"_gl_DrawID",Ht),et.render(vt[Ht]/Xe,Ee[Ht])}else if(z.isInstancedMesh)et.renderInstances(be,ht,z.count);else if(W.isInstancedBufferGeometry){const vt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,Ee=Math.min(W.instanceCount,vt);et.renderInstances(be,ht,Ee)}else et.render(be,ht)};function da(M,U,W){M.transparent===!0&&M.side===cn&&M.forceSinglePass===!1?(M.side=At,M.needsUpdate=!0,Ii(M,U,W),M.side=An,M.needsUpdate=!0,Ii(M,U,W),M.side=cn):Ii(M,U,W)}this.compile=function(M,U,W=null){W===null&&(W=M),R=Q.get(W),R.init(U),C.push(R),W.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(R.pushLight(z),z.castShadow&&R.pushShadow(z))}),M!==W&&M.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(R.pushLight(z),z.castShadow&&R.pushShadow(z))}),R.setupLights();const V=new Set;return M.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const ce=z.material;if(ce)if(Array.isArray(ce))for(let pe=0;pe<ce.length;pe++){const he=ce[pe];da(he,W,z),V.add(he)}else da(ce,W,z),V.add(ce)}),R=C.pop(),V},this.compileAsync=function(M,U,W=null){const V=this.compile(M,U,W);return new Promise(z=>{function ce(){if(V.forEach(function(pe){_.get(pe).currentProgram.isReady()&&V.delete(pe)}),V.size===0){z(M);return}setTimeout(ce,10)}Ce.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let vr=null;function yl(M){vr&&vr(M)}function pa(){wn.stop()}function ma(){wn.start()}const wn=new dl;wn.setAnimationLoop(yl),typeof self<"u"&&wn.setContext(self),this.setAnimationLoop=function(M){vr=M,X.setAnimationLoop(M),M===null?wn.stop():wn.start()},X.addEventListener("sessionstart",pa),X.addEventListener("sessionend",ma),this.render=function(M,U){if(U!==void 0&&U.isCamera!==!0){qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;const W=X.enabled===!0&&X.isPresenting===!0,V=x!==null&&(N===null||W)&&x.begin(y,N);if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),X.enabled===!0&&X.isPresenting===!0&&(x===null||x.isCompositing()===!1)&&(X.cameraAutoUpdate===!0&&X.updateCamera(U),U=X.getCamera()),M.isScene===!0&&M.onBeforeRender(y,M,U,N),R=Q.get(M,C.length),R.init(U),C.push(R),ot.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),De.setFromProjectionMatrix(ot,jt,U.reversedDepth),we=this.localClippingEnabled,Ae=ne.init(this.clippingPlanes,we),E=Re.get(M,A.length),E.init(),A.push(E),X.enabled===!0&&X.isPresenting===!0){const pe=y.xr.getDepthSensingMesh();pe!==null&&Mr(pe,U,-1/0,y.sortObjects)}Mr(M,U,0,y.sortObjects),E.finish(),y.sortObjects===!0&&E.sort(nt,Je),Ie=X.enabled===!1||X.isPresenting===!1||X.hasDepthSensing()===!1,Ie&&Me.addToRenderList(E,M),this.info.render.frame++,Ae===!0&&ne.beginShadows();const z=R.state.shadowsArray;if(xe.render(z,M,U),Ae===!0&&ne.endShadows(),this.info.autoReset===!0&&this.info.reset(),(V&&x.hasRenderPass())===!1){const pe=E.opaque,he=E.transmissive;if(R.setupLights(),U.isArrayCamera){const Se=U.cameras;if(he.length>0)for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye];_a(pe,he,M,Ge)}Ie&&Me.render(M);for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye];ga(E,M,Ge,Ge.viewport)}}else he.length>0&&_a(pe,he,M,U),Ie&&Me.render(M),ga(E,M,U)}N!==null&&F===0&&(I.updateMultisampleRenderTarget(N),I.updateRenderTargetMipmap(N)),V&&x.end(y),M.isScene===!0&&M.onAfterRender(y,M,U),ie.resetDefaultState(),L=-1,B=null,C.pop(),C.length>0?(R=C[C.length-1],Ae===!0&&ne.setGlobalState(y.clippingPlanes,R.state.camera)):R=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Mr(M,U,W,V){if(M.visible===!1)return;if(M.layers.test(U.layers)){if(M.isGroup)W=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(U);else if(M.isLight)R.pushLight(M),M.castShadow&&R.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||De.intersectsSprite(M)){V&&Ye.setFromMatrixPosition(M.matrixWorld).applyMatrix4(ot);const pe=_e.update(M),he=M.material;he.visible&&E.push(M,pe,he,W,Ye.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||De.intersectsObject(M))){const pe=_e.update(M),he=M.material;if(V&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Ye.copy(M.boundingSphere.center)):(pe.boundingSphere===null&&pe.computeBoundingSphere(),Ye.copy(pe.boundingSphere.center)),Ye.applyMatrix4(M.matrixWorld).applyMatrix4(ot)),Array.isArray(he)){const Se=pe.groups;for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye],be=he[Ge.materialIndex];be&&be.visible&&E.push(M,pe,be,W,Ye.z,Ge)}}else he.visible&&E.push(M,pe,he,W,Ye.z,null)}}const ce=M.children;for(let pe=0,he=ce.length;pe<he;pe++)Mr(ce[pe],U,W,V)}function ga(M,U,W,V){const{opaque:z,transmissive:ce,transparent:pe}=M;R.setupLightsView(W),Ae===!0&&ne.setGlobalState(y.clippingPlanes,W),V&&ge.viewport(H.copy(V)),z.length>0&&Li(z,U,W),ce.length>0&&Li(ce,U,W),pe.length>0&&Li(pe,U,W),ge.buffers.depth.setTest(!0),ge.buffers.depth.setMask(!0),ge.buffers.color.setMask(!0),ge.setPolygonOffset(!1)}function _a(M,U,W,V){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(R.state.transmissionRenderTarget[V.id]===void 0){const be=Ce.has("EXT_color_buffer_half_float")||Ce.has("EXT_color_buffer_float");R.state.transmissionRenderTarget[V.id]=new Zt(1,1,{generateMipmaps:!0,type:be?pn:It,minFilter:Bn,samples:Math.max(4,Ne.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:We.workingColorSpace})}const ce=R.state.transmissionRenderTarget[V.id],pe=V.viewport||H;ce.setSize(pe.z*y.transmissionResolutionScale,pe.w*y.transmissionResolutionScale);const he=y.getRenderTarget(),Se=y.getActiveCubeFace(),ye=y.getActiveMipmapLevel();y.setRenderTarget(ce),y.getClearColor(Z),le=y.getClearAlpha(),le<1&&y.setClearColor(16777215,.5),y.clear(),Ie&&Me.render(W);const Ue=y.toneMapping;y.toneMapping=$t;const Ge=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),R.setupLightsView(V),Ae===!0&&ne.setGlobalState(y.clippingPlanes,V),Li(M,W,V),I.updateMultisampleRenderTarget(ce),I.updateRenderTargetMipmap(ce),Ce.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Qe=0,ht=U.length;Qe<ht;Qe++){const lt=U[Qe],{object:et,geometry:vt,material:Ee,group:wt}=lt;if(Ee.side===cn&&et.layers.test(V.layers)){const Xe=Ee.side;Ee.side=At,Ee.needsUpdate=!0,xa(et,W,V,vt,Ee,wt),Ee.side=Xe,Ee.needsUpdate=!0,be=!0}}be===!0&&(I.updateMultisampleRenderTarget(ce),I.updateRenderTargetMipmap(ce))}y.setRenderTarget(he,Se,ye),y.setClearColor(Z,le),Ge!==void 0&&(V.viewport=Ge),y.toneMapping=Ue}function Li(M,U,W){const V=U.isScene===!0?U.overrideMaterial:null;for(let z=0,ce=M.length;z<ce;z++){const pe=M[z],{object:he,geometry:Se,group:ye}=pe;let Ue=pe.material;Ue.allowOverride===!0&&V!==null&&(Ue=V),he.layers.test(W.layers)&&xa(he,U,W,Se,Ue,ye)}}function xa(M,U,W,V,z,ce){M.onBeforeRender(y,U,W,V,z,ce),M.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),z.onBeforeRender(y,U,W,V,M,ce),z.transparent===!0&&z.side===cn&&z.forceSinglePass===!1?(z.side=At,z.needsUpdate=!0,y.renderBufferDirect(W,U,V,z,M,ce),z.side=An,z.needsUpdate=!0,y.renderBufferDirect(W,U,V,z,M,ce),z.side=cn):y.renderBufferDirect(W,U,V,z,M,ce),M.onAfterRender(y,U,W,V,z,ce)}function Ii(M,U,W){U.isScene!==!0&&(U=je);const V=_.get(M),z=R.state.lights,ce=R.state.shadowsArray,pe=z.state.version,he=se.getParameters(M,z.state,ce,U,W),Se=se.getProgramCacheKey(he);let ye=V.programs;V.environment=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?U.environment:null,V.fog=U.fog;const Ue=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap;V.envMap=Y.get(M.envMap||V.environment,Ue),V.envMapRotation=V.environment!==null&&M.envMap===null?U.environmentRotation:M.envMapRotation,ye===void 0&&(M.addEventListener("dispose",Ze),ye=new Map,V.programs=ye);let Ge=ye.get(Se);if(Ge!==void 0){if(V.currentProgram===Ge&&V.lightsStateVersion===pe)return Ma(M,he),Ge}else he.uniforms=se.getUniforms(M),M.onBeforeCompile(he,y),Ge=se.acquireProgram(he,Se),ye.set(Se,Ge),V.uniforms=he.uniforms;const be=V.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(be.clippingPlanes=ne.uniform),Ma(M,he),V.needsLights=Al(M),V.lightsStateVersion=pe,V.needsLights&&(be.ambientLightColor.value=z.state.ambient,be.lightProbe.value=z.state.probe,be.directionalLights.value=z.state.directional,be.directionalLightShadows.value=z.state.directionalShadow,be.spotLights.value=z.state.spot,be.spotLightShadows.value=z.state.spotShadow,be.rectAreaLights.value=z.state.rectArea,be.ltc_1.value=z.state.rectAreaLTC1,be.ltc_2.value=z.state.rectAreaLTC2,be.pointLights.value=z.state.point,be.pointLightShadows.value=z.state.pointShadow,be.hemisphereLights.value=z.state.hemi,be.directionalShadowMatrix.value=z.state.directionalShadowMatrix,be.spotLightMatrix.value=z.state.spotLightMatrix,be.spotLightMap.value=z.state.spotLightMap,be.pointShadowMatrix.value=z.state.pointShadowMatrix),V.currentProgram=Ge,V.uniformsList=null,Ge}function va(M){if(M.uniformsList===null){const U=M.currentProgram.getUniforms();M.uniformsList=lr.seqWithValue(U.seq,M.uniforms)}return M.uniformsList}function Ma(M,U){const W=_.get(M);W.outputColorSpace=U.outputColorSpace,W.batching=U.batching,W.batchingColor=U.batchingColor,W.instancing=U.instancing,W.instancingColor=U.instancingColor,W.instancingMorph=U.instancingMorph,W.skinning=U.skinning,W.morphTargets=U.morphTargets,W.morphNormals=U.morphNormals,W.morphColors=U.morphColors,W.morphTargetsCount=U.morphTargetsCount,W.numClippingPlanes=U.numClippingPlanes,W.numIntersection=U.numClipIntersection,W.vertexAlphas=U.vertexAlphas,W.vertexTangents=U.vertexTangents,W.toneMapping=U.toneMapping}function bl(M,U,W,V,z){U.isScene!==!0&&(U=je),I.resetTextureUnits();const ce=U.fog,pe=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?U.environment:null,he=N===null?y.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Hn,Se=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,ye=Y.get(V.envMap||pe,Se),Ue=V.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ge=!!W.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),be=!!W.morphAttributes.position,Qe=!!W.morphAttributes.normal,ht=!!W.morphAttributes.color;let lt=$t;V.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(lt=y.toneMapping);const et=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,vt=et!==void 0?et.length:0,Ee=_.get(V),wt=R.state.lights;if(Ae===!0&&(we===!0||M!==B)){const mt=M===B&&V.id===L;ne.setState(V,M,mt)}let Xe=!1;V.version===Ee.__version?(Ee.needsLights&&Ee.lightsStateVersion!==wt.state.version||Ee.outputColorSpace!==he||z.isBatchedMesh&&Ee.batching===!1||!z.isBatchedMesh&&Ee.batching===!0||z.isBatchedMesh&&Ee.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Ee.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Ee.instancing===!1||!z.isInstancedMesh&&Ee.instancing===!0||z.isSkinnedMesh&&Ee.skinning===!1||!z.isSkinnedMesh&&Ee.skinning===!0||z.isInstancedMesh&&Ee.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Ee.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Ee.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Ee.instancingMorph===!1&&z.morphTexture!==null||Ee.envMap!==ye||V.fog===!0&&Ee.fog!==ce||Ee.numClippingPlanes!==void 0&&(Ee.numClippingPlanes!==ne.numPlanes||Ee.numIntersection!==ne.numIntersection)||Ee.vertexAlphas!==Ue||Ee.vertexTangents!==Ge||Ee.morphTargets!==be||Ee.morphNormals!==Qe||Ee.morphColors!==ht||Ee.toneMapping!==lt||Ee.morphTargetsCount!==vt)&&(Xe=!0):(Xe=!0,Ee.__version=V.version);let Ft=Ee.currentProgram;Xe===!0&&(Ft=Ii(V,U,z));let Ht=!1,Rn=!1,Wn=!1;const it=Ft.getUniforms(),_t=Ee.uniforms;if(ge.useProgram(Ft.program)&&(Ht=!0,Rn=!0,Wn=!0),V.id!==L&&(L=V.id,Rn=!0),Ht||B!==M){ge.buffers.depth.getReversed()&&M.reversedDepth!==!0&&(M._reversedDepth=!0,M.updateProjectionMatrix()),it.setValue(P,"projectionMatrix",M.projectionMatrix),it.setValue(P,"viewMatrix",M.matrixWorldInverse);const _n=it.map.cameraPosition;_n!==void 0&&_n.setValue(P,Ve.setFromMatrixPosition(M.matrixWorld)),Ne.logarithmicDepthBuffer&&it.setValue(P,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&it.setValue(P,"isOrthographic",M.isOrthographicCamera===!0),B!==M&&(B=M,Rn=!0,Wn=!0)}if(Ee.needsLights&&(wt.state.directionalShadowMap.length>0&&it.setValue(P,"directionalShadowMap",wt.state.directionalShadowMap,I),wt.state.spotShadowMap.length>0&&it.setValue(P,"spotShadowMap",wt.state.spotShadowMap,I),wt.state.pointShadowMap.length>0&&it.setValue(P,"pointShadowMap",wt.state.pointShadowMap,I)),z.isSkinnedMesh){it.setOptional(P,z,"bindMatrix"),it.setOptional(P,z,"bindMatrixInverse");const mt=z.skeleton;mt&&(mt.boneTexture===null&&mt.computeBoneTexture(),it.setValue(P,"boneTexture",mt.boneTexture,I))}z.isBatchedMesh&&(it.setOptional(P,z,"batchingTexture"),it.setValue(P,"batchingTexture",z._matricesTexture,I),it.setOptional(P,z,"batchingIdTexture"),it.setValue(P,"batchingIdTexture",z._indirectTexture,I),it.setOptional(P,z,"batchingColorTexture"),z._colorsTexture!==null&&it.setValue(P,"batchingColorTexture",z._colorsTexture,I));const gn=W.morphAttributes;if((gn.position!==void 0||gn.normal!==void 0||gn.color!==void 0)&&fe.update(z,W,Ft),(Rn||Ee.receiveShadow!==z.receiveShadow)&&(Ee.receiveShadow=z.receiveShadow,it.setValue(P,"receiveShadow",z.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&U.environment!==null&&(_t.envMapIntensity.value=U.environmentIntensity),_t.dfgLUT!==void 0&&(_t.dfgLUT.value=$p()),Rn&&(it.setValue(P,"toneMappingExposure",y.toneMappingExposure),Ee.needsLights&&Tl(_t,Wn),ce&&V.fog===!0&&Te.refreshFogUniforms(_t,ce),Te.refreshMaterialUniforms(_t,V,Pe,ue,R.state.transmissionRenderTarget[M.id]),lr.upload(P,va(Ee),_t,I)),V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(lr.upload(P,va(Ee),_t,I),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&it.setValue(P,"center",z.center),it.setValue(P,"modelViewMatrix",z.modelViewMatrix),it.setValue(P,"normalMatrix",z.normalMatrix),it.setValue(P,"modelMatrix",z.matrixWorld),V.isShaderMaterial||V.isRawShaderMaterial){const mt=V.uniformsGroups;for(let _n=0,Xn=mt.length;_n<Xn;_n++){const Sa=mt[_n];me.update(Sa,Ft),me.bind(Sa,Ft)}}return Ft}function Tl(M,U){M.ambientLightColor.needsUpdate=U,M.lightProbe.needsUpdate=U,M.directionalLights.needsUpdate=U,M.directionalLightShadows.needsUpdate=U,M.pointLights.needsUpdate=U,M.pointLightShadows.needsUpdate=U,M.spotLights.needsUpdate=U,M.spotLightShadows.needsUpdate=U,M.rectAreaLights.needsUpdate=U,M.hemisphereLights.needsUpdate=U}function Al(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return F},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(M,U,W){const V=_.get(M);V.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),_.get(M.texture).__webglTexture=U,_.get(M.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:W,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,U){const W=_.get(M);W.__webglFramebuffer=U,W.__useDefaultFramebuffer=U===void 0};const wl=P.createFramebuffer();this.setRenderTarget=function(M,U=0,W=0){N=M,w=U,F=W;let V=null,z=!1,ce=!1;if(M){const he=_.get(M);if(he.__useDefaultFramebuffer!==void 0){ge.bindFramebuffer(P.FRAMEBUFFER,he.__webglFramebuffer),H.copy(M.viewport),O.copy(M.scissor),J=M.scissorTest,ge.viewport(H),ge.scissor(O),ge.setScissorTest(J),L=-1;return}else if(he.__webglFramebuffer===void 0)I.setupRenderTarget(M);else if(he.__hasExternalTextures)I.rebindTextures(M,_.get(M.texture).__webglTexture,_.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Ue=M.depthTexture;if(he.__boundDepthTexture!==Ue){if(Ue!==null&&_.has(Ue)&&(M.width!==Ue.image.width||M.height!==Ue.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");I.setupDepthRenderbuffer(M)}}const Se=M.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(ce=!0);const ye=_.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(ye[U])?V=ye[U][W]:V=ye[U],z=!0):M.samples>0&&I.useMultisampledRTT(M)===!1?V=_.get(M).__webglMultisampledFramebuffer:Array.isArray(ye)?V=ye[W]:V=ye,H.copy(M.viewport),O.copy(M.scissor),J=M.scissorTest}else H.copy(j).multiplyScalar(Pe).floor(),O.copy(te).multiplyScalar(Pe).floor(),J=re;if(W!==0&&(V=wl),ge.bindFramebuffer(P.FRAMEBUFFER,V)&&ge.drawBuffers(M,V),ge.viewport(H),ge.scissor(O),ge.setScissorTest(J),z){const he=_.get(M.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+U,he.__webglTexture,W)}else if(ce){const he=U;for(let Se=0;Se<M.textures.length;Se++){const ye=_.get(M.textures[Se]);P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0+Se,ye.__webglTexture,W,he)}}else if(M!==null&&W!==0){const he=_.get(M.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,he.__webglTexture,W)}L=-1},this.readRenderTargetPixels=function(M,U,W,V,z,ce,pe,he=0){if(!(M&&M.isWebGLRenderTarget)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se){ge.bindFramebuffer(P.FRAMEBUFFER,Se);try{const ye=M.textures[he],Ue=ye.format,Ge=ye.type;if(M.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+he),!Ne.textureFormatReadable(Ue)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ne.textureTypeReadable(Ge)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=M.width-V&&W>=0&&W<=M.height-z&&P.readPixels(U,W,V,z,ae.convert(Ue),ae.convert(Ge),ce)}finally{const ye=N!==null?_.get(N).__webglFramebuffer:null;ge.bindFramebuffer(P.FRAMEBUFFER,ye)}}},this.readRenderTargetPixelsAsync=async function(M,U,W,V,z,ce,pe,he=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se)if(U>=0&&U<=M.width-V&&W>=0&&W<=M.height-z){ge.bindFramebuffer(P.FRAMEBUFFER,Se);const ye=M.textures[he],Ue=ye.format,Ge=ye.type;if(M.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+he),!Ne.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ne.textureTypeReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,be),P.bufferData(P.PIXEL_PACK_BUFFER,ce.byteLength,P.STREAM_READ),P.readPixels(U,W,V,z,ae.convert(Ue),ae.convert(Ge),0);const Qe=N!==null?_.get(N).__webglFramebuffer:null;ge.bindFramebuffer(P.FRAMEBUFFER,Qe);const ht=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await vc(P,ht,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,be),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,ce),P.deleteBuffer(be),P.deleteSync(ht),ce}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,U=null,W=0){const V=Math.pow(2,-W),z=Math.floor(M.image.width*V),ce=Math.floor(M.image.height*V),pe=U!==null?U.x:0,he=U!==null?U.y:0;I.setTexture2D(M,0),P.copyTexSubImage2D(P.TEXTURE_2D,W,0,0,pe,he,z,ce),ge.unbindTexture()};const Rl=P.createFramebuffer(),Cl=P.createFramebuffer();this.copyTextureToTexture=function(M,U,W=null,V=null,z=0,ce=0){let pe,he,Se,ye,Ue,Ge,be,Qe,ht;const lt=M.isCompressedTexture?M.mipmaps[ce]:M.image;if(W!==null)pe=W.max.x-W.min.x,he=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,ye=W.min.x,Ue=W.min.y,Ge=W.isBox3?W.min.z:0;else{const _t=Math.pow(2,-z);pe=Math.floor(lt.width*_t),he=Math.floor(lt.height*_t),M.isDataArrayTexture?Se=lt.depth:M.isData3DTexture?Se=Math.floor(lt.depth*_t):Se=1,ye=0,Ue=0,Ge=0}V!==null?(be=V.x,Qe=V.y,ht=V.z):(be=0,Qe=0,ht=0);const et=ae.convert(U.format),vt=ae.convert(U.type);let Ee;U.isData3DTexture?(I.setTexture3D(U,0),Ee=P.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(I.setTexture2DArray(U,0),Ee=P.TEXTURE_2D_ARRAY):(I.setTexture2D(U,0),Ee=P.TEXTURE_2D),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);const wt=P.getParameter(P.UNPACK_ROW_LENGTH),Xe=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Ft=P.getParameter(P.UNPACK_SKIP_PIXELS),Ht=P.getParameter(P.UNPACK_SKIP_ROWS),Rn=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,lt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,lt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,ye),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ue),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Ge);const Wn=M.isDataArrayTexture||M.isData3DTexture,it=U.isDataArrayTexture||U.isData3DTexture;if(M.isDepthTexture){const _t=_.get(M),gn=_.get(U),mt=_.get(_t.__renderTarget),_n=_.get(gn.__renderTarget);ge.bindFramebuffer(P.READ_FRAMEBUFFER,mt.__webglFramebuffer),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,_n.__webglFramebuffer);for(let Xn=0;Xn<Se;Xn++)Wn&&(P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_.get(M).__webglTexture,z,Ge+Xn),P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_.get(U).__webglTexture,ce,ht+Xn)),P.blitFramebuffer(ye,Ue,pe,he,be,Qe,pe,he,P.DEPTH_BUFFER_BIT,P.NEAREST);ge.bindFramebuffer(P.READ_FRAMEBUFFER,null),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(z!==0||M.isRenderTargetTexture||_.has(M)){const _t=_.get(M),gn=_.get(U);ge.bindFramebuffer(P.READ_FRAMEBUFFER,Rl),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,Cl);for(let mt=0;mt<Se;mt++)Wn?P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_t.__webglTexture,z,Ge+mt):P.framebufferTexture2D(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,_t.__webglTexture,z),it?P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,gn.__webglTexture,ce,ht+mt):P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,gn.__webglTexture,ce),z!==0?P.blitFramebuffer(ye,Ue,pe,he,be,Qe,pe,he,P.COLOR_BUFFER_BIT,P.NEAREST):it?P.copyTexSubImage3D(Ee,ce,be,Qe,ht+mt,ye,Ue,pe,he):P.copyTexSubImage2D(Ee,ce,be,Qe,ye,Ue,pe,he);ge.bindFramebuffer(P.READ_FRAMEBUFFER,null),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else it?M.isDataTexture||M.isData3DTexture?P.texSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,vt,lt.data):U.isCompressedArrayTexture?P.compressedTexSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,lt.data):P.texSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,vt,lt):M.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,ce,be,Qe,pe,he,et,vt,lt.data):M.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,ce,be,Qe,lt.width,lt.height,et,lt.data):P.texSubImage2D(P.TEXTURE_2D,ce,be,Qe,pe,he,et,vt,lt);P.pixelStorei(P.UNPACK_ROW_LENGTH,wt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Xe),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ft),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ht),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Rn),ce===0&&U.generateMipmaps&&P.generateMipmap(Ee),ge.unbindTexture()},this.initRenderTarget=function(M){_.get(M).__webglFramebuffer===void 0&&I.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?I.setTextureCube(M,0):M.isData3DTexture?I.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?I.setTexture2DArray(M,0):I.setTexture2D(M,0),ge.unbindTexture()},this.resetState=function(){w=0,F=0,N=null,ge.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return jt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=We._getDrawingBufferColorSpace(e),t.unpackColorSpace=We._getUnpackColorSpace()}}const Kp=`
4049
+ }`;class Wp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new cl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Qt({vertexShader:Hp,fragmentShader:kp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jt(new _r(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xp extends fi{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,m=null,h=null,p=null,g=null;const v=typeof XRWebGLBinding<"u",d=new Wp,f={},S=t.getContextAttributes();let b=null,E=null;const R=[],A=[],C=new $e;let x=null;const y=new Bt;y.viewport=new ct;const G=new Bt;G.viewport=new ct;const w=[y,G],F=new th;let N=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getTargetRaySpace()},this.getControllerGrip=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getGripSpace()},this.getHand=function(j){let te=R[j];return te===void 0&&(te=new Ir,R[j]=te),te.getHandSpace()};function B(j){const te=A.indexOf(j.inputSource);if(te===-1)return;const re=R[te];re!==void 0&&(re.update(j.inputSource,j.frame,c||a),re.dispatchEvent({type:j.type,data:j.inputSource}))}function H(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",O);for(let j=0;j<R.length;j++){const te=A[j];te!==null&&(A[j]=null,R[j].disconnect(te))}N=null,L=null,d.reset();for(const j in f)delete f[j];e.setRenderTarget(b),p=null,h=null,m=null,r=null,E=null,Je.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,i.isPresenting===!0&&Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return h!==null?h:p},this.getBinding=function(){return m===null&&v&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(j){if(r=j,r!==null){if(b=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",H),r.addEventListener("inputsourceschange",O),S.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(C),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,De=null,Ae=null;S.depth&&(Ae=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=S.stencil?zn:mn,De=S.stencil?Ri:Kt);const we={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};m=this.getBinding(),h=m.createProjectionLayer(we),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),E=new Zt(h.textureWidth,h.textureHeight,{format:zt,type:It,depthTexture:new Ci(h.textureWidth,h.textureHeight,De,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const re={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),E=new Zt(p.framebufferWidth,p.framebufferHeight,{format:zt,type:It,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Je.setContext(r),Je.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return d.getDepthTexture()};function O(j){for(let te=0;te<j.removed.length;te++){const re=j.removed[te],De=A.indexOf(re);De>=0&&(A[De]=null,R[De].disconnect(re))}for(let te=0;te<j.added.length;te++){const re=j.added[te];let De=A.indexOf(re);if(De===-1){for(let we=0;we<R.length;we++)if(we>=A.length){A.push(re),De=we;break}else if(A[we]===null){A[we]=re,De=we;break}if(De===-1)break}const Ae=R[De];Ae&&Ae.connect(re)}}const J=new k,Z=new k;function le(j,te,re){J.setFromMatrixPosition(te.matrixWorld),Z.setFromMatrixPosition(re.matrixWorld);const De=J.distanceTo(Z),Ae=te.projectionMatrix.elements,we=re.projectionMatrix.elements,ot=Ae[14]/(Ae[10]-1),Ve=Ae[14]/(Ae[10]+1),Ye=(Ae[9]+1)/Ae[5],je=(Ae[9]-1)/Ae[5],Ie=(Ae[8]-1)/Ae[0],st=(we[8]+1)/we[0],P=ot*Ie,at=ot*st,Ce=De/(-Ie+st),Ne=Ce*-Ie;if(te.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ne),j.translateZ(Ce),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Ae[10]===-1)j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{const ge=ot+Ce,T=Ve+Ce,_=P-Ne,I=at+(De-Ne),Y=Ye*Ve/T*ge,K=je*Ve/T*ge;j.projectionMatrix.makePerspective(_,I,Y,K,ge,T),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function de(j,te){te===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(te.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;let te=j.near,re=j.far;d.texture!==null&&(d.depthNear>0&&(te=d.depthNear),d.depthFar>0&&(re=d.depthFar)),F.near=G.near=y.near=te,F.far=G.far=y.far=re,(N!==F.near||L!==F.far)&&(r.updateRenderState({depthNear:F.near,depthFar:F.far}),N=F.near,L=F.far),F.layers.mask=j.layers.mask|6,y.layers.mask=F.layers.mask&-5,G.layers.mask=F.layers.mask&-3;const De=j.parent,Ae=F.cameras;de(F,De);for(let we=0;we<Ae.length;we++)de(Ae[we],De);Ae.length===2?le(F,y,G):F.projectionMatrix.copy(y.projectionMatrix),ue(j,F,De)};function ue(j,te,re){re===null?j.matrix.copy(te.matrixWorld):(j.matrix.copy(re.matrixWorld),j.matrix.invert(),j.matrix.multiply(te.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=$s*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(h===null&&p===null))return l},this.setFoveation=function(j){l=j,h!==null&&(h.fixedFoveation=j),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=j)},this.hasDepthSensing=function(){return d.texture!==null},this.getDepthSensingMesh=function(){return d.getMesh(F)},this.getCameraTexture=function(j){return f[j]};let Pe=null;function nt(j,te){if(u=te.getViewerPose(c||a),g=te,u!==null){const re=u.views;p!==null&&(e.setRenderTargetFramebuffer(E,p.framebuffer),e.setRenderTarget(E));let De=!1;re.length!==F.cameras.length&&(F.cameras.length=0,De=!0);for(let Ve=0;Ve<re.length;Ve++){const Ye=re[Ve];let je=null;if(p!==null)je=p.getViewport(Ye);else{const st=m.getViewSubImage(h,Ye);je=st.viewport,Ve===0&&(e.setRenderTargetTextures(E,st.colorTexture,st.depthStencilTexture),e.setRenderTarget(E))}let Ie=w[Ve];Ie===void 0&&(Ie=new Bt,Ie.layers.enable(Ve),Ie.viewport=new ct,w[Ve]=Ie),Ie.matrix.fromArray(Ye.transform.matrix),Ie.matrix.decompose(Ie.position,Ie.quaternion,Ie.scale),Ie.projectionMatrix.fromArray(Ye.projectionMatrix),Ie.projectionMatrixInverse.copy(Ie.projectionMatrix).invert(),Ie.viewport.set(je.x,je.y,je.width,je.height),Ve===0&&(F.matrix.copy(Ie.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),De===!0&&F.cameras.push(Ie)}const Ae=r.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&v){m=i.getBinding();const Ve=m.getDepthInformation(re[0]);Ve&&Ve.isValid&&Ve.texture&&d.init(Ve,r.renderState)}if(Ae&&Ae.includes("camera-access")&&v){e.state.unbindTexture(),m=i.getBinding();for(let Ve=0;Ve<re.length;Ve++){const Ye=re[Ve].camera;if(Ye){let je=f[Ye];je||(je=new cl,f[Ye]=je);const Ie=m.getCameraImage(Ye);je.sourceTexture=Ie}}}}for(let re=0;re<R.length;re++){const De=A[re],Ae=R[re];De!==null&&Ae!==void 0&&Ae.update(De,te,c||a)}Pe&&Pe(j,te),te.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:te}),g=null}const Je=new dl;Je.setAnimationLoop(nt),this.setAnimationLoop=function(j){Pe=j},this.dispose=function(){}}}const Fn=new kn,qp=new ft;function Yp(n,e){function t(d,f){d.matrixAutoUpdate===!0&&d.updateMatrix(),f.value.copy(d.matrix)}function i(d,f){f.color.getRGB(d.fogColor.value,hl(n)),f.isFog?(d.fogNear.value=f.near,d.fogFar.value=f.far):f.isFogExp2&&(d.fogDensity.value=f.density)}function r(d,f,S,b,E){f.isMeshBasicMaterial?s(d,f):f.isMeshLambertMaterial?(s(d,f),f.envMap&&(d.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(d,f),m(d,f)):f.isMeshPhongMaterial?(s(d,f),u(d,f),f.envMap&&(d.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(d,f),h(d,f),f.isMeshPhysicalMaterial&&p(d,f,E)):f.isMeshMatcapMaterial?(s(d,f),g(d,f)):f.isMeshDepthMaterial?s(d,f):f.isMeshDistanceMaterial?(s(d,f),v(d,f)):f.isMeshNormalMaterial?s(d,f):f.isLineBasicMaterial?(a(d,f),f.isLineDashedMaterial&&o(d,f)):f.isPointsMaterial?l(d,f,S,b):f.isSpriteMaterial?c(d,f):f.isShadowMaterial?(d.color.value.copy(f.color),d.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(d,f){d.opacity.value=f.opacity,f.color&&d.diffuse.value.copy(f.color),f.emissive&&d.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(d.map.value=f.map,t(f.map,d.mapTransform)),f.alphaMap&&(d.alphaMap.value=f.alphaMap,t(f.alphaMap,d.alphaMapTransform)),f.bumpMap&&(d.bumpMap.value=f.bumpMap,t(f.bumpMap,d.bumpMapTransform),d.bumpScale.value=f.bumpScale,f.side===At&&(d.bumpScale.value*=-1)),f.normalMap&&(d.normalMap.value=f.normalMap,t(f.normalMap,d.normalMapTransform),d.normalScale.value.copy(f.normalScale),f.side===At&&d.normalScale.value.negate()),f.displacementMap&&(d.displacementMap.value=f.displacementMap,t(f.displacementMap,d.displacementMapTransform),d.displacementScale.value=f.displacementScale,d.displacementBias.value=f.displacementBias),f.emissiveMap&&(d.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,d.emissiveMapTransform)),f.specularMap&&(d.specularMap.value=f.specularMap,t(f.specularMap,d.specularMapTransform)),f.alphaTest>0&&(d.alphaTest.value=f.alphaTest);const S=e.get(f),b=S.envMap,E=S.envMapRotation;b&&(d.envMap.value=b,Fn.copy(E),Fn.x*=-1,Fn.y*=-1,Fn.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Fn.y*=-1,Fn.z*=-1),d.envMapRotation.value.setFromMatrix4(qp.makeRotationFromEuler(Fn)),d.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=f.reflectivity,d.ior.value=f.ior,d.refractionRatio.value=f.refractionRatio),f.lightMap&&(d.lightMap.value=f.lightMap,d.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,d.lightMapTransform)),f.aoMap&&(d.aoMap.value=f.aoMap,d.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,d.aoMapTransform))}function a(d,f){d.diffuse.value.copy(f.color),d.opacity.value=f.opacity,f.map&&(d.map.value=f.map,t(f.map,d.mapTransform))}function o(d,f){d.dashSize.value=f.dashSize,d.totalSize.value=f.dashSize+f.gapSize,d.scale.value=f.scale}function l(d,f,S,b){d.diffuse.value.copy(f.color),d.opacity.value=f.opacity,d.size.value=f.size*S,d.scale.value=b*.5,f.map&&(d.map.value=f.map,t(f.map,d.uvTransform)),f.alphaMap&&(d.alphaMap.value=f.alphaMap,t(f.alphaMap,d.alphaMapTransform)),f.alphaTest>0&&(d.alphaTest.value=f.alphaTest)}function c(d,f){d.diffuse.value.copy(f.color),d.opacity.value=f.opacity,d.rotation.value=f.rotation,f.map&&(d.map.value=f.map,t(f.map,d.mapTransform)),f.alphaMap&&(d.alphaMap.value=f.alphaMap,t(f.alphaMap,d.alphaMapTransform)),f.alphaTest>0&&(d.alphaTest.value=f.alphaTest)}function u(d,f){d.specular.value.copy(f.specular),d.shininess.value=Math.max(f.shininess,1e-4)}function m(d,f){f.gradientMap&&(d.gradientMap.value=f.gradientMap)}function h(d,f){d.metalness.value=f.metalness,f.metalnessMap&&(d.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,d.metalnessMapTransform)),d.roughness.value=f.roughness,f.roughnessMap&&(d.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,d.roughnessMapTransform)),f.envMap&&(d.envMapIntensity.value=f.envMapIntensity)}function p(d,f,S){d.ior.value=f.ior,f.sheen>0&&(d.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),d.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(d.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,d.sheenColorMapTransform)),f.sheenRoughnessMap&&(d.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,d.sheenRoughnessMapTransform))),f.clearcoat>0&&(d.clearcoat.value=f.clearcoat,d.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(d.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,d.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(d.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===At&&d.clearcoatNormalScale.value.negate())),f.dispersion>0&&(d.dispersion.value=f.dispersion),f.iridescence>0&&(d.iridescence.value=f.iridescence,d.iridescenceIOR.value=f.iridescenceIOR,d.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(d.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,d.iridescenceMapTransform)),f.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),f.transmission>0&&(d.transmission.value=f.transmission,d.transmissionSamplerMap.value=S.texture,d.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(d.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,d.transmissionMapTransform)),d.thickness.value=f.thickness,f.thicknessMap&&(d.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=f.attenuationDistance,d.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(d.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(d.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=f.specularIntensity,d.specularColor.value.copy(f.specularColor),f.specularColorMap&&(d.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,d.specularColorMapTransform)),f.specularIntensityMap&&(d.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,d.specularIntensityMapTransform))}function g(d,f){f.matcap&&(d.matcap.value=f.matcap)}function v(d,f){const S=e.get(f).light;d.referencePosition.value.setFromMatrixPosition(S.matrixWorld),d.nearDistance.value=S.shadow.camera.near,d.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function jp(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,b){const E=b.program;i.uniformBlockBinding(S,E)}function c(S,b){let E=r[S.id];E===void 0&&(g(S),E=u(S),r[S.id]=E,S.addEventListener("dispose",d));const R=b.program;i.updateUBOMapping(S,R);const A=e.render.frame;s[S.id]!==A&&(h(S),s[S.id]=A)}function u(S){const b=m();S.__bindingPointIndex=b;const E=n.createBuffer(),R=S.__size,A=S.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,R,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,b,E),E}function m(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return qe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){const b=r[S.id],E=S.uniforms,R=S.__cache;n.bindBuffer(n.UNIFORM_BUFFER,b);for(let A=0,C=E.length;A<C;A++){const x=Array.isArray(E[A])?E[A]:[E[A]];for(let y=0,G=x.length;y<G;y++){const w=x[y];if(p(w,A,y,R)===!0){const F=w.__offset,N=Array.isArray(w.value)?w.value:[w.value];let L=0;for(let B=0;B<N.length;B++){const H=N[B],O=v(H);typeof H=="number"||typeof H=="boolean"?(w.__data[0]=H,n.bufferSubData(n.UNIFORM_BUFFER,F+L,w.__data)):H.isMatrix3?(w.__data[0]=H.elements[0],w.__data[1]=H.elements[1],w.__data[2]=H.elements[2],w.__data[3]=0,w.__data[4]=H.elements[3],w.__data[5]=H.elements[4],w.__data[6]=H.elements[5],w.__data[7]=0,w.__data[8]=H.elements[6],w.__data[9]=H.elements[7],w.__data[10]=H.elements[8],w.__data[11]=0):(H.toArray(w.__data,L),L+=O.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,F,w.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(S,b,E,R){const A=S.value,C=b+"_"+E;if(R[C]===void 0)return typeof A=="number"||typeof A=="boolean"?R[C]=A:R[C]=A.clone(),!0;{const x=R[C];if(typeof A=="number"||typeof A=="boolean"){if(x!==A)return R[C]=A,!0}else if(x.equals(A)===!1)return x.copy(A),!0}return!1}function g(S){const b=S.uniforms;let E=0;const R=16;for(let C=0,x=b.length;C<x;C++){const y=Array.isArray(b[C])?b[C]:[b[C]];for(let G=0,w=y.length;G<w;G++){const F=y[G],N=Array.isArray(F.value)?F.value:[F.value];for(let L=0,B=N.length;L<B;L++){const H=N[L],O=v(H),J=E%R,Z=J%O.boundary,le=J+Z;E+=Z,le!==0&&R-le<O.storage&&(E+=R-le),F.__data=new Float32Array(O.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=E,E+=O.storage}}}const A=E%R;return A>0&&(E+=R-A),S.__size=E,S.__cache={},this}function v(S){const b={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(b.boundary=4,b.storage=4):S.isVector2?(b.boundary=8,b.storage=8):S.isVector3||S.isColor?(b.boundary=16,b.storage=12):S.isVector4?(b.boundary=16,b.storage=16):S.isMatrix3?(b.boundary=48,b.storage=48):S.isMatrix4?(b.boundary=64,b.storage=64):S.isTexture?Le("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Le("WebGLRenderer: Unsupported uniform value type.",S),b}function d(S){const b=S.target;b.removeEventListener("dispose",d);const E=a.indexOf(b.__bindingPointIndex);a.splice(E,1),n.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function f(){for(const S in r)n.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:l,update:c,dispose:f}}const $p=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Xt=null;function Zp(){return Xt===null&&(Xt=new kc($p,16,16,hi,pn),Xt.name="DFG_LUT",Xt.minFilter=Et,Xt.magFilter=Et,Xt.wrapS=hn,Xt.wrapT=hn,Xt.generateMipmaps=!1,Xt.needsUpdate=!0),Xt}class Kp{constructor(e={}){const{canvas:t=vc(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:p=It}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=a;const v=p,d=new Set([aa,sa,ra]),f=new Set([It,Kt,wi,Ri,na,ia]),S=new Uint32Array(4),b=new Int32Array(4);let E=null,R=null;const A=[],C=[];let x=null;this.domElement=t,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=$t,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const y=this;let G=!1;this._outputColorSpace=Lt;let w=0,F=0,N=null,L=-1,B=null;const H=new ct,O=new ct;let J=null;const Z=new tt(0);let le=0,de=t.width,ue=t.height,Pe=1,nt=null,Je=null;const j=new ct(0,0,de,ue),te=new ct(0,0,de,ue);let re=!1;const De=new ol;let Ae=!1,we=!1;const ot=new ft,Ve=new k,Ye=new ct,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function st(){return N===null?Pe:1}let P=i;function at(M,U){return t.getContext(M,U)}try{const M={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ea}`),t.addEventListener("webglcontextlost",ve,!1),t.addEventListener("webglcontextrestored",Fe,!1),t.addEventListener("webglcontextcreationerror",rt,!1),P===null){const U="webgl2";if(P=at(U,M),P===null)throw at(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw qe("WebGLRenderer: "+M.message),M}let Ce,Ne,ge,T,_,I,Y,K,q,_e,se,Te,Re,Q,ne,xe,Me,fe,ze,D,ae,ie,me;function ee(){Ce=new Kf(P),Ce.init(),ae=new Vp(P,Ce),Ne=new kf(P,Ce,e,ae),ge=new zp(P,Ce),Ne.reversedDepthBuffer&&h&&ge.buffers.depth.setReversed(!0),T=new ed(P),_=new Tp,I=new Gp(P,Ce,ge,_,Ne,ae,T),Y=new Zf(y),K=new rh(P),ie=new Vf(P,K),q=new Jf(P,K,T,ie),_e=new nd(P,q,K,ie,T),fe=new td(P,Ne,I),ne=new Wf(_),se=new bp(y,Y,Ce,Ne,ie,ne),Te=new Yp(y,_),Re=new wp,Q=new Ip(Ce),Me=new Gf(y,Y,ge,_e,g,l),xe=new Bp(y,_e,Ne),me=new jp(P,T,Ne,ge),ze=new Hf(P,Ce,T),D=new Qf(P,Ce,T),T.programs=se.programs,y.capabilities=Ne,y.extensions=Ce,y.properties=_,y.renderLists=Re,y.shadowMap=xe,y.state=ge,y.info=T}ee(),v!==It&&(x=new rd(v,t.width,t.height,r,s));const X=new Xp(y,P);this.xr=X,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const M=Ce.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=Ce.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return Pe},this.setPixelRatio=function(M){M!==void 0&&(Pe=M,this.setSize(de,ue,!1))},this.getSize=function(M){return M.set(de,ue)},this.setSize=function(M,U,W=!0){if(X.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}de=M,ue=U,t.width=Math.floor(M*Pe),t.height=Math.floor(U*Pe),W===!0&&(t.style.width=M+"px",t.style.height=U+"px"),x!==null&&x.setSize(t.width,t.height),this.setViewport(0,0,M,U)},this.getDrawingBufferSize=function(M){return M.set(de*Pe,ue*Pe).floor()},this.setDrawingBufferSize=function(M,U,W){de=M,ue=U,Pe=W,t.width=Math.floor(M*W),t.height=Math.floor(U*W),this.setViewport(0,0,M,U)},this.setEffects=function(M){if(v===It){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(M){for(let U=0;U<M.length;U++)if(M[U].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(M||[])},this.getCurrentViewport=function(M){return M.copy(H)},this.getViewport=function(M){return M.copy(j)},this.setViewport=function(M,U,W,V){M.isVector4?j.set(M.x,M.y,M.z,M.w):j.set(M,U,W,V),ge.viewport(H.copy(j).multiplyScalar(Pe).round())},this.getScissor=function(M){return M.copy(te)},this.setScissor=function(M,U,W,V){M.isVector4?te.set(M.x,M.y,M.z,M.w):te.set(M,U,W,V),ge.scissor(O.copy(te).multiplyScalar(Pe).round())},this.getScissorTest=function(){return re},this.setScissorTest=function(M){ge.setScissorTest(re=M)},this.setOpaqueSort=function(M){nt=M},this.setTransparentSort=function(M){Je=M},this.getClearColor=function(M){return M.copy(Me.getClearColor())},this.setClearColor=function(){Me.setClearColor(...arguments)},this.getClearAlpha=function(){return Me.getClearAlpha()},this.setClearAlpha=function(){Me.setClearAlpha(...arguments)},this.clear=function(M=!0,U=!0,W=!0){let V=0;if(M){let z=!1;if(N!==null){const ce=N.texture.format;z=d.has(ce)}if(z){const ce=N.texture.type,pe=f.has(ce),he=Me.getClearColor(),Se=Me.getClearAlpha(),ye=he.r,Ue=he.g,Ge=he.b;pe?(S[0]=ye,S[1]=Ue,S[2]=Ge,S[3]=Se,P.clearBufferuiv(P.COLOR,0,S)):(b[0]=ye,b[1]=Ue,b[2]=Ge,b[3]=Se,P.clearBufferiv(P.COLOR,0,b))}else V|=P.COLOR_BUFFER_BIT}U&&(V|=P.DEPTH_BUFFER_BIT),W&&(V|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&P.clear(V)},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(){t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Fe,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Me.dispose(),Re.dispose(),Q.dispose(),_.dispose(),Y.dispose(),_e.dispose(),ie.dispose(),me.dispose(),se.dispose(),X.dispose(),X.removeEventListener("sessionstart",da),X.removeEventListener("sessionend",pa),wn.stop()};function ve(M){M.preventDefault(),Pa("WebGLRenderer: Context Lost."),G=!0}function Fe(){Pa("WebGLRenderer: Context Restored."),G=!1;const M=T.autoReset,U=xe.enabled,W=xe.autoUpdate,V=xe.needsUpdate,z=xe.type;ee(),T.autoReset=M,xe.enabled=U,xe.autoUpdate=W,xe.needsUpdate=V,xe.type=z}function rt(M){qe("WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function Ze(M){const U=M.target;U.removeEventListener("dispose",Ze),tn(U)}function tn(M){nn(M),_.remove(M)}function nn(M){const U=_.get(M).programs;U!==void 0&&(U.forEach(function(W){se.releaseProgram(W)}),M.isShaderMaterial&&se.releaseShaderCache(M))}this.renderBufferDirect=function(M,U,W,V,z,ce){U===null&&(U=je);const pe=z.isMesh&&z.matrixWorld.determinant()<0,he=bl(M,U,W,V,z);ge.setMaterial(V,pe);let Se=W.index,ye=1;if(V.wireframe===!0){if(Se=q.getWireframeAttribute(W),Se===void 0)return;ye=2}const Ue=W.drawRange,Ge=W.attributes.position;let be=Ue.start*ye,Qe=(Ue.start+Ue.count)*ye;ce!==null&&(be=Math.max(be,ce.start*ye),Qe=Math.min(Qe,(ce.start+ce.count)*ye)),Se!==null?(be=Math.max(be,0),Qe=Math.min(Qe,Se.count)):Ge!=null&&(be=Math.max(be,0),Qe=Math.min(Qe,Ge.count));const ht=Qe-be;if(ht<0||ht===1/0)return;ie.setup(z,V,he,W,Se);let lt,et=ze;if(Se!==null&&(lt=K.get(Se),et=D,et.setIndex(lt)),z.isMesh)V.wireframe===!0?(ge.setLineWidth(V.wireframeLinewidth*st()),et.setMode(P.LINES)):et.setMode(P.TRIANGLES);else if(z.isLine){let vt=V.linewidth;vt===void 0&&(vt=1),ge.setLineWidth(vt*st()),z.isLineSegments?et.setMode(P.LINES):z.isLineLoop?et.setMode(P.LINE_LOOP):et.setMode(P.LINE_STRIP)}else z.isPoints?et.setMode(P.POINTS):z.isSprite&&et.setMode(P.TRIANGLES);if(z.isBatchedMesh)if(z._multiDrawInstances!==null)dr("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),et.renderMultiDrawInstances(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount,z._multiDrawInstances);else if(Ce.get("WEBGL_multi_draw"))et.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const vt=z._multiDrawStarts,Ee=z._multiDrawCounts,wt=z._multiDrawCount,Xe=Se?K.get(Se).bytesPerElement:1,Ft=_.get(V).currentProgram.getUniforms();for(let Ht=0;Ht<wt;Ht++)Ft.setValue(P,"_gl_DrawID",Ht),et.render(vt[Ht]/Xe,Ee[Ht])}else if(z.isInstancedMesh)et.renderInstances(be,ht,z.count);else if(W.isInstancedBufferGeometry){const vt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,Ee=Math.min(W.instanceCount,vt);et.renderInstances(be,ht,Ee)}else et.render(be,ht)};function fa(M,U,W){M.transparent===!0&&M.side===cn&&M.forceSinglePass===!1?(M.side=At,M.needsUpdate=!0,Fi(M,U,W),M.side=An,M.needsUpdate=!0,Fi(M,U,W),M.side=cn):Fi(M,U,W)}this.compile=function(M,U,W=null){W===null&&(W=M),R=Q.get(W),R.init(U),C.push(R),W.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(R.pushLight(z),z.castShadow&&R.pushShadow(z))}),M!==W&&M.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(R.pushLight(z),z.castShadow&&R.pushShadow(z))}),R.setupLights();const V=new Set;return M.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const ce=z.material;if(ce)if(Array.isArray(ce))for(let pe=0;pe<ce.length;pe++){const he=ce[pe];fa(he,W,z),V.add(he)}else fa(ce,W,z),V.add(ce)}),R=C.pop(),V},this.compileAsync=function(M,U,W=null){const V=this.compile(M,U,W);return new Promise(z=>{function ce(){if(V.forEach(function(pe){_.get(pe).currentProgram.isReady()&&V.delete(pe)}),V.size===0){z(M);return}setTimeout(ce,10)}Ce.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let Mr=null;function yl(M){Mr&&Mr(M)}function da(){wn.stop()}function pa(){wn.start()}const wn=new dl;wn.setAnimationLoop(yl),typeof self<"u"&&wn.setContext(self),this.setAnimationLoop=function(M){Mr=M,X.setAnimationLoop(M),M===null?wn.stop():wn.start()},X.addEventListener("sessionstart",da),X.addEventListener("sessionend",pa),this.render=function(M,U){if(U!==void 0&&U.isCamera!==!0){qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;const W=X.enabled===!0&&X.isPresenting===!0,V=x!==null&&(N===null||W)&&x.begin(y,N);if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),X.enabled===!0&&X.isPresenting===!0&&(x===null||x.isCompositing()===!1)&&(X.cameraAutoUpdate===!0&&X.updateCamera(U),U=X.getCamera()),M.isScene===!0&&M.onBeforeRender(y,M,U,N),R=Q.get(M,C.length),R.init(U),C.push(R),ot.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),De.setFromProjectionMatrix(ot,jt,U.reversedDepth),we=this.localClippingEnabled,Ae=ne.init(this.clippingPlanes,we),E=Re.get(M,A.length),E.init(),A.push(E),X.enabled===!0&&X.isPresenting===!0){const pe=y.xr.getDepthSensingMesh();pe!==null&&Sr(pe,U,-1/0,y.sortObjects)}Sr(M,U,0,y.sortObjects),E.finish(),y.sortObjects===!0&&E.sort(nt,Je),Ie=X.enabled===!1||X.isPresenting===!1||X.hasDepthSensing()===!1,Ie&&Me.addToRenderList(E,M),this.info.render.frame++,Ae===!0&&ne.beginShadows();const z=R.state.shadowsArray;if(xe.render(z,M,U),Ae===!0&&ne.endShadows(),this.info.autoReset===!0&&this.info.reset(),(V&&x.hasRenderPass())===!1){const pe=E.opaque,he=E.transmissive;if(R.setupLights(),U.isArrayCamera){const Se=U.cameras;if(he.length>0)for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye];ga(pe,he,M,Ge)}Ie&&Me.render(M);for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye];ma(E,M,Ge,Ge.viewport)}}else he.length>0&&ga(pe,he,M,U),Ie&&Me.render(M),ma(E,M,U)}N!==null&&F===0&&(I.updateMultisampleRenderTarget(N),I.updateRenderTargetMipmap(N)),V&&x.end(y),M.isScene===!0&&M.onAfterRender(y,M,U),ie.resetDefaultState(),L=-1,B=null,C.pop(),C.length>0?(R=C[C.length-1],Ae===!0&&ne.setGlobalState(y.clippingPlanes,R.state.camera)):R=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Sr(M,U,W,V){if(M.visible===!1)return;if(M.layers.test(U.layers)){if(M.isGroup)W=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(U);else if(M.isLight)R.pushLight(M),M.castShadow&&R.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||De.intersectsSprite(M)){V&&Ye.setFromMatrixPosition(M.matrixWorld).applyMatrix4(ot);const pe=_e.update(M),he=M.material;he.visible&&E.push(M,pe,he,W,Ye.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||De.intersectsObject(M))){const pe=_e.update(M),he=M.material;if(V&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Ye.copy(M.boundingSphere.center)):(pe.boundingSphere===null&&pe.computeBoundingSphere(),Ye.copy(pe.boundingSphere.center)),Ye.applyMatrix4(M.matrixWorld).applyMatrix4(ot)),Array.isArray(he)){const Se=pe.groups;for(let ye=0,Ue=Se.length;ye<Ue;ye++){const Ge=Se[ye],be=he[Ge.materialIndex];be&&be.visible&&E.push(M,pe,be,W,Ye.z,Ge)}}else he.visible&&E.push(M,pe,he,W,Ye.z,null)}}const ce=M.children;for(let pe=0,he=ce.length;pe<he;pe++)Sr(ce[pe],U,W,V)}function ma(M,U,W,V){const{opaque:z,transmissive:ce,transparent:pe}=M;R.setupLightsView(W),Ae===!0&&ne.setGlobalState(y.clippingPlanes,W),V&&ge.viewport(H.copy(V)),z.length>0&&Ii(z,U,W),ce.length>0&&Ii(ce,U,W),pe.length>0&&Ii(pe,U,W),ge.buffers.depth.setTest(!0),ge.buffers.depth.setMask(!0),ge.buffers.color.setMask(!0),ge.setPolygonOffset(!1)}function ga(M,U,W,V){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(R.state.transmissionRenderTarget[V.id]===void 0){const be=Ce.has("EXT_color_buffer_half_float")||Ce.has("EXT_color_buffer_float");R.state.transmissionRenderTarget[V.id]=new Zt(1,1,{generateMipmaps:!0,type:be?pn:It,minFilter:Bn,samples:Math.max(4,Ne.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:We.workingColorSpace})}const ce=R.state.transmissionRenderTarget[V.id],pe=V.viewport||H;ce.setSize(pe.z*y.transmissionResolutionScale,pe.w*y.transmissionResolutionScale);const he=y.getRenderTarget(),Se=y.getActiveCubeFace(),ye=y.getActiveMipmapLevel();y.setRenderTarget(ce),y.getClearColor(Z),le=y.getClearAlpha(),le<1&&y.setClearColor(16777215,.5),y.clear(),Ie&&Me.render(W);const Ue=y.toneMapping;y.toneMapping=$t;const Ge=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),R.setupLightsView(V),Ae===!0&&ne.setGlobalState(y.clippingPlanes,V),Ii(M,W,V),I.updateMultisampleRenderTarget(ce),I.updateRenderTargetMipmap(ce),Ce.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Qe=0,ht=U.length;Qe<ht;Qe++){const lt=U[Qe],{object:et,geometry:vt,material:Ee,group:wt}=lt;if(Ee.side===cn&&et.layers.test(V.layers)){const Xe=Ee.side;Ee.side=At,Ee.needsUpdate=!0,_a(et,W,V,vt,Ee,wt),Ee.side=Xe,Ee.needsUpdate=!0,be=!0}}be===!0&&(I.updateMultisampleRenderTarget(ce),I.updateRenderTargetMipmap(ce))}y.setRenderTarget(he,Se,ye),y.setClearColor(Z,le),Ge!==void 0&&(V.viewport=Ge),y.toneMapping=Ue}function Ii(M,U,W){const V=U.isScene===!0?U.overrideMaterial:null;for(let z=0,ce=M.length;z<ce;z++){const pe=M[z],{object:he,geometry:Se,group:ye}=pe;let Ue=pe.material;Ue.allowOverride===!0&&V!==null&&(Ue=V),he.layers.test(W.layers)&&_a(he,U,W,Se,Ue,ye)}}function _a(M,U,W,V,z,ce){M.onBeforeRender(y,U,W,V,z,ce),M.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),z.onBeforeRender(y,U,W,V,M,ce),z.transparent===!0&&z.side===cn&&z.forceSinglePass===!1?(z.side=At,z.needsUpdate=!0,y.renderBufferDirect(W,U,V,z,M,ce),z.side=An,z.needsUpdate=!0,y.renderBufferDirect(W,U,V,z,M,ce),z.side=cn):y.renderBufferDirect(W,U,V,z,M,ce),M.onAfterRender(y,U,W,V,z,ce)}function Fi(M,U,W){U.isScene!==!0&&(U=je);const V=_.get(M),z=R.state.lights,ce=R.state.shadowsArray,pe=z.state.version,he=se.getParameters(M,z.state,ce,U,W),Se=se.getProgramCacheKey(he);let ye=V.programs;V.environment=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?U.environment:null,V.fog=U.fog;const Ue=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap;V.envMap=Y.get(M.envMap||V.environment,Ue),V.envMapRotation=V.environment!==null&&M.envMap===null?U.environmentRotation:M.envMapRotation,ye===void 0&&(M.addEventListener("dispose",Ze),ye=new Map,V.programs=ye);let Ge=ye.get(Se);if(Ge!==void 0){if(V.currentProgram===Ge&&V.lightsStateVersion===pe)return va(M,he),Ge}else he.uniforms=se.getUniforms(M),M.onBeforeCompile(he,y),Ge=se.acquireProgram(he,Se),ye.set(Se,Ge),V.uniforms=he.uniforms;const be=V.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(be.clippingPlanes=ne.uniform),va(M,he),V.needsLights=Al(M),V.lightsStateVersion=pe,V.needsLights&&(be.ambientLightColor.value=z.state.ambient,be.lightProbe.value=z.state.probe,be.directionalLights.value=z.state.directional,be.directionalLightShadows.value=z.state.directionalShadow,be.spotLights.value=z.state.spot,be.spotLightShadows.value=z.state.spotShadow,be.rectAreaLights.value=z.state.rectArea,be.ltc_1.value=z.state.rectAreaLTC1,be.ltc_2.value=z.state.rectAreaLTC2,be.pointLights.value=z.state.point,be.pointLightShadows.value=z.state.pointShadow,be.hemisphereLights.value=z.state.hemi,be.directionalShadowMatrix.value=z.state.directionalShadowMatrix,be.spotLightMatrix.value=z.state.spotLightMatrix,be.spotLightMap.value=z.state.spotLightMap,be.pointShadowMatrix.value=z.state.pointShadowMatrix),V.currentProgram=Ge,V.uniformsList=null,Ge}function xa(M){if(M.uniformsList===null){const U=M.currentProgram.getUniforms();M.uniformsList=cr.seqWithValue(U.seq,M.uniforms)}return M.uniformsList}function va(M,U){const W=_.get(M);W.outputColorSpace=U.outputColorSpace,W.batching=U.batching,W.batchingColor=U.batchingColor,W.instancing=U.instancing,W.instancingColor=U.instancingColor,W.instancingMorph=U.instancingMorph,W.skinning=U.skinning,W.morphTargets=U.morphTargets,W.morphNormals=U.morphNormals,W.morphColors=U.morphColors,W.morphTargetsCount=U.morphTargetsCount,W.numClippingPlanes=U.numClippingPlanes,W.numIntersection=U.numClipIntersection,W.vertexAlphas=U.vertexAlphas,W.vertexTangents=U.vertexTangents,W.toneMapping=U.toneMapping}function bl(M,U,W,V,z){U.isScene!==!0&&(U=je),I.resetTextureUnits();const ce=U.fog,pe=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?U.environment:null,he=N===null?y.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Hn,Se=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,ye=Y.get(V.envMap||pe,Se),Ue=V.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ge=!!W.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),be=!!W.morphAttributes.position,Qe=!!W.morphAttributes.normal,ht=!!W.morphAttributes.color;let lt=$t;V.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(lt=y.toneMapping);const et=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,vt=et!==void 0?et.length:0,Ee=_.get(V),wt=R.state.lights;if(Ae===!0&&(we===!0||M!==B)){const mt=M===B&&V.id===L;ne.setState(V,M,mt)}let Xe=!1;V.version===Ee.__version?(Ee.needsLights&&Ee.lightsStateVersion!==wt.state.version||Ee.outputColorSpace!==he||z.isBatchedMesh&&Ee.batching===!1||!z.isBatchedMesh&&Ee.batching===!0||z.isBatchedMesh&&Ee.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Ee.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Ee.instancing===!1||!z.isInstancedMesh&&Ee.instancing===!0||z.isSkinnedMesh&&Ee.skinning===!1||!z.isSkinnedMesh&&Ee.skinning===!0||z.isInstancedMesh&&Ee.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Ee.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Ee.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Ee.instancingMorph===!1&&z.morphTexture!==null||Ee.envMap!==ye||V.fog===!0&&Ee.fog!==ce||Ee.numClippingPlanes!==void 0&&(Ee.numClippingPlanes!==ne.numPlanes||Ee.numIntersection!==ne.numIntersection)||Ee.vertexAlphas!==Ue||Ee.vertexTangents!==Ge||Ee.morphTargets!==be||Ee.morphNormals!==Qe||Ee.morphColors!==ht||Ee.toneMapping!==lt||Ee.morphTargetsCount!==vt)&&(Xe=!0):(Xe=!0,Ee.__version=V.version);let Ft=Ee.currentProgram;Xe===!0&&(Ft=Fi(V,U,z));let Ht=!1,Rn=!1,Wn=!1;const it=Ft.getUniforms(),_t=Ee.uniforms;if(ge.useProgram(Ft.program)&&(Ht=!0,Rn=!0,Wn=!0),V.id!==L&&(L=V.id,Rn=!0),Ht||B!==M){ge.buffers.depth.getReversed()&&M.reversedDepth!==!0&&(M._reversedDepth=!0,M.updateProjectionMatrix()),it.setValue(P,"projectionMatrix",M.projectionMatrix),it.setValue(P,"viewMatrix",M.matrixWorldInverse);const _n=it.map.cameraPosition;_n!==void 0&&_n.setValue(P,Ve.setFromMatrixPosition(M.matrixWorld)),Ne.logarithmicDepthBuffer&&it.setValue(P,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&it.setValue(P,"isOrthographic",M.isOrthographicCamera===!0),B!==M&&(B=M,Rn=!0,Wn=!0)}if(Ee.needsLights&&(wt.state.directionalShadowMap.length>0&&it.setValue(P,"directionalShadowMap",wt.state.directionalShadowMap,I),wt.state.spotShadowMap.length>0&&it.setValue(P,"spotShadowMap",wt.state.spotShadowMap,I),wt.state.pointShadowMap.length>0&&it.setValue(P,"pointShadowMap",wt.state.pointShadowMap,I)),z.isSkinnedMesh){it.setOptional(P,z,"bindMatrix"),it.setOptional(P,z,"bindMatrixInverse");const mt=z.skeleton;mt&&(mt.boneTexture===null&&mt.computeBoneTexture(),it.setValue(P,"boneTexture",mt.boneTexture,I))}z.isBatchedMesh&&(it.setOptional(P,z,"batchingTexture"),it.setValue(P,"batchingTexture",z._matricesTexture,I),it.setOptional(P,z,"batchingIdTexture"),it.setValue(P,"batchingIdTexture",z._indirectTexture,I),it.setOptional(P,z,"batchingColorTexture"),z._colorsTexture!==null&&it.setValue(P,"batchingColorTexture",z._colorsTexture,I));const gn=W.morphAttributes;if((gn.position!==void 0||gn.normal!==void 0||gn.color!==void 0)&&fe.update(z,W,Ft),(Rn||Ee.receiveShadow!==z.receiveShadow)&&(Ee.receiveShadow=z.receiveShadow,it.setValue(P,"receiveShadow",z.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&U.environment!==null&&(_t.envMapIntensity.value=U.environmentIntensity),_t.dfgLUT!==void 0&&(_t.dfgLUT.value=Zp()),Rn&&(it.setValue(P,"toneMappingExposure",y.toneMappingExposure),Ee.needsLights&&Tl(_t,Wn),ce&&V.fog===!0&&Te.refreshFogUniforms(_t,ce),Te.refreshMaterialUniforms(_t,V,Pe,ue,R.state.transmissionRenderTarget[M.id]),cr.upload(P,xa(Ee),_t,I)),V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(cr.upload(P,xa(Ee),_t,I),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&it.setValue(P,"center",z.center),it.setValue(P,"modelViewMatrix",z.modelViewMatrix),it.setValue(P,"normalMatrix",z.normalMatrix),it.setValue(P,"modelMatrix",z.matrixWorld),V.isShaderMaterial||V.isRawShaderMaterial){const mt=V.uniformsGroups;for(let _n=0,Xn=mt.length;_n<Xn;_n++){const Ma=mt[_n];me.update(Ma,Ft),me.bind(Ma,Ft)}}return Ft}function Tl(M,U){M.ambientLightColor.needsUpdate=U,M.lightProbe.needsUpdate=U,M.directionalLights.needsUpdate=U,M.directionalLightShadows.needsUpdate=U,M.pointLights.needsUpdate=U,M.pointLightShadows.needsUpdate=U,M.spotLights.needsUpdate=U,M.spotLightShadows.needsUpdate=U,M.rectAreaLights.needsUpdate=U,M.hemisphereLights.needsUpdate=U}function Al(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return F},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(M,U,W){const V=_.get(M);V.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),_.get(M.texture).__webglTexture=U,_.get(M.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:W,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,U){const W=_.get(M);W.__webglFramebuffer=U,W.__useDefaultFramebuffer=U===void 0};const wl=P.createFramebuffer();this.setRenderTarget=function(M,U=0,W=0){N=M,w=U,F=W;let V=null,z=!1,ce=!1;if(M){const he=_.get(M);if(he.__useDefaultFramebuffer!==void 0){ge.bindFramebuffer(P.FRAMEBUFFER,he.__webglFramebuffer),H.copy(M.viewport),O.copy(M.scissor),J=M.scissorTest,ge.viewport(H),ge.scissor(O),ge.setScissorTest(J),L=-1;return}else if(he.__webglFramebuffer===void 0)I.setupRenderTarget(M);else if(he.__hasExternalTextures)I.rebindTextures(M,_.get(M.texture).__webglTexture,_.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Ue=M.depthTexture;if(he.__boundDepthTexture!==Ue){if(Ue!==null&&_.has(Ue)&&(M.width!==Ue.image.width||M.height!==Ue.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");I.setupDepthRenderbuffer(M)}}const Se=M.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(ce=!0);const ye=_.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(ye[U])?V=ye[U][W]:V=ye[U],z=!0):M.samples>0&&I.useMultisampledRTT(M)===!1?V=_.get(M).__webglMultisampledFramebuffer:Array.isArray(ye)?V=ye[W]:V=ye,H.copy(M.viewport),O.copy(M.scissor),J=M.scissorTest}else H.copy(j).multiplyScalar(Pe).floor(),O.copy(te).multiplyScalar(Pe).floor(),J=re;if(W!==0&&(V=wl),ge.bindFramebuffer(P.FRAMEBUFFER,V)&&ge.drawBuffers(M,V),ge.viewport(H),ge.scissor(O),ge.setScissorTest(J),z){const he=_.get(M.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+U,he.__webglTexture,W)}else if(ce){const he=U;for(let Se=0;Se<M.textures.length;Se++){const ye=_.get(M.textures[Se]);P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0+Se,ye.__webglTexture,W,he)}}else if(M!==null&&W!==0){const he=_.get(M.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,he.__webglTexture,W)}L=-1},this.readRenderTargetPixels=function(M,U,W,V,z,ce,pe,he=0){if(!(M&&M.isWebGLRenderTarget)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se){ge.bindFramebuffer(P.FRAMEBUFFER,Se);try{const ye=M.textures[he],Ue=ye.format,Ge=ye.type;if(M.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+he),!Ne.textureFormatReadable(Ue)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ne.textureTypeReadable(Ge)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=M.width-V&&W>=0&&W<=M.height-z&&P.readPixels(U,W,V,z,ae.convert(Ue),ae.convert(Ge),ce)}finally{const ye=N!==null?_.get(N).__webglFramebuffer:null;ge.bindFramebuffer(P.FRAMEBUFFER,ye)}}},this.readRenderTargetPixelsAsync=async function(M,U,W,V,z,ce,pe,he=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=_.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&pe!==void 0&&(Se=Se[pe]),Se)if(U>=0&&U<=M.width-V&&W>=0&&W<=M.height-z){ge.bindFramebuffer(P.FRAMEBUFFER,Se);const ye=M.textures[he],Ue=ye.format,Ge=ye.type;if(M.textures.length>1&&P.readBuffer(P.COLOR_ATTACHMENT0+he),!Ne.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ne.textureTypeReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,be),P.bufferData(P.PIXEL_PACK_BUFFER,ce.byteLength,P.STREAM_READ),P.readPixels(U,W,V,z,ae.convert(Ue),ae.convert(Ge),0);const Qe=N!==null?_.get(N).__webglFramebuffer:null;ge.bindFramebuffer(P.FRAMEBUFFER,Qe);const ht=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await Mc(P,ht,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,be),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,ce),P.deleteBuffer(be),P.deleteSync(ht),ce}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,U=null,W=0){const V=Math.pow(2,-W),z=Math.floor(M.image.width*V),ce=Math.floor(M.image.height*V),pe=U!==null?U.x:0,he=U!==null?U.y:0;I.setTexture2D(M,0),P.copyTexSubImage2D(P.TEXTURE_2D,W,0,0,pe,he,z,ce),ge.unbindTexture()};const Rl=P.createFramebuffer(),Cl=P.createFramebuffer();this.copyTextureToTexture=function(M,U,W=null,V=null,z=0,ce=0){let pe,he,Se,ye,Ue,Ge,be,Qe,ht;const lt=M.isCompressedTexture?M.mipmaps[ce]:M.image;if(W!==null)pe=W.max.x-W.min.x,he=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,ye=W.min.x,Ue=W.min.y,Ge=W.isBox3?W.min.z:0;else{const _t=Math.pow(2,-z);pe=Math.floor(lt.width*_t),he=Math.floor(lt.height*_t),M.isDataArrayTexture?Se=lt.depth:M.isData3DTexture?Se=Math.floor(lt.depth*_t):Se=1,ye=0,Ue=0,Ge=0}V!==null?(be=V.x,Qe=V.y,ht=V.z):(be=0,Qe=0,ht=0);const et=ae.convert(U.format),vt=ae.convert(U.type);let Ee;U.isData3DTexture?(I.setTexture3D(U,0),Ee=P.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(I.setTexture2DArray(U,0),Ee=P.TEXTURE_2D_ARRAY):(I.setTexture2D(U,0),Ee=P.TEXTURE_2D),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,U.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,U.unpackAlignment);const wt=P.getParameter(P.UNPACK_ROW_LENGTH),Xe=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Ft=P.getParameter(P.UNPACK_SKIP_PIXELS),Ht=P.getParameter(P.UNPACK_SKIP_ROWS),Rn=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,lt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,lt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,ye),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ue),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Ge);const Wn=M.isDataArrayTexture||M.isData3DTexture,it=U.isDataArrayTexture||U.isData3DTexture;if(M.isDepthTexture){const _t=_.get(M),gn=_.get(U),mt=_.get(_t.__renderTarget),_n=_.get(gn.__renderTarget);ge.bindFramebuffer(P.READ_FRAMEBUFFER,mt.__webglFramebuffer),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,_n.__webglFramebuffer);for(let Xn=0;Xn<Se;Xn++)Wn&&(P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_.get(M).__webglTexture,z,Ge+Xn),P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_.get(U).__webglTexture,ce,ht+Xn)),P.blitFramebuffer(ye,Ue,pe,he,be,Qe,pe,he,P.DEPTH_BUFFER_BIT,P.NEAREST);ge.bindFramebuffer(P.READ_FRAMEBUFFER,null),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else if(z!==0||M.isRenderTargetTexture||_.has(M)){const _t=_.get(M),gn=_.get(U);ge.bindFramebuffer(P.READ_FRAMEBUFFER,Rl),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,Cl);for(let mt=0;mt<Se;mt++)Wn?P.framebufferTextureLayer(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,_t.__webglTexture,z,Ge+mt):P.framebufferTexture2D(P.READ_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,_t.__webglTexture,z),it?P.framebufferTextureLayer(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,gn.__webglTexture,ce,ht+mt):P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_2D,gn.__webglTexture,ce),z!==0?P.blitFramebuffer(ye,Ue,pe,he,be,Qe,pe,he,P.COLOR_BUFFER_BIT,P.NEAREST):it?P.copyTexSubImage3D(Ee,ce,be,Qe,ht+mt,ye,Ue,pe,he):P.copyTexSubImage2D(Ee,ce,be,Qe,ye,Ue,pe,he);ge.bindFramebuffer(P.READ_FRAMEBUFFER,null),ge.bindFramebuffer(P.DRAW_FRAMEBUFFER,null)}else it?M.isDataTexture||M.isData3DTexture?P.texSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,vt,lt.data):U.isCompressedArrayTexture?P.compressedTexSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,lt.data):P.texSubImage3D(Ee,ce,be,Qe,ht,pe,he,Se,et,vt,lt):M.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,ce,be,Qe,pe,he,et,vt,lt.data):M.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,ce,be,Qe,lt.width,lt.height,et,lt.data):P.texSubImage2D(P.TEXTURE_2D,ce,be,Qe,pe,he,et,vt,lt);P.pixelStorei(P.UNPACK_ROW_LENGTH,wt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Xe),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ft),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ht),P.pixelStorei(P.UNPACK_SKIP_IMAGES,Rn),ce===0&&U.generateMipmaps&&P.generateMipmap(Ee),ge.unbindTexture()},this.initRenderTarget=function(M){_.get(M).__webglFramebuffer===void 0&&I.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?I.setTextureCube(M,0):M.isData3DTexture?I.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?I.setTexture2DArray(M,0):I.setTexture2D(M,0),ge.unbindTexture()},this.resetState=function(){w=0,F=0,N=null,ge.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return jt}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=We._getDrawingBufferColorSpace(e),t.unpackColorSpace=We._getUnpackColorSpace()}}const Jp=`
4050
4050
  precision highp float;
4051
4051
  attribute vec3 position;
4052
4052
  void main(){
4053
4053
  gl_Position = vec4(position, 1.0);
4054
4054
  }
4055
- `,Jp=`
4055
+ `,Qp=`
4056
4056
  #ifdef GL_ES
4057
4057
  #extension GL_OES_standard_derivatives : enable
4058
4058
  #endif
@@ -4249,19 +4249,19 @@ void main(){
4249
4249
  // straight (non-premultiplied) alpha output
4250
4250
  gl_FragColor=vec4(col,alpha);
4251
4251
  }
4252
- `;function xo(n){let e=n.trim().replace("#","");e.length===3&&(e=e.split("").map(i=>i+i).join(""));const t=parseInt(e,16)||16777215;return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(t&255)/255}}function Qp({className:n,style:e,wispDensity:t=1,dpr:i,mouseSmoothTime:r=.06,mouseTiltStrength:s=.01,horizontalBeamOffset:a=0,verticalBeamOffset:o=-.5,flowSpeed:l=.35,verticalSizing:c=2,horizontalSizing:u=.5,fogIntensity:p=.45,fogScale:h=.3,wispSpeed:d=15,wispIntensity:g=5,flowStrength:v=.25,decay:m=1.1,falloffStart:f=1.2,fogFallSpeed:S=.6,color:b="#8a7aff"}){const E=He.useRef(null),R=He.useRef(null),A=He.useRef(!1),C=He.useRef(null),x=He.useRef(!0),y=He.useRef(!1),G=He.useRef(r);return He.useEffect(()=>{G.current=r},[r]),He.useEffect(()=>{const w=E.current;let F;try{F=new Zp({antialias:!1,alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,powerPreference:"high-performance"})}catch(Ce){console.warn("LaserFlow: WebGL not supported or context creation failed.",Ce);return}let L=Math.min(i??(window.devicePixelRatio||1),2);F.setPixelRatio(L),F.outputColorSpace=Hn,F.setClearColor(0,0);const B=F.domElement;B.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;",w.appendChild(B);const H=new Uc,O=new fa(-1,1,1,-1,0,1),J=new en;J.setAttribute("position",new Vt(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));const Z={iTime:{value:0},iResolution:{value:new k(1,1,1)},iMouse:{value:new ct(0,0,0,0)},uWispDensity:{value:t},uTiltScale:{value:s},uFlowTime:{value:0},uFogTime:{value:0},uBeamXFrac:{value:a},uBeamYFrac:{value:o},uFlowSpeed:{value:l},uVLenFactor:{value:c},uHLenFactor:{value:u},uFogIntensity:{value:p},uFogScale:{value:h},uWSpeed:{value:d},uWIntensity:{value:g},uFlowStrength:{value:v},uDecay:{value:m},uFalloffStart:{value:f},uFogFallSpeed:{value:S},uColor:{value:new k(1,1,1)},uFade:{value:A.current?1:0}};R.current=Z;const{r:le,g:de,b:ue}=xo(b);Z.uColor.value.set(le,de,ue);const Pe=new ul({vertexShader:Kp,fragmentShader:Jp,uniforms:Z,transparent:!0,depthTest:!1,depthWrite:!1,blending:Gn}),nt=new Jt(J,Pe);nt.frustumCulled=!1,H.add(nt);let Je=0,j=0,te=0;function re(){const Ce=w.clientWidth||1,Ne=w.clientHeight||1;Math.abs(Ce-Je)<1&&Math.abs(Ne-j)<1&&Math.abs(L-te)<.01||(Je=Ce,j=Ne,te=L,F.setPixelRatio(L),F.setSize(Ce,Ne,!1),Z.iResolution.value.set(Ce*L,Ne*L,L),C.current=B.getBoundingClientRect())}let De=0;const Ae=new ResizeObserver(()=>{cancelAnimationFrame(De),De=requestAnimationFrame(re)});Ae.observe(w),re();const we=new IntersectionObserver(Ce=>{x.current=Ce[0]?.isIntersecting??!0},{threshold:0});we.observe(w),document.addEventListener("visibilitychange",()=>{y.current=document.hidden},{passive:!0});const ot=new $e(0,0),Ve=new $e(0,0);function Ye(Ce){const Ne=C.current;Ne&&ot.set((Ce.clientX-Ne.left)*L,(Ne.height-(Ce.clientY-Ne.top))*L)}B.addEventListener("pointermove",Ye,{passive:!0}),B.addEventListener("pointerleave",()=>ot.set(0,0),{passive:!0});let je=0,Ie=A.current?1:0;const st=new th;let P=0;function at(){if(P=requestAnimationFrame(at),y.current||!x.current)return;const Ce=st.getElapsedTime(),Ne=Math.min(Math.max(Ce-je,.001),.033);je=Ce,Z.iTime.value=Ce,Z.uFlowTime.value+=Ne,Z.uFogTime.value+=Ne,A.current||(Ie=Math.min(1,Ie+Ne/1),Z.uFade.value=Ie,Ie>=1&&(A.current=!0));const ge=Math.max(.001,G.current);Ve.lerp(ot,1-Math.exp(-Ne/ge)),Z.iMouse.value.set(Ve.x,Ve.y,0,0),F.render(H,O)}return at(),()=>{cancelAnimationFrame(P),cancelAnimationFrame(De),Ae.disconnect(),we.disconnect(),H.clear(),J.dispose(),Pe.dispose(),F.dispose(),F.forceContextLoss(),w.contains(B)&&w.removeChild(B)}},[i]),He.useEffect(()=>{const w=R.current;if(!w)return;w.uWispDensity.value=t,w.uTiltScale.value=s,w.uBeamXFrac.value=a,w.uBeamYFrac.value=o,w.uFlowSpeed.value=l,w.uVLenFactor.value=c,w.uHLenFactor.value=u,w.uFogIntensity.value=p,w.uFogScale.value=h,w.uWSpeed.value=d,w.uWIntensity.value=g,w.uFlowStrength.value=v,w.uDecay.value=m,w.uFalloffStart.value=f,w.uFogFallSpeed.value=S;const{r:F,g:N,b:L}=xo(b);w.uColor.value.set(F,N,L)},[t,s,a,o,l,c,u,p,h,d,g,v,m,f,S,b]),$.jsx("div",{ref:E,className:n,style:{position:"relative",overflow:"hidden",...e}})}function Ti(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function Qs(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function em(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function vo(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function Mo(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function tm(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function nm(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function ns(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function im(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function rm(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function So(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function sm(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function am(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function ea(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function vl(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Eo(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2];return n[0]=r*l-s*o,n[1]=s*a-i*l,n[2]=i*o-r*a,n}function om(n,e,t,i){let r=e[0],s=e[1],a=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=a+i*(t[2]-a),n}function lm(n,e,t,i,r){const s=Math.exp(-i*r);let a=e[0],o=e[1],l=e[2];return n[0]=t[0]+(a-t[0])*s,n[1]=t[1]+(o-t[1])*s,n[2]=t[2]+(l-t[2])*s,n}function cm(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[3]*i+t[7]*r+t[11]*s+t[15];return a=a||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/a,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/a,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/a,n}function hm(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[3]*i+t[7]*r+t[11]*s+t[15];return a=a||1,n[0]=(t[0]*i+t[4]*r+t[8]*s)/a,n[1]=(t[1]*i+t[5]*r+t[9]*s)/a,n[2]=(t[2]*i+t[6]*r+t[10]*s)/a,n}function um(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function fm(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2],c=t[3],u=o*s-l*r,p=l*i-a*s,h=a*r-o*i,d=o*h-l*p,g=l*u-a*h,v=a*p-o*u,m=c*2;return u*=m,p*=m,h*=m,d*=2,g*=2,v*=2,n[0]=i+u+d,n[1]=r+p+g,n[2]=s+h+v,n}const dm=(function(){const n=[0,0,0],e=[0,0,0];return function(t,i){Qs(n,t),Qs(e,i),ea(n,n),ea(e,e);let r=vl(n,e);return r>1?0:r<-1?Math.PI:Math.acos(r)}})();function pm(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}class Gt extends Array{constructor(e=0,t=e,i=e){return super(e,t,i),this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(e){this[0]=e}set y(e){this[1]=e}set z(e){this[2]=e}set(e,t=e,i=e){return e.length?this.copy(e):(em(this,e,t,i),this)}copy(e){return Qs(this,e),this}add(e,t){return t?vo(this,e,t):vo(this,this,e),this}sub(e,t){return t?Mo(this,e,t):Mo(this,this,e),this}multiply(e){return e.length?tm(this,this,e):ns(this,this,e),this}divide(e){return e.length?nm(this,this,e):ns(this,this,1/e),this}inverse(e=this){return am(this,e),this}len(){return Ti(this)}distance(e){return e?im(this,e):Ti(this)}squaredLen(){return So(this)}squaredDistance(e){return e?rm(this,e):So(this)}negate(e=this){return sm(this,e),this}cross(e,t){return t?Eo(this,e,t):Eo(this,this,e),this}scale(e){return ns(this,this,e),this}normalize(){return ea(this,this),this}dot(e){return vl(this,e)}equals(e){return pm(this,e)}applyMatrix3(e){return um(this,this,e),this}applyMatrix4(e){return cm(this,this,e),this}scaleRotateMatrix4(e){return hm(this,this,e),this}applyQuaternion(e){return fm(this,this,e),this}angle(e){return dm(this,e)}lerp(e,t){return om(this,this,e,t),this}smoothLerp(e,t,i){return lm(this,this,e,t,i),this}clone(){return new Gt(this[0],this[1],this[2])}fromArray(e,t=0){return this[0]=e[t],this[1]=e[t+1],this[2]=e[t+2],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e}transformDirection(e){const t=this[0],i=this[1],r=this[2];return this[0]=e[0]*t+e[4]*i+e[8]*r,this[1]=e[1]*t+e[5]*i+e[9]*r,this[2]=e[2]*t+e[6]*i+e[10]*r,this.normalize()}}const yo=new Gt;let mm=1,gm=1,bo=!1;class _m{constructor(e,t={}){e.canvas||console.error("gl not passed as first argument to Geometry"),this.gl=e,this.attributes=t,this.id=mm++,this.VAOs={},this.drawRange={start:0,count:0},this.instancedCount=0,this.gl.renderer.bindVertexArray(null),this.gl.renderer.currentGeometry=null,this.glState=this.gl.renderer.state;for(let i in t)this.addAttribute(i,t[i])}addAttribute(e,t){if(this.attributes[e]=t,t.id=gm++,t.size=t.size||1,t.type=t.type||(t.data.constructor===Float32Array?this.gl.FLOAT:t.data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT),t.target=e==="index"?this.gl.ELEMENT_ARRAY_BUFFER:this.gl.ARRAY_BUFFER,t.normalized=t.normalized||!1,t.stride=t.stride||0,t.offset=t.offset||0,t.count=t.count||(t.stride?t.data.byteLength/t.stride:t.data.length/t.size),t.divisor=t.instanced||0,t.needsUpdate=!1,t.usage=t.usage||this.gl.STATIC_DRAW,t.buffer||this.updateAttribute(t),t.divisor){if(this.isInstanced=!0,this.instancedCount&&this.instancedCount!==t.count*t.divisor)return console.warn("geometry has multiple instanced buffers of different length"),this.instancedCount=Math.min(this.instancedCount,t.count*t.divisor);this.instancedCount=t.count*t.divisor}else e==="index"?this.drawRange.count=t.count:this.attributes.index||(this.drawRange.count=Math.max(this.drawRange.count,t.count))}updateAttribute(e){const t=!e.buffer;t&&(e.buffer=this.gl.createBuffer()),this.glState.boundBuffer!==e.buffer&&(this.gl.bindBuffer(e.target,e.buffer),this.glState.boundBuffer=e.buffer),t?this.gl.bufferData(e.target,e.data,e.usage):this.gl.bufferSubData(e.target,0,e.data),e.needsUpdate=!1}setIndex(e){this.addAttribute("index",e)}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}setInstancedCount(e){this.instancedCount=e}createVAO(e){this.VAOs[e.attributeOrder]=this.gl.renderer.createVertexArray(),this.gl.renderer.bindVertexArray(this.VAOs[e.attributeOrder]),this.bindAttributes(e)}bindAttributes(e){e.attributeLocations.forEach((t,{name:i,type:r})=>{if(!this.attributes[i]){console.warn(`active attribute ${i} not being supplied`);return}const s=this.attributes[i];this.gl.bindBuffer(s.target,s.buffer),this.glState.boundBuffer=s.buffer;let a=1;r===35674&&(a=2),r===35675&&(a=3),r===35676&&(a=4);const o=s.size/a,l=a===1?0:a*a*4,c=a===1?0:a*4;for(let u=0;u<a;u++)this.gl.vertexAttribPointer(t+u,o,s.type,s.normalized,s.stride+l,s.offset+u*c),this.gl.enableVertexAttribArray(t+u),this.gl.renderer.vertexAttribDivisor(t+u,s.divisor)}),this.attributes.index&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.attributes.index.buffer)}draw({program:e,mode:t=this.gl.TRIANGLES}){this.gl.renderer.currentGeometry!==`${this.id}_${e.attributeOrder}`&&(this.VAOs[e.attributeOrder]||this.createVAO(e),this.gl.renderer.bindVertexArray(this.VAOs[e.attributeOrder]),this.gl.renderer.currentGeometry=`${this.id}_${e.attributeOrder}`),e.attributeLocations.forEach((r,{name:s})=>{const a=this.attributes[s];a.needsUpdate&&this.updateAttribute(a)});let i=2;this.attributes.index?.type===this.gl.UNSIGNED_INT&&(i=4),this.isInstanced?this.attributes.index?this.gl.renderer.drawElementsInstanced(t,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i,this.instancedCount):this.gl.renderer.drawArraysInstanced(t,this.drawRange.start,this.drawRange.count,this.instancedCount):this.attributes.index?this.gl.drawElements(t,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i):this.gl.drawArrays(t,this.drawRange.start,this.drawRange.count)}getPosition(){const e=this.attributes.position;if(e.data)return e;if(!bo)return console.warn("No position buffer data found to compute bounds"),bo=!0}computeBoundingBox(e){e||(e=this.getPosition());const t=e.data,i=e.size;this.bounds||(this.bounds={min:new Gt,max:new Gt,center:new Gt,scale:new Gt,radius:1/0});const r=this.bounds.min,s=this.bounds.max,a=this.bounds.center,o=this.bounds.scale;r.set(1/0),s.set(-1/0);for(let l=0,c=t.length;l<c;l+=i){const u=t[l],p=t[l+1],h=t[l+2];r.x=Math.min(u,r.x),r.y=Math.min(p,r.y),r.z=Math.min(h,r.z),s.x=Math.max(u,s.x),s.y=Math.max(p,s.y),s.z=Math.max(h,s.z)}o.sub(s,r),a.add(r,s).divide(2)}computeBoundingSphere(e){e||(e=this.getPosition());const t=e.data,i=e.size;this.bounds||this.computeBoundingBox(e);let r=0;for(let s=0,a=t.length;s<a;s+=i)yo.fromArray(t,s),r=Math.max(r,this.bounds.center.squaredDistance(yo));this.bounds.radius=Math.sqrt(r)}remove(){for(let e in this.VAOs)this.gl.renderer.deleteVertexArray(this.VAOs[e]),delete this.VAOs[e];for(let e in this.attributes)this.gl.deleteBuffer(this.attributes[e].buffer),delete this.attributes[e]}}let xm=1;const To={};class vm{constructor(e,{vertex:t,fragment:i,uniforms:r={},transparent:s=!1,cullFace:a=e.BACK,frontFace:o=e.CCW,depthTest:l=!0,depthWrite:c=!0,depthFunc:u=e.LEQUAL}={}){e.canvas||console.error("gl not passed as first argument to Program"),this.gl=e,this.uniforms=r,this.id=xm++,t||console.warn("vertex shader not supplied"),i||console.warn("fragment shader not supplied"),this.transparent=s,this.cullFace=a,this.frontFace=o,this.depthTest=l,this.depthWrite=c,this.depthFunc=u,this.blendFunc={},this.blendEquation={},this.stencilFunc={},this.stencilOp={},this.transparent&&!this.blendFunc.src&&(this.gl.renderer.premultipliedAlpha?this.setBlendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.setBlendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA)),this.vertexShader=e.createShader(e.VERTEX_SHADER),this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),this.program=e.createProgram(),e.attachShader(this.program,this.vertexShader),e.attachShader(this.program,this.fragmentShader),this.setShaders({vertex:t,fragment:i})}setShaders({vertex:e,fragment:t}){if(e&&(this.gl.shaderSource(this.vertexShader,e),this.gl.compileShader(this.vertexShader),this.gl.getShaderInfoLog(this.vertexShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.vertexShader)}
4252
+ `;function xo(n){let e=n.trim().replace("#","");e.length===3&&(e=e.split("").map(i=>i+i).join(""));const t=parseInt(e,16)||16777215;return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(t&255)/255}}function em({className:n,style:e,wispDensity:t=1,dpr:i,mouseSmoothTime:r=.06,mouseTiltStrength:s=.01,horizontalBeamOffset:a=0,verticalBeamOffset:o=-.5,flowSpeed:l=.35,verticalSizing:c=2,horizontalSizing:u=.5,fogIntensity:m=.45,fogScale:h=.3,wispSpeed:p=15,wispIntensity:g=5,flowStrength:v=.25,decay:d=1.1,falloffStart:f=1.2,fogFallSpeed:S=.6,color:b="#8a7aff"}){const E=He.useRef(null),R=He.useRef(null),A=He.useRef(!1),C=He.useRef(null),x=He.useRef(!0),y=He.useRef(!1),G=He.useRef(r);return He.useEffect(()=>{G.current=r},[r]),He.useEffect(()=>{const w=E.current;let F;try{F=new Kp({antialias:!1,alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,powerPreference:"high-performance"})}catch(Ce){console.warn("LaserFlow: WebGL not supported or context creation failed.",Ce);return}let L=Math.min(i??(window.devicePixelRatio||1),2);F.setPixelRatio(L),F.outputColorSpace=Hn,F.setClearColor(0,0);const B=F.domElement;B.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;",w.appendChild(B);const H=new Nc,O=new ua(-1,1,1,-1,0,1),J=new en;J.setAttribute("position",new Vt(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));const Z={iTime:{value:0},iResolution:{value:new k(1,1,1)},iMouse:{value:new ct(0,0,0,0)},uWispDensity:{value:t},uTiltScale:{value:s},uFlowTime:{value:0},uFogTime:{value:0},uBeamXFrac:{value:a},uBeamYFrac:{value:o},uFlowSpeed:{value:l},uVLenFactor:{value:c},uHLenFactor:{value:u},uFogIntensity:{value:m},uFogScale:{value:h},uWSpeed:{value:p},uWIntensity:{value:g},uFlowStrength:{value:v},uDecay:{value:d},uFalloffStart:{value:f},uFogFallSpeed:{value:S},uColor:{value:new k(1,1,1)},uFade:{value:A.current?1:0}};R.current=Z;const{r:le,g:de,b:ue}=xo(b);Z.uColor.value.set(le,de,ue);const Pe=new ul({vertexShader:Jp,fragmentShader:Qp,uniforms:Z,transparent:!0,depthTest:!1,depthWrite:!1,blending:Gn}),nt=new Jt(J,Pe);nt.frustumCulled=!1,H.add(nt);let Je=0,j=0,te=0;function re(){const Ce=w.clientWidth||1,Ne=w.clientHeight||1;Math.abs(Ce-Je)<1&&Math.abs(Ne-j)<1&&Math.abs(L-te)<.01||(Je=Ce,j=Ne,te=L,F.setPixelRatio(L),F.setSize(Ce,Ne,!1),Z.iResolution.value.set(Ce*L,Ne*L,L),C.current=B.getBoundingClientRect())}let De=0;const Ae=new ResizeObserver(()=>{cancelAnimationFrame(De),De=requestAnimationFrame(re)});Ae.observe(w),re();const we=new IntersectionObserver(Ce=>{x.current=Ce[0]?.isIntersecting??!0},{threshold:0});we.observe(w),document.addEventListener("visibilitychange",()=>{y.current=document.hidden},{passive:!0});const ot=new $e(0,0),Ve=new $e(0,0);function Ye(Ce){const Ne=C.current;Ne&&ot.set((Ce.clientX-Ne.left)*L,(Ne.height-(Ce.clientY-Ne.top))*L)}B.addEventListener("pointermove",Ye,{passive:!0}),B.addEventListener("pointerleave",()=>ot.set(0,0),{passive:!0});let je=0,Ie=A.current?1:0;const st=new nh;let P=0;function at(){if(P=requestAnimationFrame(at),y.current||!x.current)return;const Ce=st.getElapsedTime(),Ne=Math.min(Math.max(Ce-je,.001),.033);je=Ce,Z.iTime.value=Ce,Z.uFlowTime.value+=Ne,Z.uFogTime.value+=Ne,A.current||(Ie=Math.min(1,Ie+Ne/1),Z.uFade.value=Ie,Ie>=1&&(A.current=!0));const ge=Math.max(.001,G.current);Ve.lerp(ot,1-Math.exp(-Ne/ge)),Z.iMouse.value.set(Ve.x,Ve.y,0,0),F.render(H,O)}return at(),()=>{cancelAnimationFrame(P),cancelAnimationFrame(De),Ae.disconnect(),we.disconnect(),H.clear(),J.dispose(),Pe.dispose(),F.dispose(),F.forceContextLoss(),w.contains(B)&&w.removeChild(B)}},[i]),He.useEffect(()=>{const w=R.current;if(!w)return;w.uWispDensity.value=t,w.uTiltScale.value=s,w.uBeamXFrac.value=a,w.uBeamYFrac.value=o,w.uFlowSpeed.value=l,w.uVLenFactor.value=c,w.uHLenFactor.value=u,w.uFogIntensity.value=m,w.uFogScale.value=h,w.uWSpeed.value=p,w.uWIntensity.value=g,w.uFlowStrength.value=v,w.uDecay.value=d,w.uFalloffStart.value=f,w.uFogFallSpeed.value=S;const{r:F,g:N,b:L}=xo(b);w.uColor.value.set(F,N,L)},[t,s,a,o,l,c,u,m,h,p,g,v,d,f,S,b]),$.jsx("div",{ref:E,className:n,style:{position:"relative",overflow:"hidden",...e}})}function Ai(n){let e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function Js(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}function tm(n,e,t,i){return n[0]=e,n[1]=t,n[2]=i,n}function vo(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function Mo(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function nm(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function im(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n}function ns(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function rm(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return Math.sqrt(t*t+i*i+r*r)}function sm(n,e){let t=e[0]-n[0],i=e[1]-n[1],r=e[2]-n[2];return t*t+i*i+r*r}function So(n){let e=n[0],t=n[1],i=n[2];return e*e+t*t+i*i}function am(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function om(n,e){return n[0]=1/e[0],n[1]=1/e[1],n[2]=1/e[2],n}function Qs(n,e){let t=e[0],i=e[1],r=e[2],s=t*t+i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n}function vl(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Eo(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2];return n[0]=r*l-s*o,n[1]=s*a-i*l,n[2]=i*o-r*a,n}function lm(n,e,t,i){let r=e[0],s=e[1],a=e[2];return n[0]=r+i*(t[0]-r),n[1]=s+i*(t[1]-s),n[2]=a+i*(t[2]-a),n}function cm(n,e,t,i,r){const s=Math.exp(-i*r);let a=e[0],o=e[1],l=e[2];return n[0]=t[0]+(a-t[0])*s,n[1]=t[1]+(o-t[1])*s,n[2]=t[2]+(l-t[2])*s,n}function hm(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[3]*i+t[7]*r+t[11]*s+t[15];return a=a||1,n[0]=(t[0]*i+t[4]*r+t[8]*s+t[12])/a,n[1]=(t[1]*i+t[5]*r+t[9]*s+t[13])/a,n[2]=(t[2]*i+t[6]*r+t[10]*s+t[14])/a,n}function um(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[3]*i+t[7]*r+t[11]*s+t[15];return a=a||1,n[0]=(t[0]*i+t[4]*r+t[8]*s)/a,n[1]=(t[1]*i+t[5]*r+t[9]*s)/a,n[2]=(t[2]*i+t[6]*r+t[10]*s)/a,n}function fm(n,e,t){let i=e[0],r=e[1],s=e[2];return n[0]=i*t[0]+r*t[3]+s*t[6],n[1]=i*t[1]+r*t[4]+s*t[7],n[2]=i*t[2]+r*t[5]+s*t[8],n}function dm(n,e,t){let i=e[0],r=e[1],s=e[2],a=t[0],o=t[1],l=t[2],c=t[3],u=o*s-l*r,m=l*i-a*s,h=a*r-o*i,p=o*h-l*m,g=l*u-a*h,v=a*m-o*u,d=c*2;return u*=d,m*=d,h*=d,p*=2,g*=2,v*=2,n[0]=i+u+p,n[1]=r+m+g,n[2]=s+h+v,n}const pm=(function(){const n=[0,0,0],e=[0,0,0];return function(t,i){Js(n,t),Js(e,i),Qs(n,n),Qs(e,e);let r=vl(n,e);return r>1?0:r<-1?Math.PI:Math.acos(r)}})();function mm(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}class Gt extends Array{constructor(e=0,t=e,i=e){return super(e,t,i),this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(e){this[0]=e}set y(e){this[1]=e}set z(e){this[2]=e}set(e,t=e,i=e){return e.length?this.copy(e):(tm(this,e,t,i),this)}copy(e){return Js(this,e),this}add(e,t){return t?vo(this,e,t):vo(this,this,e),this}sub(e,t){return t?Mo(this,e,t):Mo(this,this,e),this}multiply(e){return e.length?nm(this,this,e):ns(this,this,e),this}divide(e){return e.length?im(this,this,e):ns(this,this,1/e),this}inverse(e=this){return om(this,e),this}len(){return Ai(this)}distance(e){return e?rm(this,e):Ai(this)}squaredLen(){return So(this)}squaredDistance(e){return e?sm(this,e):So(this)}negate(e=this){return am(this,e),this}cross(e,t){return t?Eo(this,e,t):Eo(this,this,e),this}scale(e){return ns(this,this,e),this}normalize(){return Qs(this,this),this}dot(e){return vl(this,e)}equals(e){return mm(this,e)}applyMatrix3(e){return fm(this,this,e),this}applyMatrix4(e){return hm(this,this,e),this}scaleRotateMatrix4(e){return um(this,this,e),this}applyQuaternion(e){return dm(this,this,e),this}angle(e){return pm(this,e)}lerp(e,t){return lm(this,this,e,t),this}smoothLerp(e,t,i){return cm(this,this,e,t,i),this}clone(){return new Gt(this[0],this[1],this[2])}fromArray(e,t=0){return this[0]=e[t],this[1]=e[t+1],this[2]=e[t+2],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e}transformDirection(e){const t=this[0],i=this[1],r=this[2];return this[0]=e[0]*t+e[4]*i+e[8]*r,this[1]=e[1]*t+e[5]*i+e[9]*r,this[2]=e[2]*t+e[6]*i+e[10]*r,this.normalize()}}const yo=new Gt;let gm=1,_m=1,bo=!1;class xm{constructor(e,t={}){e.canvas||console.error("gl not passed as first argument to Geometry"),this.gl=e,this.attributes=t,this.id=gm++,this.VAOs={},this.drawRange={start:0,count:0},this.instancedCount=0,this.gl.renderer.bindVertexArray(null),this.gl.renderer.currentGeometry=null,this.glState=this.gl.renderer.state;for(let i in t)this.addAttribute(i,t[i])}addAttribute(e,t){if(this.attributes[e]=t,t.id=_m++,t.size=t.size||1,t.type=t.type||(t.data.constructor===Float32Array?this.gl.FLOAT:t.data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT),t.target=e==="index"?this.gl.ELEMENT_ARRAY_BUFFER:this.gl.ARRAY_BUFFER,t.normalized=t.normalized||!1,t.stride=t.stride||0,t.offset=t.offset||0,t.count=t.count||(t.stride?t.data.byteLength/t.stride:t.data.length/t.size),t.divisor=t.instanced||0,t.needsUpdate=!1,t.usage=t.usage||this.gl.STATIC_DRAW,t.buffer||this.updateAttribute(t),t.divisor){if(this.isInstanced=!0,this.instancedCount&&this.instancedCount!==t.count*t.divisor)return console.warn("geometry has multiple instanced buffers of different length"),this.instancedCount=Math.min(this.instancedCount,t.count*t.divisor);this.instancedCount=t.count*t.divisor}else e==="index"?this.drawRange.count=t.count:this.attributes.index||(this.drawRange.count=Math.max(this.drawRange.count,t.count))}updateAttribute(e){const t=!e.buffer;t&&(e.buffer=this.gl.createBuffer()),this.glState.boundBuffer!==e.buffer&&(this.gl.bindBuffer(e.target,e.buffer),this.glState.boundBuffer=e.buffer),t?this.gl.bufferData(e.target,e.data,e.usage):this.gl.bufferSubData(e.target,0,e.data),e.needsUpdate=!1}setIndex(e){this.addAttribute("index",e)}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}setInstancedCount(e){this.instancedCount=e}createVAO(e){this.VAOs[e.attributeOrder]=this.gl.renderer.createVertexArray(),this.gl.renderer.bindVertexArray(this.VAOs[e.attributeOrder]),this.bindAttributes(e)}bindAttributes(e){e.attributeLocations.forEach((t,{name:i,type:r})=>{if(!this.attributes[i]){console.warn(`active attribute ${i} not being supplied`);return}const s=this.attributes[i];this.gl.bindBuffer(s.target,s.buffer),this.glState.boundBuffer=s.buffer;let a=1;r===35674&&(a=2),r===35675&&(a=3),r===35676&&(a=4);const o=s.size/a,l=a===1?0:a*a*4,c=a===1?0:a*4;for(let u=0;u<a;u++)this.gl.vertexAttribPointer(t+u,o,s.type,s.normalized,s.stride+l,s.offset+u*c),this.gl.enableVertexAttribArray(t+u),this.gl.renderer.vertexAttribDivisor(t+u,s.divisor)}),this.attributes.index&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.attributes.index.buffer)}draw({program:e,mode:t=this.gl.TRIANGLES}){this.gl.renderer.currentGeometry!==`${this.id}_${e.attributeOrder}`&&(this.VAOs[e.attributeOrder]||this.createVAO(e),this.gl.renderer.bindVertexArray(this.VAOs[e.attributeOrder]),this.gl.renderer.currentGeometry=`${this.id}_${e.attributeOrder}`),e.attributeLocations.forEach((r,{name:s})=>{const a=this.attributes[s];a.needsUpdate&&this.updateAttribute(a)});let i=2;this.attributes.index?.type===this.gl.UNSIGNED_INT&&(i=4),this.isInstanced?this.attributes.index?this.gl.renderer.drawElementsInstanced(t,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i,this.instancedCount):this.gl.renderer.drawArraysInstanced(t,this.drawRange.start,this.drawRange.count,this.instancedCount):this.attributes.index?this.gl.drawElements(t,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i):this.gl.drawArrays(t,this.drawRange.start,this.drawRange.count)}getPosition(){const e=this.attributes.position;if(e.data)return e;if(!bo)return console.warn("No position buffer data found to compute bounds"),bo=!0}computeBoundingBox(e){e||(e=this.getPosition());const t=e.data,i=e.size;this.bounds||(this.bounds={min:new Gt,max:new Gt,center:new Gt,scale:new Gt,radius:1/0});const r=this.bounds.min,s=this.bounds.max,a=this.bounds.center,o=this.bounds.scale;r.set(1/0),s.set(-1/0);for(let l=0,c=t.length;l<c;l+=i){const u=t[l],m=t[l+1],h=t[l+2];r.x=Math.min(u,r.x),r.y=Math.min(m,r.y),r.z=Math.min(h,r.z),s.x=Math.max(u,s.x),s.y=Math.max(m,s.y),s.z=Math.max(h,s.z)}o.sub(s,r),a.add(r,s).divide(2)}computeBoundingSphere(e){e||(e=this.getPosition());const t=e.data,i=e.size;this.bounds||this.computeBoundingBox(e);let r=0;for(let s=0,a=t.length;s<a;s+=i)yo.fromArray(t,s),r=Math.max(r,this.bounds.center.squaredDistance(yo));this.bounds.radius=Math.sqrt(r)}remove(){for(let e in this.VAOs)this.gl.renderer.deleteVertexArray(this.VAOs[e]),delete this.VAOs[e];for(let e in this.attributes)this.gl.deleteBuffer(this.attributes[e].buffer),delete this.attributes[e]}}let vm=1;const To={};class Mm{constructor(e,{vertex:t,fragment:i,uniforms:r={},transparent:s=!1,cullFace:a=e.BACK,frontFace:o=e.CCW,depthTest:l=!0,depthWrite:c=!0,depthFunc:u=e.LEQUAL}={}){e.canvas||console.error("gl not passed as first argument to Program"),this.gl=e,this.uniforms=r,this.id=vm++,t||console.warn("vertex shader not supplied"),i||console.warn("fragment shader not supplied"),this.transparent=s,this.cullFace=a,this.frontFace=o,this.depthTest=l,this.depthWrite=c,this.depthFunc=u,this.blendFunc={},this.blendEquation={},this.stencilFunc={},this.stencilOp={},this.transparent&&!this.blendFunc.src&&(this.gl.renderer.premultipliedAlpha?this.setBlendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.setBlendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA)),this.vertexShader=e.createShader(e.VERTEX_SHADER),this.fragmentShader=e.createShader(e.FRAGMENT_SHADER),this.program=e.createProgram(),e.attachShader(this.program,this.vertexShader),e.attachShader(this.program,this.fragmentShader),this.setShaders({vertex:t,fragment:i})}setShaders({vertex:e,fragment:t}){if(e&&(this.gl.shaderSource(this.vertexShader,e),this.gl.compileShader(this.vertexShader),this.gl.getShaderInfoLog(this.vertexShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.vertexShader)}
4253
4253
  Vertex Shader
4254
4254
  ${Ao(e)}`)),t&&(this.gl.shaderSource(this.fragmentShader,t),this.gl.compileShader(this.fragmentShader),this.gl.getShaderInfoLog(this.fragmentShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.fragmentShader)}
4255
4255
  Fragment Shader
4256
- ${Ao(t)}`)),this.gl.linkProgram(this.program),!this.gl.getProgramParameter(this.program,this.gl.LINK_STATUS))return console.warn(this.gl.getProgramInfoLog(this.program));this.uniformLocations=new Map;let i=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_UNIFORMS);for(let a=0;a<i;a++){let o=this.gl.getActiveUniform(this.program,a);this.uniformLocations.set(o,this.gl.getUniformLocation(this.program,o.name));const l=o.name.match(/(\w+)/g);o.uniformName=l[0],o.nameComponents=l.slice(1)}this.attributeLocations=new Map;const r=[],s=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_ATTRIBUTES);for(let a=0;a<s;a++){const o=this.gl.getActiveAttrib(this.program,a),l=this.gl.getAttribLocation(this.program,o.name);l!==-1&&(r[l]=o.name,this.attributeLocations.set(o,l))}this.attributeOrder=r.join("")}setBlendFunc(e,t,i,r){this.blendFunc.src=e,this.blendFunc.dst=t,this.blendFunc.srcAlpha=i,this.blendFunc.dstAlpha=r,e&&(this.transparent=!0)}setBlendEquation(e,t){this.blendEquation.modeRGB=e,this.blendEquation.modeAlpha=t}setStencilFunc(e,t,i){this.stencilRef=t,this.stencilFunc.func=e,this.stencilFunc.ref=t,this.stencilFunc.mask=i}setStencilOp(e,t,i){this.stencilOp.stencilFail=e,this.stencilOp.depthFail=t,this.stencilOp.depthPass=i}applyState(){this.depthTest?this.gl.renderer.enable(this.gl.DEPTH_TEST):this.gl.renderer.disable(this.gl.DEPTH_TEST),this.cullFace?this.gl.renderer.enable(this.gl.CULL_FACE):this.gl.renderer.disable(this.gl.CULL_FACE),this.blendFunc.src?this.gl.renderer.enable(this.gl.BLEND):this.gl.renderer.disable(this.gl.BLEND),this.cullFace&&this.gl.renderer.setCullFace(this.cullFace),this.gl.renderer.setFrontFace(this.frontFace),this.gl.renderer.setDepthMask(this.depthWrite),this.gl.renderer.setDepthFunc(this.depthFunc),this.blendFunc.src&&this.gl.renderer.setBlendFunc(this.blendFunc.src,this.blendFunc.dst,this.blendFunc.srcAlpha,this.blendFunc.dstAlpha),this.gl.renderer.setBlendEquation(this.blendEquation.modeRGB,this.blendEquation.modeAlpha),this.stencilFunc.func||this.stencilOp.stencilFail?this.gl.renderer.enable(this.gl.STENCIL_TEST):this.gl.renderer.disable(this.gl.STENCIL_TEST),this.gl.renderer.setStencilFunc(this.stencilFunc.func,this.stencilFunc.ref,this.stencilFunc.mask),this.gl.renderer.setStencilOp(this.stencilOp.stencilFail,this.stencilOp.depthFail,this.stencilOp.depthPass)}use({flipFaces:e=!1}={}){let t=-1;this.gl.renderer.state.currentProgram===this.id||(this.gl.useProgram(this.program),this.gl.renderer.state.currentProgram=this.id),this.uniformLocations.forEach((r,s)=>{let a=this.uniforms[s.uniformName];for(const o of s.nameComponents){if(!a)break;if(o in a)a=a[o];else{if(Array.isArray(a.value))break;a=void 0;break}}if(!a)return wo(`Active uniform ${s.name} has not been supplied`);if(a&&a.value===void 0)return wo(`${s.name} uniform is missing a value parameter`);if(a.value.texture)return t=t+1,a.value.update(t),is(this.gl,s.type,r,t);if(a.value.length&&a.value[0].texture){const o=[];return a.value.forEach(l=>{t=t+1,l.update(t),o.push(t)}),is(this.gl,s.type,r,o)}is(this.gl,s.type,r,a.value)}),this.applyState(),e&&this.gl.renderer.setFrontFace(this.frontFace===this.gl.CCW?this.gl.CW:this.gl.CCW)}remove(){this.gl.deleteProgram(this.program)}}function is(n,e,t,i){i=i.length?Mm(i):i;const r=n.renderer.state.uniformLocations.get(t);if(i.length)if(r===void 0||r.length!==i.length)n.renderer.state.uniformLocations.set(t,i.slice(0));else{if(Sm(r,i))return;r.set?r.set(i):Em(r,i),n.renderer.state.uniformLocations.set(t,r)}else{if(r===i)return;n.renderer.state.uniformLocations.set(t,i)}switch(e){case 5126:return i.length?n.uniform1fv(t,i):n.uniform1f(t,i);case 35664:return n.uniform2fv(t,i);case 35665:return n.uniform3fv(t,i);case 35666:return n.uniform4fv(t,i);case 35670:case 5124:case 35678:case 36306:case 35680:case 36289:return i.length?n.uniform1iv(t,i):n.uniform1i(t,i);case 35671:case 35667:return n.uniform2iv(t,i);case 35672:case 35668:return n.uniform3iv(t,i);case 35673:case 35669:return n.uniform4iv(t,i);case 35674:return n.uniformMatrix2fv(t,!1,i);case 35675:return n.uniformMatrix3fv(t,!1,i);case 35676:return n.uniformMatrix4fv(t,!1,i)}}function Ao(n){let e=n.split(`
4256
+ ${Ao(t)}`)),this.gl.linkProgram(this.program),!this.gl.getProgramParameter(this.program,this.gl.LINK_STATUS))return console.warn(this.gl.getProgramInfoLog(this.program));this.uniformLocations=new Map;let i=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_UNIFORMS);for(let a=0;a<i;a++){let o=this.gl.getActiveUniform(this.program,a);this.uniformLocations.set(o,this.gl.getUniformLocation(this.program,o.name));const l=o.name.match(/(\w+)/g);o.uniformName=l[0],o.nameComponents=l.slice(1)}this.attributeLocations=new Map;const r=[],s=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_ATTRIBUTES);for(let a=0;a<s;a++){const o=this.gl.getActiveAttrib(this.program,a),l=this.gl.getAttribLocation(this.program,o.name);l!==-1&&(r[l]=o.name,this.attributeLocations.set(o,l))}this.attributeOrder=r.join("")}setBlendFunc(e,t,i,r){this.blendFunc.src=e,this.blendFunc.dst=t,this.blendFunc.srcAlpha=i,this.blendFunc.dstAlpha=r,e&&(this.transparent=!0)}setBlendEquation(e,t){this.blendEquation.modeRGB=e,this.blendEquation.modeAlpha=t}setStencilFunc(e,t,i){this.stencilRef=t,this.stencilFunc.func=e,this.stencilFunc.ref=t,this.stencilFunc.mask=i}setStencilOp(e,t,i){this.stencilOp.stencilFail=e,this.stencilOp.depthFail=t,this.stencilOp.depthPass=i}applyState(){this.depthTest?this.gl.renderer.enable(this.gl.DEPTH_TEST):this.gl.renderer.disable(this.gl.DEPTH_TEST),this.cullFace?this.gl.renderer.enable(this.gl.CULL_FACE):this.gl.renderer.disable(this.gl.CULL_FACE),this.blendFunc.src?this.gl.renderer.enable(this.gl.BLEND):this.gl.renderer.disable(this.gl.BLEND),this.cullFace&&this.gl.renderer.setCullFace(this.cullFace),this.gl.renderer.setFrontFace(this.frontFace),this.gl.renderer.setDepthMask(this.depthWrite),this.gl.renderer.setDepthFunc(this.depthFunc),this.blendFunc.src&&this.gl.renderer.setBlendFunc(this.blendFunc.src,this.blendFunc.dst,this.blendFunc.srcAlpha,this.blendFunc.dstAlpha),this.gl.renderer.setBlendEquation(this.blendEquation.modeRGB,this.blendEquation.modeAlpha),this.stencilFunc.func||this.stencilOp.stencilFail?this.gl.renderer.enable(this.gl.STENCIL_TEST):this.gl.renderer.disable(this.gl.STENCIL_TEST),this.gl.renderer.setStencilFunc(this.stencilFunc.func,this.stencilFunc.ref,this.stencilFunc.mask),this.gl.renderer.setStencilOp(this.stencilOp.stencilFail,this.stencilOp.depthFail,this.stencilOp.depthPass)}use({flipFaces:e=!1}={}){let t=-1;this.gl.renderer.state.currentProgram===this.id||(this.gl.useProgram(this.program),this.gl.renderer.state.currentProgram=this.id),this.uniformLocations.forEach((r,s)=>{let a=this.uniforms[s.uniformName];for(const o of s.nameComponents){if(!a)break;if(o in a)a=a[o];else{if(Array.isArray(a.value))break;a=void 0;break}}if(!a)return wo(`Active uniform ${s.name} has not been supplied`);if(a&&a.value===void 0)return wo(`${s.name} uniform is missing a value parameter`);if(a.value.texture)return t=t+1,a.value.update(t),is(this.gl,s.type,r,t);if(a.value.length&&a.value[0].texture){const o=[];return a.value.forEach(l=>{t=t+1,l.update(t),o.push(t)}),is(this.gl,s.type,r,o)}is(this.gl,s.type,r,a.value)}),this.applyState(),e&&this.gl.renderer.setFrontFace(this.frontFace===this.gl.CCW?this.gl.CW:this.gl.CCW)}remove(){this.gl.deleteProgram(this.program)}}function is(n,e,t,i){i=i.length?Sm(i):i;const r=n.renderer.state.uniformLocations.get(t);if(i.length)if(r===void 0||r.length!==i.length)n.renderer.state.uniformLocations.set(t,i.slice(0));else{if(Em(r,i))return;r.set?r.set(i):ym(r,i),n.renderer.state.uniformLocations.set(t,r)}else{if(r===i)return;n.renderer.state.uniformLocations.set(t,i)}switch(e){case 5126:return i.length?n.uniform1fv(t,i):n.uniform1f(t,i);case 35664:return n.uniform2fv(t,i);case 35665:return n.uniform3fv(t,i);case 35666:return n.uniform4fv(t,i);case 35670:case 5124:case 35678:case 36306:case 35680:case 36289:return i.length?n.uniform1iv(t,i):n.uniform1i(t,i);case 35671:case 35667:return n.uniform2iv(t,i);case 35672:case 35668:return n.uniform3iv(t,i);case 35673:case 35669:return n.uniform4iv(t,i);case 35674:return n.uniformMatrix2fv(t,!1,i);case 35675:return n.uniformMatrix3fv(t,!1,i);case 35676:return n.uniformMatrix4fv(t,!1,i)}}function Ao(n){let e=n.split(`
4257
4257
  `);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
4258
- `)}function Mm(n){const e=n.length,t=n[0].length;if(t===void 0)return n;const i=e*t;let r=To[i];r||(To[i]=r=new Float32Array(i));for(let s=0;s<e;s++)r.set(n[s],s*t);return r}function Sm(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Em(n,e){for(let t=0,i=n.length;t<i;t++)n[t]=e[t]}let rs=0;function wo(n){rs>100||(console.warn(n),rs++,rs>100&&console.warn("More than 100 program warnings - stopping logs."))}const ss=new Gt;let ym=1;class bm{constructor({canvas:e=document.createElement("canvas"),width:t=300,height:i=150,dpr:r=1,alpha:s=!1,depth:a=!0,stencil:o=!1,antialias:l=!1,premultipliedAlpha:c=!1,preserveDrawingBuffer:u=!1,powerPreference:p="default",autoClear:h=!0,webgl:d=2}={}){const g={alpha:s,depth:a,stencil:o,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:p};this.dpr=r,this.alpha=s,this.color=!0,this.depth=a,this.stencil=o,this.premultipliedAlpha=c,this.autoClear=h,this.id=ym++,d===2&&(this.gl=e.getContext("webgl2",g)),this.isWebgl2=!!this.gl,this.gl||(this.gl=e.getContext("webgl",g)),this.gl||console.error("unable to create webgl context"),this.gl.renderer=this,this.setSize(t,i),this.state={},this.state.blendFunc={src:this.gl.ONE,dst:this.gl.ZERO},this.state.blendEquation={modeRGB:this.gl.FUNC_ADD},this.state.cullFace=!1,this.state.frontFace=this.gl.CCW,this.state.depthMask=!0,this.state.depthFunc=this.gl.LEQUAL,this.state.premultiplyAlpha=!1,this.state.flipY=!1,this.state.unpackAlignment=4,this.state.framebuffer=null,this.state.viewport={x:0,y:0,width:null,height:null},this.state.textureUnits=[],this.state.activeTextureUnit=0,this.state.boundBuffer=null,this.state.uniformLocations=new Map,this.state.currentProgram=null,this.extensions={},this.isWebgl2?(this.getExtension("EXT_color_buffer_float"),this.getExtension("OES_texture_float_linear")):(this.getExtension("OES_texture_float"),this.getExtension("OES_texture_float_linear"),this.getExtension("OES_texture_half_float"),this.getExtension("OES_texture_half_float_linear"),this.getExtension("OES_element_index_uint"),this.getExtension("OES_standard_derivatives"),this.getExtension("EXT_sRGB"),this.getExtension("WEBGL_depth_texture"),this.getExtension("WEBGL_draw_buffers")),this.getExtension("WEBGL_compressed_texture_astc"),this.getExtension("EXT_texture_compression_bptc"),this.getExtension("WEBGL_compressed_texture_s3tc"),this.getExtension("WEBGL_compressed_texture_etc1"),this.getExtension("WEBGL_compressed_texture_pvrtc"),this.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this.vertexAttribDivisor=this.getExtension("ANGLE_instanced_arrays","vertexAttribDivisor","vertexAttribDivisorANGLE"),this.drawArraysInstanced=this.getExtension("ANGLE_instanced_arrays","drawArraysInstanced","drawArraysInstancedANGLE"),this.drawElementsInstanced=this.getExtension("ANGLE_instanced_arrays","drawElementsInstanced","drawElementsInstancedANGLE"),this.createVertexArray=this.getExtension("OES_vertex_array_object","createVertexArray","createVertexArrayOES"),this.bindVertexArray=this.getExtension("OES_vertex_array_object","bindVertexArray","bindVertexArrayOES"),this.deleteVertexArray=this.getExtension("OES_vertex_array_object","deleteVertexArray","deleteVertexArrayOES"),this.drawBuffers=this.getExtension("WEBGL_draw_buffers","drawBuffers","drawBuffersWEBGL"),this.parameters={},this.parameters.maxTextureUnits=this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this.parameters.maxAnisotropy=this.getExtension("EXT_texture_filter_anisotropic")?this.gl.getParameter(this.getExtension("EXT_texture_filter_anisotropic").MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}setSize(e,t){this.width=e,this.height=t,this.gl.canvas.width=e*this.dpr,this.gl.canvas.height=t*this.dpr,this.gl.canvas.style&&Object.assign(this.gl.canvas.style,{width:e+"px",height:t+"px"})}setViewport(e,t,i=0,r=0){this.state.viewport.width===e&&this.state.viewport.height===t||(this.state.viewport.width=e,this.state.viewport.height=t,this.state.viewport.x=i,this.state.viewport.y=r,this.gl.viewport(i,r,e,t))}setScissor(e,t,i=0,r=0){this.gl.scissor(i,r,e,t)}enable(e){this.state[e]!==!0&&(this.gl.enable(e),this.state[e]=!0)}disable(e){this.state[e]!==!1&&(this.gl.disable(e),this.state[e]=!1)}setBlendFunc(e,t,i,r){this.state.blendFunc.src===e&&this.state.blendFunc.dst===t&&this.state.blendFunc.srcAlpha===i&&this.state.blendFunc.dstAlpha===r||(this.state.blendFunc.src=e,this.state.blendFunc.dst=t,this.state.blendFunc.srcAlpha=i,this.state.blendFunc.dstAlpha=r,i!==void 0?this.gl.blendFuncSeparate(e,t,i,r):this.gl.blendFunc(e,t))}setBlendEquation(e,t){e=e||this.gl.FUNC_ADD,!(this.state.blendEquation.modeRGB===e&&this.state.blendEquation.modeAlpha===t)&&(this.state.blendEquation.modeRGB=e,this.state.blendEquation.modeAlpha=t,t!==void 0?this.gl.blendEquationSeparate(e,t):this.gl.blendEquation(e))}setCullFace(e){this.state.cullFace!==e&&(this.state.cullFace=e,this.gl.cullFace(e))}setFrontFace(e){this.state.frontFace!==e&&(this.state.frontFace=e,this.gl.frontFace(e))}setDepthMask(e){this.state.depthMask!==e&&(this.state.depthMask=e,this.gl.depthMask(e))}setDepthFunc(e){this.state.depthFunc!==e&&(this.state.depthFunc=e,this.gl.depthFunc(e))}setStencilMask(e){this.state.stencilMask!==e&&(this.state.stencilMask=e,this.gl.stencilMask(e))}setStencilFunc(e,t,i){this.state.stencilFunc===e&&this.state.stencilRef===t&&this.state.stencilFuncMask===i||(this.state.stencilFunc=e||this.gl.ALWAYS,this.state.stencilRef=t||0,this.state.stencilFuncMask=i||0,this.gl.stencilFunc(e||this.gl.ALWAYS,t||0,i||0))}setStencilOp(e,t,i){this.state.stencilFail===e&&this.state.stencilDepthFail===t&&this.state.stencilDepthPass===i||(this.state.stencilFail=e,this.state.stencilDepthFail=t,this.state.stencilDepthPass=i,this.gl.stencilOp(e,t,i))}activeTexture(e){this.state.activeTextureUnit!==e&&(this.state.activeTextureUnit=e,this.gl.activeTexture(this.gl.TEXTURE0+e))}bindFramebuffer({target:e=this.gl.FRAMEBUFFER,buffer:t=null}={}){this.state.framebuffer!==t&&(this.state.framebuffer=t,this.gl.bindFramebuffer(e,t))}getExtension(e,t,i){return t&&this.gl[t]?this.gl[t].bind(this.gl):(this.extensions[e]||(this.extensions[e]=this.gl.getExtension(e)),t?this.extensions[e]?this.extensions[e][i].bind(this.extensions[e]):null:this.extensions[e])}sortOpaque(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program.id!==t.program.id?e.program.id-t.program.id:e.zDepth!==t.zDepth?e.zDepth-t.zDepth:t.id-e.id}sortTransparent(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.zDepth!==t.zDepth?t.zDepth-e.zDepth:t.id-e.id}sortUI(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program.id!==t.program.id?e.program.id-t.program.id:t.id-e.id}getRenderList({scene:e,camera:t,frustumCull:i,sort:r}){let s=[];if(t&&i&&t.updateFrustum(),e.traverse(a=>{if(!a.visible)return!0;a.draw&&(i&&a.frustumCulled&&t&&!t.frustumIntersectsMesh(a)||s.push(a))}),r){const a=[],o=[],l=[];s.forEach(c=>{c.program.transparent?c.program.depthTest?o.push(c):l.push(c):a.push(c),c.zDepth=0,!(c.renderOrder!==0||!c.program.depthTest||!t)&&(c.worldMatrix.getTranslation(ss),ss.applyMatrix4(t.projectionViewMatrix),c.zDepth=ss.z)}),a.sort(this.sortOpaque),o.sort(this.sortTransparent),l.sort(this.sortUI),s=a.concat(o,l)}return s}render({scene:e,camera:t,target:i=null,update:r=!0,sort:s=!0,frustumCull:a=!0,clear:o}){i===null?(this.bindFramebuffer(),this.setViewport(this.width*this.dpr,this.height*this.dpr)):(this.bindFramebuffer(i),this.setViewport(i.width,i.height)),(o||this.autoClear&&o!==!1)&&(this.depth&&(!i||i.depth)&&(this.enable(this.gl.DEPTH_TEST),this.setDepthMask(!0)),(this.stencil||!i||i.stencil)&&(this.enable(this.gl.STENCIL_TEST),this.setStencilMask(255)),this.gl.clear((this.color?this.gl.COLOR_BUFFER_BIT:0)|(this.depth?this.gl.DEPTH_BUFFER_BIT:0)|(this.stencil?this.gl.STENCIL_BUFFER_BIT:0))),r&&e.updateMatrixWorld(),t&&t.updateMatrixWorld(),this.getRenderList({scene:e,camera:t,frustumCull:a,sort:s}).forEach(c=>{c.draw({camera:t})})}}function Tm(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function Am(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function wm(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t*t+i*i+r*r+s*s;return a>0&&(a=1/Math.sqrt(a)),n[0]=t*a,n[1]=i*a,n[2]=r*a,n[3]=s*a,n}function Rm(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function Cm(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Pm(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Ro(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1],c=t[2],u=t[3];return n[0]=i*u+a*o+r*c-s*l,n[1]=r*u+a*l+s*o-i*c,n[2]=s*u+a*c+i*l-r*o,n[3]=a*u-i*o-r*l-s*c,n}function Dm(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+a*o,n[1]=r*l+s*o,n[2]=s*l-r*o,n[3]=a*l-i*o,n}function Lm(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l-s*o,n[1]=r*l+a*o,n[2]=s*l+i*o,n[3]=a*l-r*o,n}function Im(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+r*o,n[1]=r*l-i*o,n[2]=s*l+a*o,n[3]=a*l-s*o,n}function Fm(n,e,t,i){let r=e[0],s=e[1],a=e[2],o=e[3],l=t[0],c=t[1],u=t[2],p=t[3],h,d,g,v,m;return d=r*l+s*c+a*u+o*p,d<0&&(d=-d,l=-l,c=-c,u=-u,p=-p),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),v=Math.sin((1-i)*h)/g,m=Math.sin(i*h)/g):(v=1-i,m=i),n[0]=v*r+m*l,n[1]=v*s+m*c,n[2]=v*a+m*u,n[3]=v*o+m*p,n}function Um(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t*t+i*i+r*r+s*s,o=a?1/a:0;return n[0]=-t*o,n[1]=-i*o,n[2]=-r*o,n[3]=s*o,n}function Nm(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n}function Om(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,a=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[a*3+a]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+a]-e[a*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[a]=(e[a*3+r]+e[r*3+a])*i}return n}function Bm(n,e,t="YXZ"){let i=Math.sin(e[0]*.5),r=Math.cos(e[0]*.5),s=Math.sin(e[1]*.5),a=Math.cos(e[1]*.5),o=Math.sin(e[2]*.5),l=Math.cos(e[2]*.5);return t==="XYZ"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l-i*s*o):t==="YXZ"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l+i*s*o):t==="ZXY"?(n[0]=i*a*l-r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l-i*s*o):t==="ZYX"?(n[0]=i*a*l-r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l+i*s*o):t==="YZX"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l-i*s*o):t==="XZY"&&(n[0]=i*a*l-r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l+i*s*o),n}const zm=Tm,Gm=Am,Vm=Rm,Hm=wm;class km extends Array{constructor(e=0,t=0,i=0,r=1){super(e,t,i,r),this.onChange=()=>{},this._target=this;const s=["0","1","2","3"];return new Proxy(this,{set(a,o){const l=Reflect.set(...arguments);return l&&s.includes(o)&&a.onChange(),l}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(e){this._target[0]=e,this.onChange()}set y(e){this._target[1]=e,this.onChange()}set z(e){this._target[2]=e,this.onChange()}set w(e){this._target[3]=e,this.onChange()}identity(){return Cm(this._target),this.onChange(),this}set(e,t,i,r){return e.length?this.copy(e):(Gm(this._target,e,t,i,r),this.onChange(),this)}rotateX(e){return Dm(this._target,this._target,e),this.onChange(),this}rotateY(e){return Lm(this._target,this._target,e),this.onChange(),this}rotateZ(e){return Im(this._target,this._target,e),this.onChange(),this}inverse(e=this._target){return Um(this._target,e),this.onChange(),this}conjugate(e=this._target){return Nm(this._target,e),this.onChange(),this}copy(e){return zm(this._target,e),this.onChange(),this}normalize(e=this._target){return Hm(this._target,e),this.onChange(),this}multiply(e,t){return t?Ro(this._target,e,t):Ro(this._target,this._target,e),this.onChange(),this}dot(e){return Vm(this._target,e)}fromMatrix3(e){return Om(this._target,e),this.onChange(),this}fromEuler(e,t){return Bm(this._target,e,e.order),t||this.onChange(),this}fromAxisAngle(e,t){return Pm(this._target,e,t),this.onChange(),this}slerp(e,t){return Fm(this._target,this._target,e,t),this.onChange(),this}fromArray(e,t=0){return this._target[0]=e[t],this._target[1]=e[t+1],this._target[2]=e[t+2],this._target[3]=e[t+3],this.onChange(),this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e[t+3]=this[3],e}}const Wm=1e-6;function Xm(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function qm(n,e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n[9]=u,n[10]=p,n[11]=h,n[12]=d,n[13]=g,n[14]=v,n[15]=m,n}function Ym(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function jm(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],p=e[9],h=e[10],d=e[11],g=e[12],v=e[13],m=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-p*g,y=u*m-h*g,G=u*f-d*g,w=p*m-h*v,F=p*f-d*v,N=h*f-d*m,L=S*N-b*F+E*w+R*G-A*y+C*x;return L?(L=1/L,n[0]=(o*N-l*F+c*w)*L,n[1]=(r*F-i*N-s*w)*L,n[2]=(v*C-m*A+f*R)*L,n[3]=(h*A-p*C-d*R)*L,n[4]=(l*G-a*N-c*y)*L,n[5]=(t*N-r*G+s*y)*L,n[6]=(m*E-g*C-f*b)*L,n[7]=(u*C-h*E+d*b)*L,n[8]=(a*F-o*G+c*x)*L,n[9]=(i*G-t*F-s*x)*L,n[10]=(g*A-v*E+f*S)*L,n[11]=(p*E-u*A-d*S)*L,n[12]=(o*y-a*w-l*x)*L,n[13]=(t*w-i*y+r*x)*L,n[14]=(v*b-g*R-m*S)*L,n[15]=(u*R-p*b+h*S)*L,n):null}function Ml(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],a=n[5],o=n[6],l=n[7],c=n[8],u=n[9],p=n[10],h=n[11],d=n[12],g=n[13],v=n[14],m=n[15],f=e*a-t*s,S=e*o-i*s,b=e*l-r*s,E=t*o-i*a,R=t*l-r*a,A=i*l-r*o,C=c*g-u*d,x=c*v-p*d,y=c*m-h*d,G=u*v-p*g,w=u*m-h*g,F=p*m-h*v;return f*F-S*w+b*G+E*y-R*x+A*C}function Co(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=e[9],d=e[10],g=e[11],v=e[12],m=e[13],f=e[14],S=e[15],b=t[0],E=t[1],R=t[2],A=t[3];return n[0]=b*i+E*o+R*p+A*v,n[1]=b*r+E*l+R*h+A*m,n[2]=b*s+E*c+R*d+A*f,n[3]=b*a+E*u+R*g+A*S,b=t[4],E=t[5],R=t[6],A=t[7],n[4]=b*i+E*o+R*p+A*v,n[5]=b*r+E*l+R*h+A*m,n[6]=b*s+E*c+R*d+A*f,n[7]=b*a+E*u+R*g+A*S,b=t[8],E=t[9],R=t[10],A=t[11],n[8]=b*i+E*o+R*p+A*v,n[9]=b*r+E*l+R*h+A*m,n[10]=b*s+E*c+R*d+A*f,n[11]=b*a+E*u+R*g+A*S,b=t[12],E=t[13],R=t[14],A=t[15],n[12]=b*i+E*o+R*p+A*v,n[13]=b*r+E*l+R*h+A*m,n[14]=b*s+E*c+R*d+A*f,n[15]=b*a+E*u+R*g+A*S,n}function $m(n,e,t){let i=t[0],r=t[1],s=t[2],a,o,l,c,u,p,h,d,g,v,m,f;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(a=e[0],o=e[1],l=e[2],c=e[3],u=e[4],p=e[5],h=e[6],d=e[7],g=e[8],v=e[9],m=e[10],f=e[11],n[0]=a,n[1]=o,n[2]=l,n[3]=c,n[4]=u,n[5]=p,n[6]=h,n[7]=d,n[8]=g,n[9]=v,n[10]=m,n[11]=f,n[12]=a*i+u*r+g*s+e[12],n[13]=o*i+p*r+v*s+e[13],n[14]=l*i+h*r+m*s+e[14],n[15]=c*i+d*r+f*s+e[15]),n}function Zm(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Km(n,e,t,i){let r=i[0],s=i[1],a=i[2],o=Math.hypot(r,s,a),l,c,u,p,h,d,g,v,m,f,S,b,E,R,A,C,x,y,G,w,F,N,L,B;return Math.abs(o)<Wm?null:(o=1/o,r*=o,s*=o,a*=o,l=Math.sin(t),c=Math.cos(t),u=1-c,p=e[0],h=e[1],d=e[2],g=e[3],v=e[4],m=e[5],f=e[6],S=e[7],b=e[8],E=e[9],R=e[10],A=e[11],C=r*r*u+c,x=s*r*u+a*l,y=a*r*u-s*l,G=r*s*u-a*l,w=s*s*u+c,F=a*s*u+r*l,N=r*a*u+s*l,L=s*a*u-r*l,B=a*a*u+c,n[0]=p*C+v*x+b*y,n[1]=h*C+m*x+E*y,n[2]=d*C+f*x+R*y,n[3]=g*C+S*x+A*y,n[4]=p*G+v*w+b*F,n[5]=h*G+m*w+E*F,n[6]=d*G+f*w+R*F,n[7]=g*G+S*w+A*F,n[8]=p*N+v*L+b*B,n[9]=h*N+m*L+E*B,n[10]=d*N+f*L+R*B,n[11]=g*N+S*L+A*B,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Jm(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function Sl(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],a=e[5],o=e[6],l=e[8],c=e[9],u=e[10];return n[0]=Math.hypot(t,i,r),n[1]=Math.hypot(s,a,o),n[2]=Math.hypot(l,c,u),n}function Qm(n){let e=n[0],t=n[1],i=n[2],r=n[4],s=n[5],a=n[6],o=n[8],l=n[9],c=n[10];const u=e*e+t*t+i*i,p=r*r+s*s+a*a,h=o*o+l*l+c*c;return Math.sqrt(Math.max(u,p,h))}const El=(function(){const n=[1,1,1];return function(e,t){let i=n;Sl(i,t);let r=1/i[0],s=1/i[1],a=1/i[2],o=t[0]*r,l=t[1]*s,c=t[2]*a,u=t[4]*r,p=t[5]*s,h=t[6]*a,d=t[8]*r,g=t[9]*s,v=t[10]*a,m=o+p+v,f=0;return m>0?(f=Math.sqrt(m+1)*2,e[3]=.25*f,e[0]=(h-g)/f,e[1]=(d-c)/f,e[2]=(l-u)/f):o>p&&o>v?(f=Math.sqrt(1+o-p-v)*2,e[3]=(h-g)/f,e[0]=.25*f,e[1]=(l+u)/f,e[2]=(d+c)/f):p>v?(f=Math.sqrt(1+p-o-v)*2,e[3]=(d-c)/f,e[0]=(l+u)/f,e[1]=.25*f,e[2]=(h+g)/f):(f=Math.sqrt(1+v-o-p)*2,e[3]=(l-u)/f,e[0]=(d+c)/f,e[1]=(h+g)/f,e[2]=.25*f),e}})();function eg(n,e,t,i){let r=Ti([n[0],n[1],n[2]]);const s=Ti([n[4],n[5],n[6]]),a=Ti([n[8],n[9],n[10]]);Ml(n)<0&&(r=-r),t[0]=n[12],t[1]=n[13],t[2]=n[14];const l=n.slice(),c=1/r,u=1/s,p=1/a;l[0]*=c,l[1]*=c,l[2]*=c,l[4]*=u,l[5]*=u,l[6]*=u,l[8]*=p,l[9]*=p,l[10]*=p,El(e,l),i[0]=r,i[1]=s,i[2]=a}function tg(n,e,t,i){const r=n,s=e[0],a=e[1],o=e[2],l=e[3],c=s+s,u=a+a,p=o+o,h=s*c,d=s*u,g=s*p,v=a*u,m=a*p,f=o*p,S=l*c,b=l*u,E=l*p,R=i[0],A=i[1],C=i[2];return r[0]=(1-(v+f))*R,r[1]=(d+E)*R,r[2]=(g-b)*R,r[3]=0,r[4]=(d-E)*A,r[5]=(1-(h+f))*A,r[6]=(m+S)*A,r[7]=0,r[8]=(g+b)*C,r[9]=(m-S)*C,r[10]=(1-(h+v))*C,r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function ng(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,u=i*a,p=i*o,h=r*a,d=r*o,g=r*l,v=s*a,m=s*o,f=s*l;return n[0]=1-p-g,n[1]=u+f,n[2]=h-m,n[3]=0,n[4]=u-f,n[5]=1-c-g,n[6]=d+v,n[7]=0,n[8]=h+m,n[9]=d-v,n[10]=1-c-p,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function ig(n,e,t,i,r){let s=1/Math.tan(e/2),a=1/(i-r);return n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=(r+i)*a,n[11]=-1,n[12]=0,n[13]=0,n[14]=2*r*i*a,n[15]=0,n}function rg(n,e,t,i,r,s,a){let o=1/(e-t),l=1/(i-r),c=1/(s-a);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*l,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*c,n[11]=0,n[12]=(e+t)*o,n[13]=(r+i)*l,n[14]=(a+s)*c,n[15]=1,n}function sg(n,e,t,i){let r=e[0],s=e[1],a=e[2],o=i[0],l=i[1],c=i[2],u=r-t[0],p=s-t[1],h=a-t[2],d=u*u+p*p+h*h;d===0?h=1:(d=1/Math.sqrt(d),u*=d,p*=d,h*=d);let g=l*h-c*p,v=c*u-o*h,m=o*p-l*u;return d=g*g+v*v+m*m,d===0&&(c?o+=1e-6:l?c+=1e-6:l+=1e-6,g=l*h-c*p,v=c*u-o*h,m=o*p-l*u,d=g*g+v*v+m*m),d=1/Math.sqrt(d),g*=d,v*=d,m*=d,n[0]=g,n[1]=v,n[2]=m,n[3]=0,n[4]=p*m-h*v,n[5]=h*g-u*m,n[6]=u*v-p*g,n[7]=0,n[8]=u,n[9]=p,n[10]=h,n[11]=0,n[12]=r,n[13]=s,n[14]=a,n[15]=1,n}function Po(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function Do(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function ag(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}class dr extends Array{constructor(e=1,t=0,i=0,r=0,s=0,a=1,o=0,l=0,c=0,u=0,p=1,h=0,d=0,g=0,v=0,m=1){return super(e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m),this}get x(){return this[12]}get y(){return this[13]}get z(){return this[14]}get w(){return this[15]}set x(e){this[12]=e}set y(e){this[13]=e}set z(e){this[14]=e}set w(e){this[15]=e}set(e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m){return e.length?this.copy(e):(qm(this,e,t,i,r,s,a,o,l,c,u,p,h,d,g,v,m),this)}translate(e,t=this){return $m(this,t,e),this}rotate(e,t,i=this){return Km(this,i,e,t),this}scale(e,t=this){return Zm(this,t,typeof e=="number"?[e,e,e]:e),this}add(e,t){return t?Po(this,e,t):Po(this,this,e),this}sub(e,t){return t?Do(this,e,t):Do(this,this,e),this}multiply(e,t){return e.length?t?Co(this,e,t):Co(this,this,e):ag(this,this,e),this}identity(){return Ym(this),this}copy(e){return Xm(this,e),this}fromPerspective({fov:e,aspect:t,near:i,far:r}={}){return ig(this,e,t,i,r),this}fromOrthogonal({left:e,right:t,bottom:i,top:r,near:s,far:a}){return rg(this,e,t,i,r,s,a),this}fromQuaternion(e){return ng(this,e),this}setPosition(e){return this.x=e[0],this.y=e[1],this.z=e[2],this}inverse(e=this){return jm(this,e),this}compose(e,t,i){return tg(this,e,t,i),this}decompose(e,t,i){return eg(this,e,t,i),this}getRotation(e){return El(e,this),this}getTranslation(e){return Jm(e,this),this}getScaling(e){return Sl(e,this),this}getMaxScaleOnAxis(){return Qm(this)}lookAt(e,t,i){return sg(this,e,t,i),this}determinant(){return Ml(this)}fromArray(e,t=0){return this[0]=e[t],this[1]=e[t+1],this[2]=e[t+2],this[3]=e[t+3],this[4]=e[t+4],this[5]=e[t+5],this[6]=e[t+6],this[7]=e[t+7],this[8]=e[t+8],this[9]=e[t+9],this[10]=e[t+10],this[11]=e[t+11],this[12]=e[t+12],this[13]=e[t+13],this[14]=e[t+14],this[15]=e[t+15],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e[t+3]=this[3],e[t+4]=this[4],e[t+5]=this[5],e[t+6]=this[6],e[t+7]=this[7],e[t+8]=this[8],e[t+9]=this[9],e[t+10]=this[10],e[t+11]=this[11],e[t+12]=this[12],e[t+13]=this[13],e[t+14]=this[14],e[t+15]=this[15],e}}function og(n,e,t="YXZ"){return t==="XYZ"?(n[1]=Math.asin(Math.min(Math.max(e[8],-1),1)),Math.abs(e[8])<.99999?(n[0]=Math.atan2(-e[9],e[10]),n[2]=Math.atan2(-e[4],e[0])):(n[0]=Math.atan2(e[6],e[5]),n[2]=0)):t==="YXZ"?(n[0]=Math.asin(-Math.min(Math.max(e[9],-1),1)),Math.abs(e[9])<.99999?(n[1]=Math.atan2(e[8],e[10]),n[2]=Math.atan2(e[1],e[5])):(n[1]=Math.atan2(-e[2],e[0]),n[2]=0)):t==="ZXY"?(n[0]=Math.asin(Math.min(Math.max(e[6],-1),1)),Math.abs(e[6])<.99999?(n[1]=Math.atan2(-e[2],e[10]),n[2]=Math.atan2(-e[4],e[5])):(n[1]=0,n[2]=Math.atan2(e[1],e[0]))):t==="ZYX"?(n[1]=Math.asin(-Math.min(Math.max(e[2],-1),1)),Math.abs(e[2])<.99999?(n[0]=Math.atan2(e[6],e[10]),n[2]=Math.atan2(e[1],e[0])):(n[0]=0,n[2]=Math.atan2(-e[4],e[5]))):t==="YZX"?(n[2]=Math.asin(Math.min(Math.max(e[1],-1),1)),Math.abs(e[1])<.99999?(n[0]=Math.atan2(-e[9],e[5]),n[1]=Math.atan2(-e[2],e[0])):(n[0]=0,n[1]=Math.atan2(e[8],e[10]))):t==="XZY"&&(n[2]=Math.asin(-Math.min(Math.max(e[4],-1),1)),Math.abs(e[4])<.99999?(n[0]=Math.atan2(e[6],e[5]),n[1]=Math.atan2(e[8],e[0])):(n[0]=Math.atan2(-e[9],e[10]),n[1]=0)),n}const Lo=new dr;class lg extends Array{constructor(e=0,t=e,i=e,r="YXZ"){super(e,t,i),this.order=r,this.onChange=()=>{},this._target=this;const s=["0","1","2"];return new Proxy(this,{set(a,o){const l=Reflect.set(...arguments);return l&&s.includes(o)&&a.onChange(),l}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(e){this._target[0]=e,this.onChange()}set y(e){this._target[1]=e,this.onChange()}set z(e){this._target[2]=e,this.onChange()}set(e,t=e,i=e){return e.length?this.copy(e):(this._target[0]=e,this._target[1]=t,this._target[2]=i,this.onChange(),this)}copy(e){return this._target[0]=e[0],this._target[1]=e[1],this._target[2]=e[2],this.onChange(),this}reorder(e){return this._target.order=e,this.onChange(),this}fromRotationMatrix(e,t=this.order){return og(this._target,e,t),this.onChange(),this}fromQuaternion(e,t=this.order,i){return Lo.fromQuaternion(e),this._target.fromRotationMatrix(Lo,t),i||this.onChange(),this}fromArray(e,t=0){return this._target[0]=e[t],this._target[1]=e[t+1],this._target[2]=e[t+2],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e}}class cg{constructor(){this.parent=null,this.children=[],this.visible=!0,this.matrix=new dr,this.worldMatrix=new dr,this.matrixAutoUpdate=!0,this.worldMatrixNeedsUpdate=!1,this.position=new Gt,this.quaternion=new km,this.scale=new Gt(1),this.rotation=new lg,this.up=new Gt(0,1,0),this.rotation._target.onChange=()=>this.quaternion.fromEuler(this.rotation,!0),this.quaternion._target.onChange=()=>this.rotation.fromQuaternion(this.quaternion,void 0,!0)}setParent(e,t=!0){this.parent&&e!==this.parent&&this.parent.removeChild(this,!1),this.parent=e,t&&e&&e.addChild(this,!1)}addChild(e,t=!0){~this.children.indexOf(e)||this.children.push(e),t&&e.setParent(this,!1)}removeChild(e,t=!0){~this.children.indexOf(e)&&this.children.splice(this.children.indexOf(e),1),t&&e.setParent(null,!1)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.worldMatrixNeedsUpdate||e)&&(this.parent===null?this.worldMatrix.copy(this.matrix):this.worldMatrix.multiply(this.parent.worldMatrix,this.matrix),this.worldMatrixNeedsUpdate=!1,e=!0);for(let t=0,i=this.children.length;t<i;t++)this.children[t].updateMatrixWorld(e)}updateMatrix(){this.matrix.compose(this.quaternion,this.position,this.scale),this.worldMatrixNeedsUpdate=!0}traverse(e){if(!e(this))for(let t=0,i=this.children.length;t<i;t++)this.children[t].traverse(e)}decompose(){this.matrix.decompose(this.quaternion._target,this.position,this.scale),this.rotation.fromQuaternion(this.quaternion)}lookAt(e,t=!1){t?this.matrix.lookAt(this.position,e,this.up):this.matrix.lookAt(e,this.position,this.up),this.matrix.getRotation(this.quaternion._target),this.rotation.fromQuaternion(this.quaternion)}}function hg(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n}function ug(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,u=i*a,p=i*o,h=r*a,d=r*o,g=r*l,v=s*a,m=s*o,f=s*l;return n[0]=1-p-g,n[3]=u-f,n[6]=h+m,n[1]=u+f,n[4]=1-c-g,n[7]=d-v,n[2]=h-m,n[5]=d+v,n[8]=1-c-p,n}function fg(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function dg(n,e,t,i,r,s,a,o,l,c){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n}function pg(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n}function mg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],p=u*a-o*c,h=-u*s+o*l,d=c*s-a*l,g=t*p+i*h+r*d;return g?(g=1/g,n[0]=p*g,n[1]=(-u*i+r*c)*g,n[2]=(o*i-r*a)*g,n[3]=h*g,n[4]=(u*t-r*l)*g,n[5]=(-o*t+r*s)*g,n[6]=d*g,n[7]=(-c*t+i*l)*g,n[8]=(a*t-i*s)*g,n):null}function Io(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=t[0],d=t[1],g=t[2],v=t[3],m=t[4],f=t[5],S=t[6],b=t[7],E=t[8];return n[0]=h*i+d*a+g*c,n[1]=h*r+d*o+g*u,n[2]=h*s+d*l+g*p,n[3]=v*i+m*a+f*c,n[4]=v*r+m*o+f*u,n[5]=v*s+m*l+f*p,n[6]=S*i+b*a+E*c,n[7]=S*r+b*o+E*u,n[8]=S*s+b*l+E*p,n}function gg(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=t[0],d=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=o,n[5]=l,n[6]=h*i+d*a+c,n[7]=h*r+d*o+u,n[8]=h*s+d*l+p,n}function _g(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],p=e[8],h=Math.sin(t),d=Math.cos(t);return n[0]=d*i+h*a,n[1]=d*r+h*o,n[2]=d*s+h*l,n[3]=d*a-h*i,n[4]=d*o-h*r,n[5]=d*l-h*s,n[6]=c,n[7]=u,n[8]=p,n}function xg(n,e,t){let i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function vg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],p=e[9],h=e[10],d=e[11],g=e[12],v=e[13],m=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-p*g,y=u*m-h*g,G=u*f-d*g,w=p*m-h*v,F=p*f-d*v,N=h*f-d*m,L=S*N-b*F+E*w+R*G-A*y+C*x;return L?(L=1/L,n[0]=(o*N-l*F+c*w)*L,n[1]=(l*G-a*N-c*y)*L,n[2]=(a*F-o*G+c*x)*L,n[3]=(r*F-i*N-s*w)*L,n[4]=(t*N-r*G+s*y)*L,n[5]=(i*G-t*F-s*x)*L,n[6]=(v*C-m*A+f*R)*L,n[7]=(m*E-g*C-f*b)*L,n[8]=(g*A-v*E+f*S)*L,n):null}class Mg extends Array{constructor(e=1,t=0,i=0,r=0,s=1,a=0,o=0,l=0,c=1){return super(e,t,i,r,s,a,o,l,c),this}set(e,t,i,r,s,a,o,l,c){return e.length?this.copy(e):(dg(this,e,t,i,r,s,a,o,l,c),this)}translate(e,t=this){return gg(this,t,e),this}rotate(e,t=this){return _g(this,t,e),this}scale(e,t=this){return xg(this,t,e),this}multiply(e,t){return t?Io(this,e,t):Io(this,this,e),this}identity(){return pg(this),this}copy(e){return fg(this,e),this}fromMatrix4(e){return hg(this,e),this}fromQuaternion(e){return ug(this,e),this}fromBasis(e,t,i){return this.set(e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]),this}inverse(e=this){return mg(this,e),this}getNormalMatrix(e){return vg(this,e),this}}let Sg=0;class Eg extends cg{constructor(e,{geometry:t,program:i,mode:r=e.TRIANGLES,frustumCulled:s=!0,renderOrder:a=0}={}){super(),e.canvas||console.error("gl not passed as first argument to Mesh"),this.gl=e,this.id=Sg++,this.geometry=t,this.program=i,this.mode=r,this.frustumCulled=s,this.renderOrder=a,this.modelViewMatrix=new dr,this.normalMatrix=new Mg,this.beforeRenderCallbacks=[],this.afterRenderCallbacks=[]}onBeforeRender(e){return this.beforeRenderCallbacks.push(e),this}onAfterRender(e){return this.afterRenderCallbacks.push(e),this}draw({camera:e}={}){e&&(this.program.uniforms.modelMatrix||Object.assign(this.program.uniforms,{modelMatrix:{value:null},viewMatrix:{value:null},modelViewMatrix:{value:null},normalMatrix:{value:null},projectionMatrix:{value:null},cameraPosition:{value:null}}),this.program.uniforms.projectionMatrix.value=e.projectionMatrix,this.program.uniforms.cameraPosition.value=e.worldPosition,this.program.uniforms.viewMatrix.value=e.viewMatrix,this.modelViewMatrix.multiply(e.viewMatrix,this.worldMatrix),this.normalMatrix.getNormalMatrix(this.modelViewMatrix),this.program.uniforms.modelMatrix.value=this.worldMatrix,this.program.uniforms.modelViewMatrix.value=this.modelViewMatrix,this.program.uniforms.normalMatrix.value=this.normalMatrix),this.beforeRenderCallbacks.forEach(i=>i&&i({mesh:this,camera:e}));let t=this.program.cullFace&&this.worldMatrix.determinant()<0;this.program.use({flipFaces:t}),this.geometry.draw({mode:this.mode,program:this.program}),this.afterRenderCallbacks.forEach(i=>i&&i({mesh:this,camera:e}))}}class yg extends _m{constructor(e,{attributes:t={}}={}){Object.assign(t,{position:{size:2,data:new Float32Array([-1,-1,3,-1,-1,3])},uv:{size:2,data:new Float32Array([0,0,2,0,0,2])}}),super(e,t)}}const Fo=n=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?[parseInt(e[1],16)/255,parseInt(e[2],16)/255,parseInt(e[3],16)/255]:[1,1,1]},Uo=(n,e,t)=>{switch(n){case"top-left":return{anchor:[0,-.2*t],dir:[0,1]};case"top-right":return{anchor:[e,-.2*t],dir:[0,1]};case"left":return{anchor:[-.2*e,.5*t],dir:[1,0]};case"right":return{anchor:[(1+.2)*e,.5*t],dir:[-1,0]};case"bottom-left":return{anchor:[0,(1+.2)*t],dir:[0,-1]};case"bottom-center":return{anchor:[.5*e,(1+.2)*t],dir:[0,-1]};case"bottom-right":return{anchor:[e,(1+.2)*t],dir:[0,-1]};default:return{anchor:[.5*e,-.2*t],dir:[0,1]}}},bg=`
4258
+ `)}function Sm(n){const e=n.length,t=n[0].length;if(t===void 0)return n;const i=e*t;let r=To[i];r||(To[i]=r=new Float32Array(i));for(let s=0;s<e;s++)r.set(n[s],s*t);return r}function Em(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function ym(n,e){for(let t=0,i=n.length;t<i;t++)n[t]=e[t]}let rs=0;function wo(n){rs>100||(console.warn(n),rs++,rs>100&&console.warn("More than 100 program warnings - stopping logs."))}const ss=new Gt;let bm=1;class Tm{constructor({canvas:e=document.createElement("canvas"),width:t=300,height:i=150,dpr:r=1,alpha:s=!1,depth:a=!0,stencil:o=!1,antialias:l=!1,premultipliedAlpha:c=!1,preserveDrawingBuffer:u=!1,powerPreference:m="default",autoClear:h=!0,webgl:p=2}={}){const g={alpha:s,depth:a,stencil:o,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:m};this.dpr=r,this.alpha=s,this.color=!0,this.depth=a,this.stencil=o,this.premultipliedAlpha=c,this.autoClear=h,this.id=bm++,p===2&&(this.gl=e.getContext("webgl2",g)),this.isWebgl2=!!this.gl,this.gl||(this.gl=e.getContext("webgl",g)),this.gl||console.error("unable to create webgl context"),this.gl.renderer=this,this.setSize(t,i),this.state={},this.state.blendFunc={src:this.gl.ONE,dst:this.gl.ZERO},this.state.blendEquation={modeRGB:this.gl.FUNC_ADD},this.state.cullFace=!1,this.state.frontFace=this.gl.CCW,this.state.depthMask=!0,this.state.depthFunc=this.gl.LEQUAL,this.state.premultiplyAlpha=!1,this.state.flipY=!1,this.state.unpackAlignment=4,this.state.framebuffer=null,this.state.viewport={x:0,y:0,width:null,height:null},this.state.textureUnits=[],this.state.activeTextureUnit=0,this.state.boundBuffer=null,this.state.uniformLocations=new Map,this.state.currentProgram=null,this.extensions={},this.isWebgl2?(this.getExtension("EXT_color_buffer_float"),this.getExtension("OES_texture_float_linear")):(this.getExtension("OES_texture_float"),this.getExtension("OES_texture_float_linear"),this.getExtension("OES_texture_half_float"),this.getExtension("OES_texture_half_float_linear"),this.getExtension("OES_element_index_uint"),this.getExtension("OES_standard_derivatives"),this.getExtension("EXT_sRGB"),this.getExtension("WEBGL_depth_texture"),this.getExtension("WEBGL_draw_buffers")),this.getExtension("WEBGL_compressed_texture_astc"),this.getExtension("EXT_texture_compression_bptc"),this.getExtension("WEBGL_compressed_texture_s3tc"),this.getExtension("WEBGL_compressed_texture_etc1"),this.getExtension("WEBGL_compressed_texture_pvrtc"),this.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this.vertexAttribDivisor=this.getExtension("ANGLE_instanced_arrays","vertexAttribDivisor","vertexAttribDivisorANGLE"),this.drawArraysInstanced=this.getExtension("ANGLE_instanced_arrays","drawArraysInstanced","drawArraysInstancedANGLE"),this.drawElementsInstanced=this.getExtension("ANGLE_instanced_arrays","drawElementsInstanced","drawElementsInstancedANGLE"),this.createVertexArray=this.getExtension("OES_vertex_array_object","createVertexArray","createVertexArrayOES"),this.bindVertexArray=this.getExtension("OES_vertex_array_object","bindVertexArray","bindVertexArrayOES"),this.deleteVertexArray=this.getExtension("OES_vertex_array_object","deleteVertexArray","deleteVertexArrayOES"),this.drawBuffers=this.getExtension("WEBGL_draw_buffers","drawBuffers","drawBuffersWEBGL"),this.parameters={},this.parameters.maxTextureUnits=this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this.parameters.maxAnisotropy=this.getExtension("EXT_texture_filter_anisotropic")?this.gl.getParameter(this.getExtension("EXT_texture_filter_anisotropic").MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}setSize(e,t){this.width=e,this.height=t,this.gl.canvas.width=e*this.dpr,this.gl.canvas.height=t*this.dpr,this.gl.canvas.style&&Object.assign(this.gl.canvas.style,{width:e+"px",height:t+"px"})}setViewport(e,t,i=0,r=0){this.state.viewport.width===e&&this.state.viewport.height===t||(this.state.viewport.width=e,this.state.viewport.height=t,this.state.viewport.x=i,this.state.viewport.y=r,this.gl.viewport(i,r,e,t))}setScissor(e,t,i=0,r=0){this.gl.scissor(i,r,e,t)}enable(e){this.state[e]!==!0&&(this.gl.enable(e),this.state[e]=!0)}disable(e){this.state[e]!==!1&&(this.gl.disable(e),this.state[e]=!1)}setBlendFunc(e,t,i,r){this.state.blendFunc.src===e&&this.state.blendFunc.dst===t&&this.state.blendFunc.srcAlpha===i&&this.state.blendFunc.dstAlpha===r||(this.state.blendFunc.src=e,this.state.blendFunc.dst=t,this.state.blendFunc.srcAlpha=i,this.state.blendFunc.dstAlpha=r,i!==void 0?this.gl.blendFuncSeparate(e,t,i,r):this.gl.blendFunc(e,t))}setBlendEquation(e,t){e=e||this.gl.FUNC_ADD,!(this.state.blendEquation.modeRGB===e&&this.state.blendEquation.modeAlpha===t)&&(this.state.blendEquation.modeRGB=e,this.state.blendEquation.modeAlpha=t,t!==void 0?this.gl.blendEquationSeparate(e,t):this.gl.blendEquation(e))}setCullFace(e){this.state.cullFace!==e&&(this.state.cullFace=e,this.gl.cullFace(e))}setFrontFace(e){this.state.frontFace!==e&&(this.state.frontFace=e,this.gl.frontFace(e))}setDepthMask(e){this.state.depthMask!==e&&(this.state.depthMask=e,this.gl.depthMask(e))}setDepthFunc(e){this.state.depthFunc!==e&&(this.state.depthFunc=e,this.gl.depthFunc(e))}setStencilMask(e){this.state.stencilMask!==e&&(this.state.stencilMask=e,this.gl.stencilMask(e))}setStencilFunc(e,t,i){this.state.stencilFunc===e&&this.state.stencilRef===t&&this.state.stencilFuncMask===i||(this.state.stencilFunc=e||this.gl.ALWAYS,this.state.stencilRef=t||0,this.state.stencilFuncMask=i||0,this.gl.stencilFunc(e||this.gl.ALWAYS,t||0,i||0))}setStencilOp(e,t,i){this.state.stencilFail===e&&this.state.stencilDepthFail===t&&this.state.stencilDepthPass===i||(this.state.stencilFail=e,this.state.stencilDepthFail=t,this.state.stencilDepthPass=i,this.gl.stencilOp(e,t,i))}activeTexture(e){this.state.activeTextureUnit!==e&&(this.state.activeTextureUnit=e,this.gl.activeTexture(this.gl.TEXTURE0+e))}bindFramebuffer({target:e=this.gl.FRAMEBUFFER,buffer:t=null}={}){this.state.framebuffer!==t&&(this.state.framebuffer=t,this.gl.bindFramebuffer(e,t))}getExtension(e,t,i){return t&&this.gl[t]?this.gl[t].bind(this.gl):(this.extensions[e]||(this.extensions[e]=this.gl.getExtension(e)),t?this.extensions[e]?this.extensions[e][i].bind(this.extensions[e]):null:this.extensions[e])}sortOpaque(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program.id!==t.program.id?e.program.id-t.program.id:e.zDepth!==t.zDepth?e.zDepth-t.zDepth:t.id-e.id}sortTransparent(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.zDepth!==t.zDepth?t.zDepth-e.zDepth:t.id-e.id}sortUI(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program.id!==t.program.id?e.program.id-t.program.id:t.id-e.id}getRenderList({scene:e,camera:t,frustumCull:i,sort:r}){let s=[];if(t&&i&&t.updateFrustum(),e.traverse(a=>{if(!a.visible)return!0;a.draw&&(i&&a.frustumCulled&&t&&!t.frustumIntersectsMesh(a)||s.push(a))}),r){const a=[],o=[],l=[];s.forEach(c=>{c.program.transparent?c.program.depthTest?o.push(c):l.push(c):a.push(c),c.zDepth=0,!(c.renderOrder!==0||!c.program.depthTest||!t)&&(c.worldMatrix.getTranslation(ss),ss.applyMatrix4(t.projectionViewMatrix),c.zDepth=ss.z)}),a.sort(this.sortOpaque),o.sort(this.sortTransparent),l.sort(this.sortUI),s=a.concat(o,l)}return s}render({scene:e,camera:t,target:i=null,update:r=!0,sort:s=!0,frustumCull:a=!0,clear:o}){i===null?(this.bindFramebuffer(),this.setViewport(this.width*this.dpr,this.height*this.dpr)):(this.bindFramebuffer(i),this.setViewport(i.width,i.height)),(o||this.autoClear&&o!==!1)&&(this.depth&&(!i||i.depth)&&(this.enable(this.gl.DEPTH_TEST),this.setDepthMask(!0)),(this.stencil||!i||i.stencil)&&(this.enable(this.gl.STENCIL_TEST),this.setStencilMask(255)),this.gl.clear((this.color?this.gl.COLOR_BUFFER_BIT:0)|(this.depth?this.gl.DEPTH_BUFFER_BIT:0)|(this.stencil?this.gl.STENCIL_BUFFER_BIT:0))),r&&e.updateMatrixWorld(),t&&t.updateMatrixWorld(),this.getRenderList({scene:e,camera:t,frustumCull:a,sort:s}).forEach(c=>{c.draw({camera:t})})}}function Am(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n}function wm(n,e,t,i,r){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n}function Rm(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t*t+i*i+r*r+s*s;return a>0&&(a=1/Math.sqrt(a)),n[0]=t*a,n[1]=i*a,n[2]=r*a,n[3]=s*a,n}function Cm(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function Pm(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Dm(n,e,t){t=t*.5;let i=Math.sin(t);return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=Math.cos(t),n}function Ro(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=t[0],l=t[1],c=t[2],u=t[3];return n[0]=i*u+a*o+r*c-s*l,n[1]=r*u+a*l+s*o-i*c,n[2]=s*u+a*c+i*l-r*o,n[3]=a*u-i*o-r*l-s*c,n}function Lm(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+a*o,n[1]=r*l+s*o,n[2]=s*l-r*o,n[3]=a*l-i*o,n}function Im(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l-s*o,n[1]=r*l+a*o,n[2]=s*l+i*o,n[3]=a*l-r*o,n}function Fm(n,e,t){t*=.5;let i=e[0],r=e[1],s=e[2],a=e[3],o=Math.sin(t),l=Math.cos(t);return n[0]=i*l+r*o,n[1]=r*l-i*o,n[2]=s*l+a*o,n[3]=a*l-s*o,n}function Um(n,e,t,i){let r=e[0],s=e[1],a=e[2],o=e[3],l=t[0],c=t[1],u=t[2],m=t[3],h,p,g,v,d;return p=r*l+s*c+a*u+o*m,p<0&&(p=-p,l=-l,c=-c,u=-u,m=-m),1-p>1e-6?(h=Math.acos(p),g=Math.sin(h),v=Math.sin((1-i)*h)/g,d=Math.sin(i*h)/g):(v=1-i,d=i),n[0]=v*r+d*l,n[1]=v*s+d*c,n[2]=v*a+d*u,n[3]=v*o+d*m,n}function Nm(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t*t+i*i+r*r+s*s,o=a?1/a:0;return n[0]=-t*o,n[1]=-i*o,n[2]=-r*o,n[3]=s*o,n}function Om(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n}function Bm(n,e){let t=e[0]+e[4]+e[8],i;if(t>0)i=Math.sqrt(t+1),n[3]=.5*i,i=.5/i,n[0]=(e[5]-e[7])*i,n[1]=(e[6]-e[2])*i,n[2]=(e[1]-e[3])*i;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);let s=(r+1)%3,a=(r+2)%3;i=Math.sqrt(e[r*3+r]-e[s*3+s]-e[a*3+a]+1),n[r]=.5*i,i=.5/i,n[3]=(e[s*3+a]-e[a*3+s])*i,n[s]=(e[s*3+r]+e[r*3+s])*i,n[a]=(e[a*3+r]+e[r*3+a])*i}return n}function zm(n,e,t="YXZ"){let i=Math.sin(e[0]*.5),r=Math.cos(e[0]*.5),s=Math.sin(e[1]*.5),a=Math.cos(e[1]*.5),o=Math.sin(e[2]*.5),l=Math.cos(e[2]*.5);return t==="XYZ"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l-i*s*o):t==="YXZ"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l+i*s*o):t==="ZXY"?(n[0]=i*a*l-r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l-i*s*o):t==="ZYX"?(n[0]=i*a*l-r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l+i*s*o):t==="YZX"?(n[0]=i*a*l+r*s*o,n[1]=r*s*l+i*a*o,n[2]=r*a*o-i*s*l,n[3]=r*a*l-i*s*o):t==="XZY"&&(n[0]=i*a*l-r*s*o,n[1]=r*s*l-i*a*o,n[2]=r*a*o+i*s*l,n[3]=r*a*l+i*s*o),n}const Gm=Am,Vm=wm,Hm=Cm,km=Rm;class Wm extends Array{constructor(e=0,t=0,i=0,r=1){super(e,t,i,r),this.onChange=()=>{},this._target=this;const s=["0","1","2","3"];return new Proxy(this,{set(a,o){const l=Reflect.set(...arguments);return l&&s.includes(o)&&a.onChange(),l}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(e){this._target[0]=e,this.onChange()}set y(e){this._target[1]=e,this.onChange()}set z(e){this._target[2]=e,this.onChange()}set w(e){this._target[3]=e,this.onChange()}identity(){return Pm(this._target),this.onChange(),this}set(e,t,i,r){return e.length?this.copy(e):(Vm(this._target,e,t,i,r),this.onChange(),this)}rotateX(e){return Lm(this._target,this._target,e),this.onChange(),this}rotateY(e){return Im(this._target,this._target,e),this.onChange(),this}rotateZ(e){return Fm(this._target,this._target,e),this.onChange(),this}inverse(e=this._target){return Nm(this._target,e),this.onChange(),this}conjugate(e=this._target){return Om(this._target,e),this.onChange(),this}copy(e){return Gm(this._target,e),this.onChange(),this}normalize(e=this._target){return km(this._target,e),this.onChange(),this}multiply(e,t){return t?Ro(this._target,e,t):Ro(this._target,this._target,e),this.onChange(),this}dot(e){return Hm(this._target,e)}fromMatrix3(e){return Bm(this._target,e),this.onChange(),this}fromEuler(e,t){return zm(this._target,e,e.order),t||this.onChange(),this}fromAxisAngle(e,t){return Dm(this._target,e,t),this.onChange(),this}slerp(e,t){return Um(this._target,this._target,e,t),this.onChange(),this}fromArray(e,t=0){return this._target[0]=e[t],this._target[1]=e[t+1],this._target[2]=e[t+2],this._target[3]=e[t+3],this.onChange(),this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e[t+3]=this[3],e}}const Xm=1e-6;function qm(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Ym(n,e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n[9]=u,n[10]=m,n[11]=h,n[12]=p,n[13]=g,n[14]=v,n[15]=d,n}function jm(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function $m(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],m=e[9],h=e[10],p=e[11],g=e[12],v=e[13],d=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-m*g,y=u*d-h*g,G=u*f-p*g,w=m*d-h*v,F=m*f-p*v,N=h*f-p*d,L=S*N-b*F+E*w+R*G-A*y+C*x;return L?(L=1/L,n[0]=(o*N-l*F+c*w)*L,n[1]=(r*F-i*N-s*w)*L,n[2]=(v*C-d*A+f*R)*L,n[3]=(h*A-m*C-p*R)*L,n[4]=(l*G-a*N-c*y)*L,n[5]=(t*N-r*G+s*y)*L,n[6]=(d*E-g*C-f*b)*L,n[7]=(u*C-h*E+p*b)*L,n[8]=(a*F-o*G+c*x)*L,n[9]=(i*G-t*F-s*x)*L,n[10]=(g*A-v*E+f*S)*L,n[11]=(m*E-u*A-p*S)*L,n[12]=(o*y-a*w-l*x)*L,n[13]=(t*w-i*y+r*x)*L,n[14]=(v*b-g*R-d*S)*L,n[15]=(u*R-m*b+h*S)*L,n):null}function Ml(n){let e=n[0],t=n[1],i=n[2],r=n[3],s=n[4],a=n[5],o=n[6],l=n[7],c=n[8],u=n[9],m=n[10],h=n[11],p=n[12],g=n[13],v=n[14],d=n[15],f=e*a-t*s,S=e*o-i*s,b=e*l-r*s,E=t*o-i*a,R=t*l-r*a,A=i*l-r*o,C=c*g-u*p,x=c*v-m*p,y=c*d-h*p,G=u*v-m*g,w=u*d-h*g,F=m*d-h*v;return f*F-S*w+b*G+E*y-R*x+A*C}function Co(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],m=e[8],h=e[9],p=e[10],g=e[11],v=e[12],d=e[13],f=e[14],S=e[15],b=t[0],E=t[1],R=t[2],A=t[3];return n[0]=b*i+E*o+R*m+A*v,n[1]=b*r+E*l+R*h+A*d,n[2]=b*s+E*c+R*p+A*f,n[3]=b*a+E*u+R*g+A*S,b=t[4],E=t[5],R=t[6],A=t[7],n[4]=b*i+E*o+R*m+A*v,n[5]=b*r+E*l+R*h+A*d,n[6]=b*s+E*c+R*p+A*f,n[7]=b*a+E*u+R*g+A*S,b=t[8],E=t[9],R=t[10],A=t[11],n[8]=b*i+E*o+R*m+A*v,n[9]=b*r+E*l+R*h+A*d,n[10]=b*s+E*c+R*p+A*f,n[11]=b*a+E*u+R*g+A*S,b=t[12],E=t[13],R=t[14],A=t[15],n[12]=b*i+E*o+R*m+A*v,n[13]=b*r+E*l+R*h+A*d,n[14]=b*s+E*c+R*p+A*f,n[15]=b*a+E*u+R*g+A*S,n}function Zm(n,e,t){let i=t[0],r=t[1],s=t[2],a,o,l,c,u,m,h,p,g,v,d,f;return e===n?(n[12]=e[0]*i+e[4]*r+e[8]*s+e[12],n[13]=e[1]*i+e[5]*r+e[9]*s+e[13],n[14]=e[2]*i+e[6]*r+e[10]*s+e[14],n[15]=e[3]*i+e[7]*r+e[11]*s+e[15]):(a=e[0],o=e[1],l=e[2],c=e[3],u=e[4],m=e[5],h=e[6],p=e[7],g=e[8],v=e[9],d=e[10],f=e[11],n[0]=a,n[1]=o,n[2]=l,n[3]=c,n[4]=u,n[5]=m,n[6]=h,n[7]=p,n[8]=g,n[9]=v,n[10]=d,n[11]=f,n[12]=a*i+u*r+g*s+e[12],n[13]=o*i+m*r+v*s+e[13],n[14]=l*i+h*r+d*s+e[14],n[15]=c*i+p*r+f*s+e[15]),n}function Km(n,e,t){let i=t[0],r=t[1],s=t[2];return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=e[7]*r,n[8]=e[8]*s,n[9]=e[9]*s,n[10]=e[10]*s,n[11]=e[11]*s,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Jm(n,e,t,i){let r=i[0],s=i[1],a=i[2],o=Math.hypot(r,s,a),l,c,u,m,h,p,g,v,d,f,S,b,E,R,A,C,x,y,G,w,F,N,L,B;return Math.abs(o)<Xm?null:(o=1/o,r*=o,s*=o,a*=o,l=Math.sin(t),c=Math.cos(t),u=1-c,m=e[0],h=e[1],p=e[2],g=e[3],v=e[4],d=e[5],f=e[6],S=e[7],b=e[8],E=e[9],R=e[10],A=e[11],C=r*r*u+c,x=s*r*u+a*l,y=a*r*u-s*l,G=r*s*u-a*l,w=s*s*u+c,F=a*s*u+r*l,N=r*a*u+s*l,L=s*a*u-r*l,B=a*a*u+c,n[0]=m*C+v*x+b*y,n[1]=h*C+d*x+E*y,n[2]=p*C+f*x+R*y,n[3]=g*C+S*x+A*y,n[4]=m*G+v*w+b*F,n[5]=h*G+d*w+E*F,n[6]=p*G+f*w+R*F,n[7]=g*G+S*w+A*F,n[8]=m*N+v*L+b*B,n[9]=h*N+d*L+E*B,n[10]=p*N+f*L+R*B,n[11]=g*N+S*L+A*B,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Qm(n,e){return n[0]=e[12],n[1]=e[13],n[2]=e[14],n}function Sl(n,e){let t=e[0],i=e[1],r=e[2],s=e[4],a=e[5],o=e[6],l=e[8],c=e[9],u=e[10];return n[0]=Math.hypot(t,i,r),n[1]=Math.hypot(s,a,o),n[2]=Math.hypot(l,c,u),n}function eg(n){let e=n[0],t=n[1],i=n[2],r=n[4],s=n[5],a=n[6],o=n[8],l=n[9],c=n[10];const u=e*e+t*t+i*i,m=r*r+s*s+a*a,h=o*o+l*l+c*c;return Math.sqrt(Math.max(u,m,h))}const El=(function(){const n=[1,1,1];return function(e,t){let i=n;Sl(i,t);let r=1/i[0],s=1/i[1],a=1/i[2],o=t[0]*r,l=t[1]*s,c=t[2]*a,u=t[4]*r,m=t[5]*s,h=t[6]*a,p=t[8]*r,g=t[9]*s,v=t[10]*a,d=o+m+v,f=0;return d>0?(f=Math.sqrt(d+1)*2,e[3]=.25*f,e[0]=(h-g)/f,e[1]=(p-c)/f,e[2]=(l-u)/f):o>m&&o>v?(f=Math.sqrt(1+o-m-v)*2,e[3]=(h-g)/f,e[0]=.25*f,e[1]=(l+u)/f,e[2]=(p+c)/f):m>v?(f=Math.sqrt(1+m-o-v)*2,e[3]=(p-c)/f,e[0]=(l+u)/f,e[1]=.25*f,e[2]=(h+g)/f):(f=Math.sqrt(1+v-o-m)*2,e[3]=(l-u)/f,e[0]=(p+c)/f,e[1]=(h+g)/f,e[2]=.25*f),e}})();function tg(n,e,t,i){let r=Ai([n[0],n[1],n[2]]);const s=Ai([n[4],n[5],n[6]]),a=Ai([n[8],n[9],n[10]]);Ml(n)<0&&(r=-r),t[0]=n[12],t[1]=n[13],t[2]=n[14];const l=n.slice(),c=1/r,u=1/s,m=1/a;l[0]*=c,l[1]*=c,l[2]*=c,l[4]*=u,l[5]*=u,l[6]*=u,l[8]*=m,l[9]*=m,l[10]*=m,El(e,l),i[0]=r,i[1]=s,i[2]=a}function ng(n,e,t,i){const r=n,s=e[0],a=e[1],o=e[2],l=e[3],c=s+s,u=a+a,m=o+o,h=s*c,p=s*u,g=s*m,v=a*u,d=a*m,f=o*m,S=l*c,b=l*u,E=l*m,R=i[0],A=i[1],C=i[2];return r[0]=(1-(v+f))*R,r[1]=(p+E)*R,r[2]=(g-b)*R,r[3]=0,r[4]=(p-E)*A,r[5]=(1-(h+f))*A,r[6]=(d+S)*A,r[7]=0,r[8]=(g+b)*C,r[9]=(d-S)*C,r[10]=(1-(h+v))*C,r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function ig(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,u=i*a,m=i*o,h=r*a,p=r*o,g=r*l,v=s*a,d=s*o,f=s*l;return n[0]=1-m-g,n[1]=u+f,n[2]=h-d,n[3]=0,n[4]=u-f,n[5]=1-c-g,n[6]=p+v,n[7]=0,n[8]=h+d,n[9]=p-v,n[10]=1-c-m,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function rg(n,e,t,i,r){let s=1/Math.tan(e/2),a=1/(i-r);return n[0]=s/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=(r+i)*a,n[11]=-1,n[12]=0,n[13]=0,n[14]=2*r*i*a,n[15]=0,n}function sg(n,e,t,i,r,s,a){let o=1/(e-t),l=1/(i-r),c=1/(s-a);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*l,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*c,n[11]=0,n[12]=(e+t)*o,n[13]=(r+i)*l,n[14]=(a+s)*c,n[15]=1,n}function ag(n,e,t,i){let r=e[0],s=e[1],a=e[2],o=i[0],l=i[1],c=i[2],u=r-t[0],m=s-t[1],h=a-t[2],p=u*u+m*m+h*h;p===0?h=1:(p=1/Math.sqrt(p),u*=p,m*=p,h*=p);let g=l*h-c*m,v=c*u-o*h,d=o*m-l*u;return p=g*g+v*v+d*d,p===0&&(c?o+=1e-6:l?c+=1e-6:l+=1e-6,g=l*h-c*m,v=c*u-o*h,d=o*m-l*u,p=g*g+v*v+d*d),p=1/Math.sqrt(p),g*=p,v*=p,d*=p,n[0]=g,n[1]=v,n[2]=d,n[3]=0,n[4]=m*d-h*v,n[5]=h*g-u*d,n[6]=u*v-m*g,n[7]=0,n[8]=u,n[9]=m,n[10]=h,n[11]=0,n[12]=r,n[13]=s,n[14]=a,n[15]=1,n}function Po(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3],n[4]=e[4]+t[4],n[5]=e[5]+t[5],n[6]=e[6]+t[6],n[7]=e[7]+t[7],n[8]=e[8]+t[8],n[9]=e[9]+t[9],n[10]=e[10]+t[10],n[11]=e[11]+t[11],n[12]=e[12]+t[12],n[13]=e[13]+t[13],n[14]=e[14]+t[14],n[15]=e[15]+t[15],n}function Do(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n[3]=e[3]-t[3],n[4]=e[4]-t[4],n[5]=e[5]-t[5],n[6]=e[6]-t[6],n[7]=e[7]-t[7],n[8]=e[8]-t[8],n[9]=e[9]-t[9],n[10]=e[10]-t[10],n[11]=e[11]-t[11],n[12]=e[12]-t[12],n[13]=e[13]-t[13],n[14]=e[14]-t[14],n[15]=e[15]-t[15],n}function og(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n[4]=e[4]*t,n[5]=e[5]*t,n[6]=e[6]*t,n[7]=e[7]*t,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=e[11]*t,n[12]=e[12]*t,n[13]=e[13]*t,n[14]=e[14]*t,n[15]=e[15]*t,n}class pr extends Array{constructor(e=1,t=0,i=0,r=0,s=0,a=1,o=0,l=0,c=0,u=0,m=1,h=0,p=0,g=0,v=0,d=1){return super(e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d),this}get x(){return this[12]}get y(){return this[13]}get z(){return this[14]}get w(){return this[15]}set x(e){this[12]=e}set y(e){this[13]=e}set z(e){this[14]=e}set w(e){this[15]=e}set(e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d){return e.length?this.copy(e):(Ym(this,e,t,i,r,s,a,o,l,c,u,m,h,p,g,v,d),this)}translate(e,t=this){return Zm(this,t,e),this}rotate(e,t,i=this){return Jm(this,i,e,t),this}scale(e,t=this){return Km(this,t,typeof e=="number"?[e,e,e]:e),this}add(e,t){return t?Po(this,e,t):Po(this,this,e),this}sub(e,t){return t?Do(this,e,t):Do(this,this,e),this}multiply(e,t){return e.length?t?Co(this,e,t):Co(this,this,e):og(this,this,e),this}identity(){return jm(this),this}copy(e){return qm(this,e),this}fromPerspective({fov:e,aspect:t,near:i,far:r}={}){return rg(this,e,t,i,r),this}fromOrthogonal({left:e,right:t,bottom:i,top:r,near:s,far:a}){return sg(this,e,t,i,r,s,a),this}fromQuaternion(e){return ig(this,e),this}setPosition(e){return this.x=e[0],this.y=e[1],this.z=e[2],this}inverse(e=this){return $m(this,e),this}compose(e,t,i){return ng(this,e,t,i),this}decompose(e,t,i){return tg(this,e,t,i),this}getRotation(e){return El(e,this),this}getTranslation(e){return Qm(e,this),this}getScaling(e){return Sl(e,this),this}getMaxScaleOnAxis(){return eg(this)}lookAt(e,t,i){return ag(this,e,t,i),this}determinant(){return Ml(this)}fromArray(e,t=0){return this[0]=e[t],this[1]=e[t+1],this[2]=e[t+2],this[3]=e[t+3],this[4]=e[t+4],this[5]=e[t+5],this[6]=e[t+6],this[7]=e[t+7],this[8]=e[t+8],this[9]=e[t+9],this[10]=e[t+10],this[11]=e[t+11],this[12]=e[t+12],this[13]=e[t+13],this[14]=e[t+14],this[15]=e[t+15],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e[t+3]=this[3],e[t+4]=this[4],e[t+5]=this[5],e[t+6]=this[6],e[t+7]=this[7],e[t+8]=this[8],e[t+9]=this[9],e[t+10]=this[10],e[t+11]=this[11],e[t+12]=this[12],e[t+13]=this[13],e[t+14]=this[14],e[t+15]=this[15],e}}function lg(n,e,t="YXZ"){return t==="XYZ"?(n[1]=Math.asin(Math.min(Math.max(e[8],-1),1)),Math.abs(e[8])<.99999?(n[0]=Math.atan2(-e[9],e[10]),n[2]=Math.atan2(-e[4],e[0])):(n[0]=Math.atan2(e[6],e[5]),n[2]=0)):t==="YXZ"?(n[0]=Math.asin(-Math.min(Math.max(e[9],-1),1)),Math.abs(e[9])<.99999?(n[1]=Math.atan2(e[8],e[10]),n[2]=Math.atan2(e[1],e[5])):(n[1]=Math.atan2(-e[2],e[0]),n[2]=0)):t==="ZXY"?(n[0]=Math.asin(Math.min(Math.max(e[6],-1),1)),Math.abs(e[6])<.99999?(n[1]=Math.atan2(-e[2],e[10]),n[2]=Math.atan2(-e[4],e[5])):(n[1]=0,n[2]=Math.atan2(e[1],e[0]))):t==="ZYX"?(n[1]=Math.asin(-Math.min(Math.max(e[2],-1),1)),Math.abs(e[2])<.99999?(n[0]=Math.atan2(e[6],e[10]),n[2]=Math.atan2(e[1],e[0])):(n[0]=0,n[2]=Math.atan2(-e[4],e[5]))):t==="YZX"?(n[2]=Math.asin(Math.min(Math.max(e[1],-1),1)),Math.abs(e[1])<.99999?(n[0]=Math.atan2(-e[9],e[5]),n[1]=Math.atan2(-e[2],e[0])):(n[0]=0,n[1]=Math.atan2(e[8],e[10]))):t==="XZY"&&(n[2]=Math.asin(-Math.min(Math.max(e[4],-1),1)),Math.abs(e[4])<.99999?(n[0]=Math.atan2(e[6],e[5]),n[1]=Math.atan2(e[8],e[0])):(n[0]=Math.atan2(-e[9],e[10]),n[1]=0)),n}const Lo=new pr;class cg extends Array{constructor(e=0,t=e,i=e,r="YXZ"){super(e,t,i),this.order=r,this.onChange=()=>{},this._target=this;const s=["0","1","2"];return new Proxy(this,{set(a,o){const l=Reflect.set(...arguments);return l&&s.includes(o)&&a.onChange(),l}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(e){this._target[0]=e,this.onChange()}set y(e){this._target[1]=e,this.onChange()}set z(e){this._target[2]=e,this.onChange()}set(e,t=e,i=e){return e.length?this.copy(e):(this._target[0]=e,this._target[1]=t,this._target[2]=i,this.onChange(),this)}copy(e){return this._target[0]=e[0],this._target[1]=e[1],this._target[2]=e[2],this.onChange(),this}reorder(e){return this._target.order=e,this.onChange(),this}fromRotationMatrix(e,t=this.order){return lg(this._target,e,t),this.onChange(),this}fromQuaternion(e,t=this.order,i){return Lo.fromQuaternion(e),this._target.fromRotationMatrix(Lo,t),i||this.onChange(),this}fromArray(e,t=0){return this._target[0]=e[t],this._target[1]=e[t+1],this._target[2]=e[t+2],this}toArray(e=[],t=0){return e[t]=this[0],e[t+1]=this[1],e[t+2]=this[2],e}}class hg{constructor(){this.parent=null,this.children=[],this.visible=!0,this.matrix=new pr,this.worldMatrix=new pr,this.matrixAutoUpdate=!0,this.worldMatrixNeedsUpdate=!1,this.position=new Gt,this.quaternion=new Wm,this.scale=new Gt(1),this.rotation=new cg,this.up=new Gt(0,1,0),this.rotation._target.onChange=()=>this.quaternion.fromEuler(this.rotation,!0),this.quaternion._target.onChange=()=>this.rotation.fromQuaternion(this.quaternion,void 0,!0)}setParent(e,t=!0){this.parent&&e!==this.parent&&this.parent.removeChild(this,!1),this.parent=e,t&&e&&e.addChild(this,!1)}addChild(e,t=!0){~this.children.indexOf(e)||this.children.push(e),t&&e.setParent(this,!1)}removeChild(e,t=!0){~this.children.indexOf(e)&&this.children.splice(this.children.indexOf(e),1),t&&e.setParent(null,!1)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.worldMatrixNeedsUpdate||e)&&(this.parent===null?this.worldMatrix.copy(this.matrix):this.worldMatrix.multiply(this.parent.worldMatrix,this.matrix),this.worldMatrixNeedsUpdate=!1,e=!0);for(let t=0,i=this.children.length;t<i;t++)this.children[t].updateMatrixWorld(e)}updateMatrix(){this.matrix.compose(this.quaternion,this.position,this.scale),this.worldMatrixNeedsUpdate=!0}traverse(e){if(!e(this))for(let t=0,i=this.children.length;t<i;t++)this.children[t].traverse(e)}decompose(){this.matrix.decompose(this.quaternion._target,this.position,this.scale),this.rotation.fromQuaternion(this.quaternion)}lookAt(e,t=!1){t?this.matrix.lookAt(this.position,e,this.up):this.matrix.lookAt(e,this.position,this.up),this.matrix.getRotation(this.quaternion._target),this.rotation.fromQuaternion(this.quaternion)}}function ug(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n}function fg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=t+t,o=i+i,l=r+r,c=t*a,u=i*a,m=i*o,h=r*a,p=r*o,g=r*l,v=s*a,d=s*o,f=s*l;return n[0]=1-m-g,n[3]=u-f,n[6]=h+d,n[1]=u+f,n[4]=1-c-g,n[7]=p-v,n[2]=h-d,n[5]=p+v,n[8]=1-c-m,n}function dg(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function pg(n,e,t,i,r,s,a,o,l,c){return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n[4]=s,n[5]=a,n[6]=o,n[7]=l,n[8]=c,n}function mg(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n}function gg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],m=u*a-o*c,h=-u*s+o*l,p=c*s-a*l,g=t*m+i*h+r*p;return g?(g=1/g,n[0]=m*g,n[1]=(-u*i+r*c)*g,n[2]=(o*i-r*a)*g,n[3]=h*g,n[4]=(u*t-r*l)*g,n[5]=(-o*t+r*s)*g,n[6]=p*g,n[7]=(-c*t+i*l)*g,n[8]=(a*t-i*s)*g,n):null}function Io(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],m=e[8],h=t[0],p=t[1],g=t[2],v=t[3],d=t[4],f=t[5],S=t[6],b=t[7],E=t[8];return n[0]=h*i+p*a+g*c,n[1]=h*r+p*o+g*u,n[2]=h*s+p*l+g*m,n[3]=v*i+d*a+f*c,n[4]=v*r+d*o+f*u,n[5]=v*s+d*l+f*m,n[6]=S*i+b*a+E*c,n[7]=S*r+b*o+E*u,n[8]=S*s+b*l+E*m,n}function _g(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],m=e[8],h=t[0],p=t[1];return n[0]=i,n[1]=r,n[2]=s,n[3]=a,n[4]=o,n[5]=l,n[6]=h*i+p*a+c,n[7]=h*r+p*o+u,n[8]=h*s+p*l+m,n}function xg(n,e,t){let i=e[0],r=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],m=e[8],h=Math.sin(t),p=Math.cos(t);return n[0]=p*i+h*a,n[1]=p*r+h*o,n[2]=p*s+h*l,n[3]=p*a-h*i,n[4]=p*o-h*r,n[5]=p*l-h*s,n[6]=c,n[7]=u,n[8]=m,n}function vg(n,e,t){let i=t[0],r=t[1];return n[0]=i*e[0],n[1]=i*e[1],n[2]=i*e[2],n[3]=r*e[3],n[4]=r*e[4],n[5]=r*e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n}function Mg(n,e){let t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],m=e[9],h=e[10],p=e[11],g=e[12],v=e[13],d=e[14],f=e[15],S=t*o-i*a,b=t*l-r*a,E=t*c-s*a,R=i*l-r*o,A=i*c-s*o,C=r*c-s*l,x=u*v-m*g,y=u*d-h*g,G=u*f-p*g,w=m*d-h*v,F=m*f-p*v,N=h*f-p*d,L=S*N-b*F+E*w+R*G-A*y+C*x;return L?(L=1/L,n[0]=(o*N-l*F+c*w)*L,n[1]=(l*G-a*N-c*y)*L,n[2]=(a*F-o*G+c*x)*L,n[3]=(r*F-i*N-s*w)*L,n[4]=(t*N-r*G+s*y)*L,n[5]=(i*G-t*F-s*x)*L,n[6]=(v*C-d*A+f*R)*L,n[7]=(d*E-g*C-f*b)*L,n[8]=(g*A-v*E+f*S)*L,n):null}class Sg extends Array{constructor(e=1,t=0,i=0,r=0,s=1,a=0,o=0,l=0,c=1){return super(e,t,i,r,s,a,o,l,c),this}set(e,t,i,r,s,a,o,l,c){return e.length?this.copy(e):(pg(this,e,t,i,r,s,a,o,l,c),this)}translate(e,t=this){return _g(this,t,e),this}rotate(e,t=this){return xg(this,t,e),this}scale(e,t=this){return vg(this,t,e),this}multiply(e,t){return t?Io(this,e,t):Io(this,this,e),this}identity(){return mg(this),this}copy(e){return dg(this,e),this}fromMatrix4(e){return ug(this,e),this}fromQuaternion(e){return fg(this,e),this}fromBasis(e,t,i){return this.set(e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]),this}inverse(e=this){return gg(this,e),this}getNormalMatrix(e){return Mg(this,e),this}}let Eg=0;class yg extends hg{constructor(e,{geometry:t,program:i,mode:r=e.TRIANGLES,frustumCulled:s=!0,renderOrder:a=0}={}){super(),e.canvas||console.error("gl not passed as first argument to Mesh"),this.gl=e,this.id=Eg++,this.geometry=t,this.program=i,this.mode=r,this.frustumCulled=s,this.renderOrder=a,this.modelViewMatrix=new pr,this.normalMatrix=new Sg,this.beforeRenderCallbacks=[],this.afterRenderCallbacks=[]}onBeforeRender(e){return this.beforeRenderCallbacks.push(e),this}onAfterRender(e){return this.afterRenderCallbacks.push(e),this}draw({camera:e}={}){e&&(this.program.uniforms.modelMatrix||Object.assign(this.program.uniforms,{modelMatrix:{value:null},viewMatrix:{value:null},modelViewMatrix:{value:null},normalMatrix:{value:null},projectionMatrix:{value:null},cameraPosition:{value:null}}),this.program.uniforms.projectionMatrix.value=e.projectionMatrix,this.program.uniforms.cameraPosition.value=e.worldPosition,this.program.uniforms.viewMatrix.value=e.viewMatrix,this.modelViewMatrix.multiply(e.viewMatrix,this.worldMatrix),this.normalMatrix.getNormalMatrix(this.modelViewMatrix),this.program.uniforms.modelMatrix.value=this.worldMatrix,this.program.uniforms.modelViewMatrix.value=this.modelViewMatrix,this.program.uniforms.normalMatrix.value=this.normalMatrix),this.beforeRenderCallbacks.forEach(i=>i&&i({mesh:this,camera:e}));let t=this.program.cullFace&&this.worldMatrix.determinant()<0;this.program.use({flipFaces:t}),this.geometry.draw({mode:this.mode,program:this.program}),this.afterRenderCallbacks.forEach(i=>i&&i({mesh:this,camera:e}))}}class bg extends xm{constructor(e,{attributes:t={}}={}){Object.assign(t,{position:{size:2,data:new Float32Array([-1,-1,3,-1,-1,3])},uv:{size:2,data:new Float32Array([0,0,2,0,0,2])}}),super(e,t)}}const Fo=n=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?[parseInt(e[1],16)/255,parseInt(e[2],16)/255,parseInt(e[3],16)/255]:[1,1,1]},Uo=(n,e,t)=>{switch(n){case"top-left":return{anchor:[0,-.2*t],dir:[0,1]};case"top-right":return{anchor:[e,-.2*t],dir:[0,1]};case"left":return{anchor:[-.2*e,.5*t],dir:[1,0]};case"right":return{anchor:[(1+.2)*e,.5*t],dir:[-1,0]};case"bottom-left":return{anchor:[0,(1+.2)*t],dir:[0,-1]};case"bottom-center":return{anchor:[.5*e,(1+.2)*t],dir:[0,-1]};case"bottom-right":return{anchor:[e,(1+.2)*t],dir:[0,-1]};default:return{anchor:[.5*e,-.2*t],dir:[0,1]}}},Tg=`
4259
4259
  attribute vec2 position;
4260
4260
  varying vec2 vUv;
4261
4261
  void main() {
4262
4262
  vUv = position * 0.5 + 0.5;
4263
4263
  gl_Position = vec4(position, 0.0, 1.0);
4264
- }`,Tg=`precision highp float;
4264
+ }`,Ag=`precision highp float;
4265
4265
 
4266
4266
  uniform float iTime;
4267
4267
  uniform vec2 iResolution;
@@ -4353,4 +4353,4 @@ void main() {
4353
4353
  vec4 color;
4354
4354
  mainImage(color, gl_FragCoord.xy);
4355
4355
  gl_FragColor = color;
4356
- }`;function Ag({raysOrigin:n="top-center",raysColor:e="#ffffff",raysSpeed:t=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:a=1,saturation:o=1,followMouse:l=!0,mouseInfluence:c=.1,noiseAmount:u=0,distortion:p=0,className:h=""}){const d=He.useRef(null),g=He.useRef(null),v=He.useRef(null),m=He.useRef({x:.5,y:.5}),f=He.useRef({x:.5,y:.5}),S=He.useRef(null),b=He.useRef(null),E=He.useRef(null),[R,A]=He.useState(!1),C=He.useRef(null);return He.useEffect(()=>{if(d.current)return C.current=new IntersectionObserver(x=>{A(x[0].isIntersecting)},{threshold:.1}),C.current.observe(d.current),()=>{C.current&&(C.current.disconnect(),C.current=null)}},[]),He.useEffect(()=>!R||!d.current?void 0:(E.current&&(E.current(),E.current=null),(async()=>{if(!d.current||(await new Promise(O=>setTimeout(O,10)),!d.current))return;const y=new bm({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});v.current=y;const G=y.gl;for(G.canvas.style.width="100%",G.canvas.style.height="100%";d.current.firstChild;)d.current.removeChild(d.current.firstChild);d.current.appendChild(G.canvas);const w={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:Fo(e)},raysSpeed:{value:t},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:a},saturation:{value:o},mousePos:{value:[.5,.5]},mouseInfluence:{value:c},noiseAmount:{value:u},distortion:{value:p}};g.current=w;const F=new yg(G),N=new vm(G,{vertex:bg,fragment:Tg,uniforms:w}),L=new Eg(G,{geometry:F,program:N});b.current=L;const B=()=>{if(!d.current||!y)return;y.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:O,clientHeight:J}=d.current;y.setSize(O,J);const Z=y.dpr,le=O*Z,de=J*Z;w.iResolution.value=[le,de];const{anchor:ue,dir:Pe}=Uo(n,le,de);w.rayPos.value=ue,w.rayDir.value=Pe},H=O=>{if(!(!v.current||!g.current||!b.current)){w.iTime.value=O*.001,l&&c>0&&(f.current.x=f.current.x*.92+m.current.x*(1-.92),f.current.y=f.current.y*.92+m.current.y*(1-.92),w.mousePos.value=[f.current.x,f.current.y]);try{y.render({scene:L}),S.current=requestAnimationFrame(H)}catch(J){console.warn("WebGL rendering error:",J)}}};window.addEventListener("resize",B),B(),S.current=requestAnimationFrame(H),E.current=()=>{if(S.current&&(cancelAnimationFrame(S.current),S.current=null),window.removeEventListener("resize",B),y)try{const O=y.gl.getExtension("WEBGL_lose_context");O&&O.loseContext();const J=y.gl.canvas;J&&J.parentNode&&J.parentNode.removeChild(J)}catch(O){console.warn("Error during WebGL cleanup:",O)}v.current=null,g.current=null,b.current=null}})(),()=>{E.current&&(E.current(),E.current=null)}),[R,n,e,t,i,r,s,a,o,l,c,u,p]),He.useEffect(()=>{if(!g.current||!d.current||!v.current)return;const x=g.current,y=v.current;x.raysColor.value=Fo(e),x.raysSpeed.value=t,x.lightSpread.value=i,x.rayLength.value=r,x.pulsating.value=s?1:0,x.fadeDistance.value=a,x.saturation.value=o,x.mouseInfluence.value=c,x.noiseAmount.value=u,x.distortion.value=p;const{clientWidth:G,clientHeight:w}=d.current,F=y.dpr,{anchor:N,dir:L}=Uo(n,G*F,w*F);x.rayPos.value=N,x.rayDir.value=L},[e,t,i,n,r,s,a,o,c,u,p]),He.useEffect(()=>{if(!l)return;const x=y=>{if(!d.current)return;const G=d.current.getBoundingClientRect();m.current={x:(y.clientX-G.left)/G.width,y:(y.clientY-G.top)/G.height}};return window.addEventListener("mousemove",x),()=>window.removeEventListener("mousemove",x)},[l]),$.jsx("div",{ref:d,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${h}`.trim()})}function wg({className:n}){return $.jsx("svg",{viewBox:"0 0 384 512",className:n,fill:"currentColor",children:$.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function Rg({className:n}){return $.jsx("svg",{viewBox:"0 0 16 16",className:n,fill:"currentColor",children:$.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function Cg({className:n}){return $.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:[$.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),$.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Pg({className:n}){return $.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:$.jsx("polyline",{points:"20 6 9 17 4 12"})})}const No="https://github.com/mm7894215/TokenTracker",Dg="https://github.com/mm7894215/TokenTracker/releases/latest";function Lg(n="default",e="md",t){const i="inline-flex items-center justify-center rounded font-medium transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",r={default:"bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200",ghost:"text-oai-gray-600 hover:text-oai-gray-900 hover:bg-oai-gray-100 active:bg-oai-gray-200 dark:text-oai-gray-400 dark:hover:text-white dark:hover:bg-oai-gray-800 dark:active:bg-oai-gray-700"},s={sm:"h-9 px-4 text-sm",md:"h-11 px-6 text-sm",lg:"h-12 px-8 text-base"};return as(i,r[n],s[e],t)}function Ig({copy:n,signInUrl:e,signUpUrl:t,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const a=Ul(),[o,l]=He.useState(!1);He.useEffect(()=>{const v=()=>l(window.scrollY>10);return window.addEventListener("scroll",v,{passive:!0}),()=>window.removeEventListener("scroll",v)},[]);const c=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:u,loading:p}=Pl(),h=He.useMemo(()=>({codex:n("landing.v2.models.agent.codex"),claude_code:n("landing.v2.models.agent.claude_code"),cursor:n("landing.v2.models.agent.cursor"),gemini:n("landing.v2.models.agent.gemini"),opencode:n("landing.v2.models.agent.opencode"),openclaw:n("landing.v2.models.agent.openclaw")}),[n]),d=He.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),g=a?{duration:0}:void 0;return $.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[$.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:$.jsx(Ag,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),$.jsx("header",{className:as("sticky top-0 z-50 transition-all duration-300",o?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:$.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[$.jsxs("div",{className:"flex items-center gap-5",children:[$.jsxs(Sr,{to:t||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[$.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),$.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),$.jsx("div",{className:"hidden sm:block",children:$.jsx(Fl,{})})]}),c&&$.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 sm:gap-3",children:[$.jsxs(Sr,{to:Ol(),className:as(Lg(u||p?"default":"ghost","sm"),"no-underline px-5 rounded-full group",u||p?"shadow-sm ring-1 ring-white/10":"ring-1 ring-oai-gray-700"),children:[n("landing.v2.cta.primary"),$.jsx("span",{className:"ml-2 inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]}),$.jsx(Dl,{})]})]})}),$.jsxs("main",{children:[$.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:$.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[$.jsxs(Er.div,{initial:a?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:g||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[$.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[n("landing.v2.hero.title_line1"),$.jsx("br",{}),$.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:n("landing.v2.hero.title_line2")})]}),$.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:n("landing.v2.hero.subtagline")}),$.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[$.jsxs(Er.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[$.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),$.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),$.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[$.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[$.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),$.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((v,m)=>$.jsxs("span",{className:v==="npx"||v==="tokentracker-cli"?"text-white font-medium":v==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[v," "]},m)):null})]}),$.jsx("button",{type:"button",onClick:s,"aria-label":n(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?$.jsx(Pg,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):$.jsx(Cg,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),$.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[$.jsxs("a",{href:Dg,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[$.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:$.jsx(wg,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),n("landing.v2.install.mac_cta")]}),$.jsxs("a",{href:No,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[$.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:$.jsx(Rg,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),n("landing.cta.secondary")]})]}),$.jsx("span",{className:"sr-only","aria-live":"polite",children:r?n("landing.install.action.copied"):""})]})]}),$.jsx("div",{className:"relative group w-full",children:$.jsxs(Er.div,{initial:a?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:g||{duration:.6,delay:.1},className:"relative w-full",children:[$.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:$.jsx(Qp,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),$.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:$.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[$.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),$.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),$.jsx("img",{src:"/dashboard-dark.png",alt:n("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),$.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:$.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:$.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[$.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:n("landing.v2.models.title")}),$.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:d.map(v=>$.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[$.jsx("img",{src:v.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${v.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),$.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:h[v.id]})]},v.id))})]})})}),$.jsx("section",{className:"py-20 lg:py-32",children:$.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[$.jsxs("div",{className:"max-w-md",children:[$.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:n("landing.v2.compare.kicker")}),$.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:n("landing.v2.compare.title")}),$.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:n("landing.v2.compare.subtitle")}),$.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:n("landing.v2.distill.body")})]}),$.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[$.jsxs("div",{className:"space-y-4",children:[$.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:n("landing.v2.compare.with.title")}),$.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p1")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p2")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p3")})]})]})]}),$.jsxs("div",{className:"space-y-4",children:[$.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:n("landing.v2.compare.without.title")}),$.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p1")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p2")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),$.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:$.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[$.jsx("p",{children:n("landing.v2.footer.line")}),$.jsxs("div",{className:"flex items-center gap-6",children:[$.jsx("a",{href:No,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:n("landing.v2.nav.github")}),c&&$.jsxs(Sr,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[n("landing.cta.primary")," →"]})]})]})})]})}function Fg({prefersReducedMotion:n,screenshotMode:e}){return!(e||n)}function Ug(){return He.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function Ng(n=0,e=!0){const[t,i]=He.useState(()=>!e);return He.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const a=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(a,{timeout:n||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(a,n),()=>{r!=null&&window.clearTimeout(r)})},[n,e]),t}function Vg({signInUrl:n,signUpUrl:e}){const t=kt("landing.handle.special"),i=kt("landing.handle.default");kt("landing.nav.login"),kt("landing.nav.signup");const[r,s]=He.useState(i),a=Ug(),o=He.useMemo(()=>typeof window>"u"?!1:Ll(window.location.search),[]),l=Fg({prefersReducedMotion:a,screenshotMode:o});Ng(250,l);const c="tokentracker.dashboard.from_landing.v1";He.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(c,"1")}catch{}},[c]),He.useMemo(()=>kt("landing.handle.placeholder",{handle:t}),[t]),He.useMemo(()=>{const g=r===t?kt("landing.rank.singularity"):kt("landing.rank.unranked");return kt("landing.rank.expectation",{rank:g})},[r,t]);const u=kt("landing.install.command"),[p,h]=He.useState(!1),d=async()=>{await Il(u)&&(h(!0),window.setTimeout(()=>h(!1),2e3))};return $.jsx(Ig,{copy:kt,reduceMotion:a,signInUrl:n,signUpUrl:e,installCommand:u,installCopied:p,onCopyInstallCommand:d})}export{Vg as LandingPage};
4356
+ }`;function wg({raysOrigin:n="top-center",raysColor:e="#ffffff",raysSpeed:t=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:a=1,saturation:o=1,followMouse:l=!0,mouseInfluence:c=.1,noiseAmount:u=0,distortion:m=0,className:h=""}){const p=He.useRef(null),g=He.useRef(null),v=He.useRef(null),d=He.useRef({x:.5,y:.5}),f=He.useRef({x:.5,y:.5}),S=He.useRef(null),b=He.useRef(null),E=He.useRef(null),[R,A]=He.useState(!1),C=He.useRef(null);return He.useEffect(()=>{if(p.current)return C.current=new IntersectionObserver(x=>{A(x[0].isIntersecting)},{threshold:.1}),C.current.observe(p.current),()=>{C.current&&(C.current.disconnect(),C.current=null)}},[]),He.useEffect(()=>!R||!p.current?void 0:(E.current&&(E.current(),E.current=null),(async()=>{if(!p.current||(await new Promise(O=>setTimeout(O,10)),!p.current))return;const y=new Tm({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});v.current=y;const G=y.gl;for(G.canvas.style.width="100%",G.canvas.style.height="100%";p.current.firstChild;)p.current.removeChild(p.current.firstChild);p.current.appendChild(G.canvas);const w={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:Fo(e)},raysSpeed:{value:t},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:a},saturation:{value:o},mousePos:{value:[.5,.5]},mouseInfluence:{value:c},noiseAmount:{value:u},distortion:{value:m}};g.current=w;const F=new bg(G),N=new Mm(G,{vertex:Tg,fragment:Ag,uniforms:w}),L=new yg(G,{geometry:F,program:N});b.current=L;const B=()=>{if(!p.current||!y)return;y.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:O,clientHeight:J}=p.current;y.setSize(O,J);const Z=y.dpr,le=O*Z,de=J*Z;w.iResolution.value=[le,de];const{anchor:ue,dir:Pe}=Uo(n,le,de);w.rayPos.value=ue,w.rayDir.value=Pe},H=O=>{if(!(!v.current||!g.current||!b.current)){w.iTime.value=O*.001,l&&c>0&&(f.current.x=f.current.x*.92+d.current.x*(1-.92),f.current.y=f.current.y*.92+d.current.y*(1-.92),w.mousePos.value=[f.current.x,f.current.y]);try{y.render({scene:L}),S.current=requestAnimationFrame(H)}catch(J){console.warn("WebGL rendering error:",J)}}};window.addEventListener("resize",B),B(),S.current=requestAnimationFrame(H),E.current=()=>{if(S.current&&(cancelAnimationFrame(S.current),S.current=null),window.removeEventListener("resize",B),y)try{const O=y.gl.getExtension("WEBGL_lose_context");O&&O.loseContext();const J=y.gl.canvas;J&&J.parentNode&&J.parentNode.removeChild(J)}catch(O){console.warn("Error during WebGL cleanup:",O)}v.current=null,g.current=null,b.current=null}})(),()=>{E.current&&(E.current(),E.current=null)}),[R,n,e,t,i,r,s,a,o,l,c,u,m]),He.useEffect(()=>{if(!g.current||!p.current||!v.current)return;const x=g.current,y=v.current;x.raysColor.value=Fo(e),x.raysSpeed.value=t,x.lightSpread.value=i,x.rayLength.value=r,x.pulsating.value=s?1:0,x.fadeDistance.value=a,x.saturation.value=o,x.mouseInfluence.value=c,x.noiseAmount.value=u,x.distortion.value=m;const{clientWidth:G,clientHeight:w}=p.current,F=y.dpr,{anchor:N,dir:L}=Uo(n,G*F,w*F);x.rayPos.value=N,x.rayDir.value=L},[e,t,i,n,r,s,a,o,c,u,m]),He.useEffect(()=>{if(!l)return;const x=y=>{if(!p.current)return;const G=p.current.getBoundingClientRect();d.current={x:(y.clientX-G.left)/G.width,y:(y.clientY-G.top)/G.height}};return window.addEventListener("mousemove",x),()=>window.removeEventListener("mousemove",x)},[l]),$.jsx("div",{ref:p,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${h}`.trim()})}function Rg({className:n}){return $.jsx("svg",{viewBox:"0 0 384 512",className:n,fill:"currentColor",children:$.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function Cg({className:n}){return $.jsx("svg",{viewBox:"0 0 16 16",className:n,fill:"currentColor",children:$.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function Pg({className:n}){return $.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:[$.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),$.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Dg({className:n}){return $.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,children:$.jsx("polyline",{points:"20 6 9 17 4 12"})})}const No="https://github.com/mm7894215/TokenTracker",Lg="https://github.com/mm7894215/TokenTracker/releases/latest";function Ig({copy:n,signInUrl:e,signUpUrl:t,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const a=Ol(),[o,l]=He.useState(!1);He.useEffect(()=>{const d=()=>l(window.scrollY>10);return window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[]);const c=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:u,loading:m}=Pl(),{openLoginModal:h}=Dl(),p=He.useMemo(()=>({codex:n("landing.v2.models.agent.codex"),claude_code:n("landing.v2.models.agent.claude_code"),cursor:n("landing.v2.models.agent.cursor"),gemini:n("landing.v2.models.agent.gemini"),opencode:n("landing.v2.models.agent.opencode"),openclaw:n("landing.v2.models.agent.openclaw")}),[n]),g=He.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),v=a?{duration:0}:void 0;return $.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[$.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:$.jsx(wg,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),$.jsx("header",{className:Il("sticky top-0 z-50 transition-all duration-300",o?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:$.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[$.jsxs("div",{className:"flex items-center gap-5",children:[$.jsxs(mi,{to:t||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[$.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),$.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),$.jsx("div",{className:"hidden sm:block",children:$.jsx(Nl,{})})]}),$.jsxs("div",{className:"flex items-center justify-end gap-5 sm:gap-6",children:[$.jsx(mi,{to:"/leaderboard",className:"text-sm font-medium text-oai-gray-400 hover:text-white transition-colors duration-200 select-none outline-none focus-visible:underline",children:n("nav.leaderboard")}),!u&&!m&&$.jsx(mi,{to:Sa(),className:"text-sm font-medium text-oai-gray-400 hover:text-white transition-colors duration-200 select-none outline-none focus-visible:underline",children:n("landing.v2.cta.primary")}),$.jsx("div",{className:"flex items-center gap-2.5 sm:gap-3.5",children:m?$.jsx("div",{className:"h-8 w-16 animate-pulse rounded-[8px] bg-white/10","aria-hidden":!0}):u?$.jsxs($.Fragment,{children:[$.jsx(mi,{to:Sa(),className:"inline-flex h-8 items-center justify-center rounded-[8px] bg-white px-3.5 text-xs font-bold text-oai-gray-950 hover:bg-oai-gray-100 transition-all duration-200 active:scale-[0.98] shadow-sm select-none",children:n("landing.v2.cta.primary")}),$.jsx(Ll,{})]}):$.jsx("button",{type:"button",onClick:h,className:"inline-flex h-8 min-w-[80px] items-center justify-center rounded-[8px] bg-white px-3.5 text-xs font-bold text-oai-gray-950 hover:bg-oai-gray-100 transition-all duration-200 active:scale-[0.98] shadow-sm select-none",children:n("header.auth.sign_in_aria")})})]})]})}),$.jsxs("main",{children:[$.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:$.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[$.jsxs(Er.div,{initial:a?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:v||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[$.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[n("landing.v2.hero.title_line1"),$.jsx("br",{}),$.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:n("landing.v2.hero.title_line2")})]}),$.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:n("landing.v2.hero.subtagline")}),$.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[$.jsxs(Er.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[$.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),$.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),$.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[$.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[$.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),$.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((d,f)=>$.jsxs("span",{className:d==="npx"||d==="tokentracker-cli"?"text-white font-medium":d==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[d," "]},f)):null})]}),$.jsx("button",{type:"button",onClick:s,"aria-label":n(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?$.jsx(Dg,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):$.jsx(Pg,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),$.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[$.jsxs("a",{href:Lg,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[$.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:$.jsx(Rg,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),n("landing.v2.install.mac_cta")]}),$.jsxs("a",{href:No,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[$.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:$.jsx(Cg,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),n("landing.cta.secondary")]})]}),$.jsx("span",{className:"sr-only","aria-live":"polite",children:r?n("landing.install.action.copied"):""})]})]}),$.jsx("div",{className:"relative group w-full",children:$.jsxs(Er.div,{initial:a?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:v||{duration:.6,delay:.1},className:"relative w-full",children:[$.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:$.jsx(em,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),$.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:$.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[$.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),$.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),$.jsx("img",{src:"/dashboard-dark.png",alt:n("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),$.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:$.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:$.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[$.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:n("landing.v2.models.title")}),$.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:g.map(d=>$.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[$.jsx("img",{src:d.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${d.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),$.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:p[d.id]})]},d.id))})]})})}),$.jsx("section",{className:"py-20 lg:py-32",children:$.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[$.jsxs("div",{className:"max-w-md",children:[$.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:n("landing.v2.compare.kicker")}),$.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:n("landing.v2.compare.title")}),$.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:n("landing.v2.compare.subtitle")}),$.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:n("landing.v2.distill.body")})]}),$.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[$.jsxs("div",{className:"space-y-4",children:[$.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:n("landing.v2.compare.with.title")}),$.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p1")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p2")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),$.jsx("span",{children:n("landing.v2.compare.with.p3")})]})]})]}),$.jsxs("div",{className:"space-y-4",children:[$.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:n("landing.v2.compare.without.title")}),$.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p1")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p2")})]}),$.jsxs("li",{className:"flex gap-2",children:[$.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),$.jsx("span",{children:n("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),$.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:$.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[$.jsx("p",{children:n("landing.v2.footer.line")}),$.jsxs("div",{className:"flex items-center gap-6",children:[$.jsx("a",{href:No,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:n("landing.v2.nav.github")}),c&&$.jsxs(mi,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[n("landing.cta.primary")," →"]})]})]})})]})}function Fg({prefersReducedMotion:n,screenshotMode:e}){return!(e||n)}function Ug(){return He.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function Ng(n=0,e=!0){const[t,i]=He.useState(()=>!e);return He.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const a=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(a,{timeout:n||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(a,n),()=>{r!=null&&window.clearTimeout(r)})},[n,e]),t}function Vg({signInUrl:n,signUpUrl:e}){const t=kt("landing.handle.special"),i=kt("landing.handle.default");kt("landing.nav.login"),kt("landing.nav.signup");const[r,s]=He.useState(i),a=Ug(),o=He.useMemo(()=>typeof window>"u"?!1:Fl(window.location.search),[]),l=Fg({prefersReducedMotion:a,screenshotMode:o});Ng(250,l);const c="tokentracker.dashboard.from_landing.v1";He.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(c,"1")}catch{}},[c]),He.useMemo(()=>kt("landing.handle.placeholder",{handle:t}),[t]),He.useMemo(()=>{const g=r===t?kt("landing.rank.singularity"):kt("landing.rank.unranked");return kt("landing.rank.expectation",{rank:g})},[r,t]);const u=kt("landing.install.command"),[m,h]=He.useState(!1),p=async()=>{await Ul(u)&&(h(!0),window.setTimeout(()=>h(!1),2e3))};return $.jsx(Ig,{copy:kt,reduceMotion:a,signInUrl:n,signUpUrl:e,installCommand:u,installCopied:m,onCopyInstallCommand:p})}export{Vg as LandingPage};